如何使用主体
在c#中获取AD计算机帐户DNpublic string GetcomputerExtededProperty(string fieldName)
{
try
{
ComputerPrincipal oGroupPrincipal = GetComputer();
return GetProperty((DirectoryEntry)oGroupPrincipal.GetUnderlyingObject(), fieldName);
}
catch
{
return "";
}
}
答案 0 :(得分:1)
不确定这是否是您要查找的内容,但您可以使用ComputerPrincipal
类的FindByIdentity
方法和DistinguishedName
属性(在System.DirectoryServices.AccountManagement
命名空间和程序集中):
PrincipalContext oCtx = new PrincipalContext(ContextType.Domain);
ComputerPrincipal oPrincipal = ComputerPrincipal.FindByIdentity(oCtx, computerName);
string dn = oPrincipal.DistinguishedName;