从 Windows 7 服务启动应用程序
我们目前正在使用一个报告打印应用程序,该应用程序由位于 Firebird 数据库中的用户定义函数启动,该函数作为服务运行。
UDF 由一个简单的 DLL 组成,该 DLL 启动报告应用程序并通过“CreateProcessAsUser”API 传递要打印的报告 ID。
具体来说,我们正在模拟特定的 Windows 帐户,以便访问用户的打印机。 运行该软件的计算机从未有人参与。没有人真正在其上打开会话。
我们的做法如下:
LogonUser( sUser, nil, sPass, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, hToken );
...
LoadUserProfile(hToken, ProfileInfo) ;
...
ImpersonateLoggedOnUser(hToken);
...
StartupInfo.lpDesktop := Pchar('Winsta0\Default');
CreateProcessAsUser(hToken,nil, Pchar(sCommand), nil, nil, False , 0, 无, 无, 启动信息, ProcessInfo);
...
UnloadUserProfile(hToken,ProfileInfo.hProfile);
现在我们已经转移到 Windows 7 平台,显然,它不再起作用了。
即使用户未登录,是否仍然可以模拟用户帐户并通过 Windows Vista/7 下的服务使用其打印机? (否则我会使用用户当前活动的会话 ID)
感谢您的帮助
We are currently using a report printing application launched by a user-defined function located in a Firebird database which runs as a service.
The UDF consists of a simple DLL that launches the reporting application and pass the report ID to be printed through "CreateProcessAsUser" API.
In details, we are impersonating a particular windows account in order to have access to the user's printer.
The computer on which the software is run is never attended. No one actually open a session on it.
So here's how we're doing it:
LogonUser( sUser, nil, sPass, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, hToken );
...
LoadUserProfile(hToken, ProfileInfo);
...
ImpersonateLoggedOnUser(hToken);
...
StartupInfo.lpDesktop := Pchar('Winsta0\Default');
CreateProcessAsUser(hToken,nil, Pchar(sCommand), nil, nil, False, 0, nil, nil, StartupInfo,
ProcessInfo);
...
UnloadUserProfile(hToken,ProfileInfo.hProfile);
Now we have moved to windows 7 platform and obviously, it doesn't work anymore.
Is it still possible to impersonate a user account and use his printer from a service under windows vista/7 even if the user is not logged on ? (Otherwise I'd use the user's currently active session ID)
Thanks for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论