我可以像下面这样获得机器Sid:
var dir = new DirectoryEntry($"WinNT://{Environment.MachineName},Computer");
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...
}
我想在调用JoinDomainOrWorkgroup
之前检查重复的机器sid。我可以从计算机SID获取计算机SID(加入域)吗?
计算机SID与域上计算机对象的SID不同。他们是不同的。