I
I
Ingvar Von Bjork2017-03-08 19:25:30
Windows
Ingvar Von Bjork, 2017-03-08 19:25:30

How to get the SID of the current user?

How to get the SID (the same Windows security identifier) ​​of the current user?
Well, immediately the second question: how unique can this identifier be, say, in the network of a small enterprise?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ingvar Von Björk, 2017-03-08
@DeboshiR

using System.Security.Principal;
...
string sid = WindowsIdentity.GetCurrent().User.Value;

A
Axian Ltd., 2017-03-08
@AxianLTD

On the command line: wmic useraccount get name,sid
Or wmic useraccount where name='username' get sid Sids
are unique within the issuing environment. The local user sid is unique within the computer, the domain sid is unique within the domain. At the same time, both the computer and the domain have their own sids. You should not worry about their repetition, this is the concern of ms and windows ;-)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question