如何获取domain 的NetBiosName信息
已知一个domain的DNS名字,如我当前域是local.com,我如何得到这个域的NetBiosName(可能是local,也可能不是)。我查找到ForestTrustDomainInformation有一个属性是NetBiosName,但是好像是找到一个forest才可以。下面是我在当前域查找,希望能找到当前域的netbiosname。但是不成功,ForestTrustRelationshipInformation forestTrustRelationship = trustRelationShip as ForestTrustRelationshipInformation; 不成功。如何解决,请大家指点。private List<string> GetAllTrustDomainNetBiosNames()
{
List<string> allTrustDomainNetBiosNameList = new List<string>();
Domain domain = Domain.GetCurrentDomain();
TrustRelationshipInformationCollection allTrustRelationshipInfos = domain.GetAllTrustRelationships();
foreach (TrustRelationshipInformation trustRelationShip in allTrustRelationshipInfos)
{
ForestTrustRelationshipInformation forestTrustRelationship = trustRelationShip as ForestTrustRelationshipInformation;
if (forestTrustRelationship != null)
{
ForestTrustDomainInfoCollection forestTrustDomainInfos = forestTrustRelationship.TrustedDomainInformation;
foreach (ForestTrustDomainInformation forestTrustDomainInfo in forestTrustDomainInfos)
{
string netBiosName = forestTrustDomainInfo.NetBiosName;
allTrustDomainNetBiosNameList.Add(netBiosName);
}
}
}
return allTrustDomainNetBiosNameList;
} --------------------编程问答-------------------- nbtstat -n
补充:.NET技术 , C#