问题
When getting the username and/or SID of the current user, what is the preferred method?
Is it using:
WindowsIdentity.GetCurrent().Owner
Or:
WindowsIdentity.GetCurrent().User
What is the difference between the two? This would be a great question for SuperUser.com, but alas, it's not live yet. Thanks!
回答1:
What you usually want is the User.
Every security object in windows has permissions and owner. The user is also a security object so it has permissions and owner. The ownership means that the owner can change the permission on the user. And the permission (in case of the user object ) means things like delete the user, change group membership and such. And all of this is not intersting in most cases. So what you need is the 'User'.
来源:https://stackoverflow.com/questions/1027693/what-is-the-difference-between-owner-and-user-windowsidentity