I want to create a security identifier for AccountDomainUsersSid
. The problem is that I can't figure out how to get the sid for the current domain (i.e. the domain that the current user is logged in to).
var sid = new SecurityIdentifier(WellKnownSidType.AccountDomainUsersSid, /* what do I write here? */);
SecurityIdentifier has an AccountDomainSid property.
The User property of the WindowsIdentity is a SecurityIdentifier.
WindowsIdentity has the GetCurrent() method that reutrns the current WindowsIdentity.
So this will write out the AccountDomainSid of the Current user
WindowsIdentity id = WindowsIdentity.GetCurrent();
Console.WriteLine(id.User.AccountDomainSid);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With