November 30, 2006

Extracting the MachineSid

using System.Security.Principal;
...
string userName = Environment.MachineName + @"\Administrator";
NTAccount account= new NTAccount(userName);
SecurityIdentifier sid = (SecurityIdentifier)
account.Translate(typeof(SecurityIdentifier)); string machineSid = sid.AccountDomainSid.ToString();

No comments: