如何获取呼叫过程Windows用户访问令牌 [英] How to get Calling-Process Windows User Access Token
问题描述
如何为创建调用我的应用程序的进程的用户获取访问令牌?
How can I get the Access Token for the user that created the process that called my application?
我需要使用该令牌进行模拟,其目的是访问该用户applicationData中的文件.
I need to use that Token for impersonation, the idea is to access a file in that users applicationData.
P.S.模仿用户的应用程序是在系统下运行的服务.
P.S. The application that will be impersonating the user is a service running under System.
推荐答案
检查MSDN,所有这些API都有据可查. 您可能想要执行以下操作:
Check MSDN, all this API is well documented. You probably want to do something like this:
HANDLE thisToken, thisProcess;
thisProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId() );
OpenProcessToken( thisProcess, TOKEN_ALL_ACCESS, &thisToken );
http://msdn.microsoft.com /en-us/library/aa379295(v=vs.85).aspx
尽管您可能想要的访问量少于该数量. 这将为您获取当前进程的令牌.
Though you probably want less access than that. This will get you the token for the current process.
这篇关于如何获取呼叫过程Windows用户访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!