要申请吗?Microsoft在.NET中使其变得相当简单。这应该为您提供域Netbios名称的列表,可用于创建具有域DN / DNS / Netbios名称或交叉引用字典的自定义对象的列表。
同样,确定属性在全局编录中是否可用的是另一个属性isMemberOfPartialAttributeSet。使用Microsoft SysInternals AD Explorer,可以搜索域中的Schema容器,并搜索具有isMemberOfPartialAttributeSet = true的任何对象,以查看可用于GC查询的所有属性。
using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;
private void GetNetbiosNamesTest()
{
DomainCollection domains = Forest.GetCurrentForest().Domains;
foreach (Domain domain in domains)
{
Console.WriteLine("Domain Netbios name: {0}", this.GetDomainNetBiosName(domain));
}
}
private string GetDomainNetBiosName(Domain domain)
{
ForestRootDirectoryEntry = Forest.GetCurrentForest().RootDomain.GetDirectoryEntry();
string forestConfigurationBindPath = String.Format("LDAP://CN=Partitions,CN=Configuration,{0}", ForestRootDirectoryEntry.Properties["distinguishedName"].Value);
ForestRootConfigurationDirectoryEntry = new DirectoryEntry(forestConfigurationBindPath);
string netBiosName = String.Empty;
using (DirectorySearcher directorySearcher = new DirectorySearcher(ForestRootConfigurationDirectoryEntry))
{
directorySearcher.Filter = String.Format("(&(nETBIOSName=*)(dnsRoot={0}))", domain.Name);
directorySearcher.PropertiesToLoad.AddRange(new String[] { "dnsRoot", "nETBIOSName" });
var result = directorySearcher.FindOne();
if ((result != null) && (result.Properties.Contains("nETBIOSName"))) netBiosName = result.Properties["nETBIOSName"][0].ToString();
}
return netBiosName;
}