从登录ID(LUID)获取用户令牌(C ++) [英] Get UserToken from Logon ID (LUID) (C++)

查看:201
本文介绍了从登录ID(LUID)获取用户令牌(C ++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图更好地理解Windows会话的工作方式,因此,如果我在这个问题上有一些奇怪的错误,请告诉我.

I'm trying to understand better how Windows sessions work, so if I have some weird mistakes in the question, please, let me know.

我使用LsaEnumerateLogonSessions()来获取系统中所有已登录的会话. 现在,我有一个代表登录的LUID,如果我理解正确,它代表一个登录的用户或一个像SYSTEM这样的构建用户.

I use LsaEnumerateLogonSessions() to get all the logged on sessions in the system. Now I have LUID that represents a log-on, and if I understand correctly, it represents a user that logged on or a build it user like SYSTEM.

现在,如果用户X启动了一个进程,则Windows将为该进程提供代表X的令牌.

Now, if user X starts a process, Windows gives that process a token that represents X.

是否有一种方法(在Windows服务中)从LUID获取用户的令牌? 我知道我可以从HANDLE流程中获取它,但这不是我想要的.

Is there a way (in a Windows service) to get the user's token from LUID? I know I can get it from a process HANDLE, but that is not what I want.

推荐答案

您可以使用

You can use LsaGetLogonSessionData to get the session id and then use WTSQueryUserToken to get the token from that. Note that you may need to run as LocalSystem for WTSQueryUserToken (see "How can I get the current user token for the physical session?" regarding that).

这篇关于从登录ID(LUID)获取用户令牌(C ++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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