我可以像下面这样获得机器Sid:
var objSid = dir.Children.Cast<DirectoryEntry>().First().InvokeGet("objectSID");
var secId = new SecurityIdentifier((byte[])objSid, 0);
var machineSid = secId.AccountDomainSid.ToString();
我尝试从计算机Sid中找到计算机Sid。但是始终为NULL。
using (PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, "AbcDomain", "userName", "password"))
{
var pc01 = ComputerPrincipal.FindByIdentity(principalContext, IdentityType.Sid, machineSid);
//output: pc01 = null
var pc02 = ComputerPrincipal.FindByIdentity(principalContext, IdentityType.Name, "PC-JACKML5291");
//output: pc02...
}
I want to check duplicate machine sid before call "JoinDomainOrWorkgroup".
Can I get the Computer SID (joined domain) from machine SID ?