Create a security identifier for the current domain

I want to create a security identifier for AccountDomainUsersSid . The problem is that I cannot figure out how to get the sid for the current domain (i.e. the Domain that the current user is connected to).

 var sid = new SecurityIdentifier(WellKnownSidType.AccountDomainUsersSid, /* what do I write here? */); 
+4
source share
1 answer

SecurityIdentifier has the AccountDomainSid property.

The WindowsIdentity User property is the SecurityIdentifier.

WindowsIdentity has a GetCurrent () method that updates the current Windows identity.

Thus, this will output the AccountDomainSid of the current user

  WindowsIdentity id = WindowsIdentity.GetCurrent(); Console.WriteLine(id.User.AccountDomainSid); 
+9
source

Source: https://habr.com/ru/post/1336786/


All Articles