Problem with Impersonation to execute batch file via ASP.Net

E

Elroyskimms

I need to execute a batch file via ASP.Net. In my VB.Net code, I'm
using System.Diagnostics.Process to call the batch file and its
appropriate command line arguments. I'm using
System.Diagnostics.Process.StandardError and
System.Diagnostics.Process.StandardOutput to capture and view the
output and error messages. My web.config file has the following:

<identity impersonate="true" userName="administrator"
password="password" />

I'm also using
System.Security.Principal.WindowsIdentity.GetCurrent().Name to verify
that Impersonation is working and that the process is being executed
under the correct username.

The response I get is "Access Is Denied".

For testing reasons, I've changed the VB code to call a command line
function instead of my batch file, and if the command line function
does not make any changes to the system, the output is returned as
expected. If the command line function makes a change, I get the
response of Access Is Denied.

For example, if I run:
cacls /?
The output is the instructions for the cacls function.

But if I run:
cacls test.bat /e /g administrator:F
The response is Access is denied.

I've also tried using schtasks to add my batch file as a scheduled task
via the command line. If I run:
schtasks /?
The ouput is the instructions for the schtasks function.

But if I run:
schtasks /create /s \\SERVERNAME /U administrator /P password /RU
administrator /RP password /SC ONCE /TN RunMyBATFile /TR C:\test.bat
/ST 23:30:00
The output is "Access Is Denied"

All of my command line calls are tested on my local machine, so I know
that there are no syntax problems. Impersonation "appears" to be
working based on the output of
System.Security.Principal.WindowsIdentity.GetCurrent().Name. But the
admin. account should have complete access to this system, but I must
be missing something. Please help!!!

-E
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top