473,388 Members | 1,340 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Problem with Impersonation to execute batch file via ASP.Net

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.GetCurre nt().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.GetCurre nt().Name. But the
admin. account should have complete access to this system, but I must
be missing something. Please help!!!

-E

Jul 18 '06 #1
0 2245

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: WKC | last post by:
Hi guys, I really have a strange problem that I have no where to look for answer. I have a DTS that generate a text file with data queries from sql server 2K then stores it in a local drive. The...
1
by: carrot | last post by:
With .Net Studio, I have a solution includes some projects. I want to execute a batch file during build solution time. For example, 1'st project is builded. 2'nd project is builded. " a batch...
1
by: Charles | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
3
by: Granger Godbold | last post by:
I've found a solution to this that I think I like, but I thought it wise to put it out for all to see so people could punch holes in it as they wished. (Is there a better way?) I want a page in...
6
by: Page Horton | last post by:
I have a ASP.NET (VB) web application running. The DTS package is suppose to generates a flat file to a file path (aka: \\myStation\outputFiles\). When it runs it generates the following error on...
0
by: Jim Heavey | last post by:
Hello, I have been taking a swing at learning how I can use Impersonation via code and I am getting back an error code of 1314. By searching the internet, I have come to believe that this error...
7
by: David R. | last post by:
Hello all, I would like to generate a Sql-Script-File and a Batch-File to execute the Batch-File over C#-Code and use the SQL-File as an Input-File for the command "osql" in the Batch-File. I...
0
by: Rob Roberts | last post by:
I have developed an ASP.NET 2.0 application using localhost on my Windows XP workstation, and it all works fine there. I tried to copy it to my test web server, which is a domain controller...
1
by: Patrick | last post by:
I have an ASP.NET web service whose Web.Config is set to use impersonation <authentication mode="Windows" /> <identity impersonate="true" /> Within a Web Method, I want to use...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.