【发布时间】:2012-03-26 14:14:06
【问题描述】:
无论我是否被提升,我都需要使用 TokenStatistics 类获取 GetTokenInformation 返回的 AuthenticationID。
让我给你一些更多的信息。假设我这样做:
var Result = GetTokenInformation(WindowsIdentity.GetCurrent().Token, TOKEN_INFORMATION_CLASS.TokenStatistics, TokenInformation, TokenInfLength, out TokenInfLength);
这将允许我毫无问题地从 TokenInformation 结构中获取 AuthenticationID。假设生成的 authenticationID 是“00000000-00001234”
现在,如果我右键单击 Visual Studio 并单击“以管理员身份运行”,再次启动我的代码,结果将是其他内容,例如“00000000-00001289”。但我需要“00000000-00001234”
无论当前进程是否被提升,我怎样才能得到“00000000-00001234”?
我想这只是找到合适的 Token 以提供给 GetTokenInformation 的问题,但我在这里绕着圈子跑......
注意:我的代码基于 How to get the logon SID in C# 来实现 GetTokenInformation,然后对其进行调整以获取 TokenStatistics。
【问题讨论】:
标签: c# windows uac advapi32 process-elevation