2014-05-15 5 views
0

I 외부 박쥐 통화하는 ASP .NET 2.0 웹 애플리케이션 내부에 다음과 같은 코드가 있습니다ASP .NET에서 (EXE 파일을 실행) 일괄 실행

using (Process process = new Process()) 
{ 
    process.StartInfo.FileName = command; 
    process.StartInfo.Arguments = args; 
    process.Start(); 

    process.WaitForExit(); 
    int exitCode = process.ExitCode; 
} 

이 코드는 잘 작동하고 배치 스크립트를 성공적으로 실행됩니다.

일괄 처리 스크립트에서 외부 실행 파일 (exe가 무엇을하든)을 호출하려고하면 사용자 권한과 관련된 오류가 발생합니다 (불행히도 전체 오류 메시지가 표시되지는 않지만 ASP .NET 사용자는 실행 파일을 실행할 수 없습니다

나는 지정된 사용자 사용하려면이 매개 변수를 지정하는 것을 시도했다

:..

process.StartInfo.UserName = "User"; 
process.StartInfo.Password = this.ConvertToSecureString("Password"); 
process.StartInfo.UseShellExecute = false; 

하지만 프로세스가 영원히 중단을

+0

Active Directory에서 사용자를 사용하고 있습니까? – Daniele

+0

@Daniele 아니요, 로컬 서버에 있습니다. –

답변

0

당신이 시도 할 수 있습니다 this 오래된 articl

public void Page_Load(Object s, EventArgs e) 
{ 
    if(impersonateValidUser("username", "domain", "password")) 
    { 
     //Insert your code that runs under the security context of a specific user here. 
     undoImpersonation(); 
    } 
    else 
    { 
     //Your impersonation failed. Therefore, include a fail-safe mechanism here. 
    } 
} 

: Microsoft에서 전자, 그것은 단지 내부에 전화를 구현, 당신은 볼 스파게티 코드에 대한 두려워하지 말고, ASP.NET에서 가장을 목적으로, 윈도우 API를 사용하는 방법을 설명 희망이 도움이됩니다.