Why can't my ASP.NET web service start the process, but my .NET console application can?

This is the code from the class library:

proc.StartInfo = new ProcessStartInfo (CmdPath, "+ an -b");
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.Start ();
proc.WaitForExit ();

This works fine, as I would expect when called from a console test application. When I take the same library and call the method from the ASP.NET web service, it just hangs.

Is there something I am missing here, perhaps permission? The ASPNET service has access to the folder where the EXE is located, and I see that it is running in the task manager, although it does nothing.

If someone tells me what I'm doing wrong, I would appreciate it. Thanks.

EDIT : Sorry for the lack of information. CmdPath goes to the command line interface for our scheduling software. I pass commands based on the documentation they provided. I have one way to get the list of tasks and another method to start the task .... hmm idea. The client usually uses Active Directory to log in, I think impersonation will be necessary. Now let's start testing.

EDIT 2 : Ok, now the client will explode with AccessViolation issues. This is obviously a permission issue. If the software uses the built-in AD authorization and I impersonate my AD account, will that be enough? I am doing an impersonation using a tag in web.config.

+3
7

, ASPNET, ( btw), , , .

+10

ASP.Net, , . , , .

+3

. ASPNET , .

, , ASPNET ? , .

, - IIS, , , .

+2

ASP.NET , ( , .)

:

  • asp.net . . , .
  • asp.net . . , .

.

+2

, ReadToEnd StandardOutput?

0

, , , ASP.NET (NETWORK SERVICE IIS 6.0), . , , , - , . - WebApplication - VS, "Casini", . , ASP.NET. , , , , , , .

0

Instead of impersonating or granting others privileges to Asp.net, how about starting a process under different credentials. In the example below, UserWithVeryLimitedRights will be the new account that you create with sufficient privileges to run the application. This can minimize security risks.

ProcessStartInfo StartInfo = new ProcessStartInfo();
SecureString ss = new SecureString();
string insecurePassword = "SomePassword";

foreach(char passChar in insecurePassword.ToCharArray()) {
ss.AppendChar(passChar);
}

StartInfo.RedirectStandardInput = true;
StartInfo.RedirectStandardError = true;
StartInfo.RedirectStandardOutput = true; 

StartInfo.CreateNoWindow = true;
StartInfo.UseShellExecute = false;
StartInfo.Password = ss;
StartInfo.UserName = @"UserWithVeryLimitedRights";
StartInfo.FileName = @"c:\winnt\notepad.exe";
Process.Start(StartInfo);
0
source

Source: https://habr.com/ru/post/1724751/


All Articles