2

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!

Mark Carpenter
  • 17,445
  • 22
  • 96
  • 149

1 Answers1

3

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'.

Igal Serban
  • 10,558
  • 3
  • 35
  • 40