How do users' Sids work?

Asked

Viewed 47 times

1

I need to implement an authentication system written in C#. NET based on users of Windows, so it will be authenticated according to some identification only of users.

The problem is that the only viable identification I have found that can represent a user is SID, but I have some small doubts about it:

  • A user’s SID logged in to the Microsoft Live account will be the same as SID if it is logged in to other machines?
  • A SID is generated randomly for a local user?
  • If the first question is no, and SID is just one local user identifier for machine, how can I get an identification whose is unique to a Microsoft Live account, and random to a local account?

This is the code used to get the user’s SID which is "logged in" to the machine:

WindowsIdentity user = WindowsIdentity.GetCurrent();
SecurityIdentifier sid = user.User;

1 answer

1


A user’s SID connected to the Microsoft Live account will be the same SID if connected to other machines?

Yes. To prove this there is even a command that allows you to fetch a windows user’s SID:

wmic useraccount where name="user" get sid

Source

I tried to run this command for a user who never logged on to my computer and returned me a SID.

A SID is generated randomly for a local user?

I have no idea.

If you have problems you can always turn to the property Name of the object WindowsIdentity

WindowsIdentity user = WindowsIdentity.GetCurrent();
user.Name

Browser other questions tagged

You are not signed in. Login or sign up in order to post.