내 설정입니다 (7 IIS)에 CreateProcessAsUser는
- IIS 7은 웹 사이트에서 일부 3D 작업 (WPF)을 요청 받고 결국 IIS 7에서 이미지를 렌더링하고 디스크 어딘가에 저장하여 웹 사이트에로드합니다.
내가 알고 내가 이미 아직 테스트 한 :
- 가 2008 년
- 세션 0에서 어떤 서비스가 비디오 드라이버에 액세스 할 수 없습니다 Windows 서버에 세션 0에 서비스로 7 개 IIS를 실행하는 0 세션에서 서비스가 없습니다. 렌더링 작업을 수행 할 수 있습니다. (Session 0 Isolation)
- Microsoft는 다른 세션에서 렌더링을 성공적으로 수행하기 위해 사용자 세션 (CreateProcessAsUser)에서 프로세스를 만들 것을 제안합니다.
지금까지 달성 무엇 :
- LogonUser 잘 작동
- 에 CreateProcessAsUser는
유일한 (그러나 중요한) 부분이 작동하지 않습니다 잘 작동 : 을 때 나는 사용자 이름과 암호를 사용하여 로그온하고 프로세스를 사용자로 만들면 프로세스는 여전히 세션 0이므로 렌더링이 실패합니다. 사용자가 성공적으로 로그온했습니다 (확인). Microsoft에 따르면 사용자 세션 (세션 0 아님)에서 프로세스를 생성 할 수 있어야합니다.
- 어떻게 0 이외의 세션에서 사용자로 프로세스를 만들 수 있습니까?
- 나 자신이나 이와 비슷한 세션을 새로 만들어야합니까?
고맙습니다!
내 코드 :
PROCESS_INFORMATION processInfo = new PROCESS_INFORMATION();
STARTUPINFO startInfo = new STARTUPINFO();
Boolean bResult = false;
IntPtr hToken = IntPtr.Zero;
UInt32 uiResultWait = WAIT_FAILED;
int processCreationFlags;
try
{
// Logon user
bResult = Win32.LogonUser(
strName,
strDomain,
strPassword,
Win32.LogonType.LOGON32_LOGON_BATCH,
Win32.LogonProvider.LOGON32_PROVIDER_DEFAULT,
out hToken
);
if (!bResult) { throw new Exception("Logon error #" + Marshal.GetLastWin32Error()); }
CheckPrivileges(hToken);
// Create process
startInfo.cb = Marshal.SizeOf(startInfo);
startInfo.lpDesktop = null;
startInfo.dwFlags = Convert.ToInt32(STARTF.STARTF_USESHOWWINDOW);
startInfo.wShowWindow = Convert.ToInt16(SHOWWINDOW.SW_HIDE);
processCreationFlags = Convert.ToInt32(CreateProcessFlags.CREATE_BREAKAWAY_FROM_JOB);
retStr += "command line: " + strCommand + Environment.NewLine;
bResult = Win32.CreateProcessAsUser(
hToken,
null, //application name
strCommand, //command line
IntPtr.Zero, //process attributes
IntPtr.Zero, //thread attributes
false, //inherit handles
processCreationFlags, //process creation flags
IntPtr.Zero, //environment
curDir, //current directory
ref startInfo,
out processInfo
);
if (!bResult) { throw new Exception("CreateProcessAsUser error #" + Marshal.GetLastWin32Error()); }
// Wait for process to end
uiResultWait = WaitForSingleObject(processInfo.hProcess, INFINITE);
if (uiResultWait == WAIT_FAILED) { throw new Exception("WaitForSingleObject error #" + Marshal.GetLastWin32Error()); }
}
finally
{
// Close all handles
CloseHandle(hToken);
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}