我可以获取机器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,但它始终为空。
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 (加入的域)?
发布于 2020-05-30 04:32:07
计算机SID与域中计算机对象的SID不同。它们是不同的。
根据this article的说法,
为了确保唯一性,安装程序生成的SID具有一个固定子权限值(21)和三个随机生成的子权限值(输出中“S-1-5-21”后面的数字)。
如果需要域中计算机对象的SID,则必须按计算机名称搜索该对象。
https://stackoverflow.com/questions/61862105
复制相似问题