如何获取会话的默认LUID [英] How to get the default LUID of a session

查看:106
本文介绍了如何获取会话的默认LUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的用户是管理员组的成员。如果他们正常运行应用程序,则该过程将具有"默认"应用程序。 LUID。但是,如果他们使用runas管理员启动应用程序,则该进程将具有不同的LUID。当进程开始时,
我想检测这种情况。如果"正常"运行好。但是如果以不同的用户身份运行,那么就终止进程。

I have a user that is a member of the admin group. If they run an app normally, the process will have the "default" LUID. However, if they start the app with runas administrator, the process will have a different LUID. When the process is started, I want to detect this situation. If being run "normally" ok. But if being run as a different user, then terminate the process.

在这个过程中,为了获取LUID,我正在使用GetCurrentProcess,OpenProcessToken,GetTokenInformation(TokenStatistics)和AuthenticationId来自返回数据。效果很好。但现在我需要获得"正常"的LUID。启动流程
with。作为一个黑客,我使用Process32Next迭代所有进程,找到"explorer.exe"。然后获取其LUID。然后比较两个LUID。这也太棒了。但是在寻找"explorer.exe"?不太好。任何人都知道我怎么能
找到"默认" LUID?或另一种解决此问题的方法?

In the process, to get the LUID, I'm using GetCurrentProcess, OpenProcessToken, GetTokenInformation(TokenStatistics) and AuthenticationId from the returned data. Works great. But now I need to get the LUID that "normal" processes with be started with. As a hack, I iterate through all processes, using Process32Next, to find "explorer.exe" and then gets its LUID. Then compare the two LUIDs. That too works great. But looking for "explorer.exe"? Not so great. Anyone know how I can find the "default" LUID? Or another way to solve this problem?

推荐答案

您可以通过查询* ACTIVE *远程桌面会话然后调用来获取此信息WTSQueryUserToken()群组。问题是您需要使用SeTcbPrivilege来执行此操作(LocalSystem)。 

You could get this information by querying for the *ACTIVE* remote desktop session and then calling WTSQueryUserToken().  The issue is that you need to have the SeTcbPrivilege to do this (LocalSystem). 

您使用explorer.exe的技术可能是执行此操作的最佳方法,因为如果您尝试从您的用户确定此信息,您将如何知道登录用户申请。

The technique you are using with explorer.exe is probably the best way to do this since how would you know the logged on user if you are trying to determine this from your application.

谢谢

Frank K [MSFT]

Frank K [MSFT]

关注我们在推特上, www.twitter.com/WindowsSDK

Follow us on Twitter, www.twitter.com/WindowsSDK.


这篇关于如何获取会话的默认LUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆