TokenUser 和 TokenOwner 的区别

Difference between TokenUser and TokenOwner

一个进程(-token)都有一个所有者和一个用户,可以使用 winapi 函数检索 OpenProcessToken()

这两者有什么区别,什么时候不同?

来自Access Tokens

The access token functions use the following structures to describe the parts of an access token.
[...]
TOKEN_OWNER The default owner SID for the security descriptors of new objects.
[...]
TOKEN_USER The SID of the user associated with an access token.

结构的页面有更多信息:

  • TOKEN_OWNER:

    [A] structure representing a user who will become the owner of any objects created by a process using this access token.

  • TOKEN_USER

    The TOKEN_USER structure identifies the user associated with an access token


编辑以添加 Harry Johnston

指出的说明

To clarify the second point, the user associated with the access token is the user whose logon credentials were used to generate the access token. So if you log in as user1 the access token that your programs run in will return user1's SID for TokenUser.