我刚刚在我的应用程序中实施了Novell eDirectory。由于我们的应用程序支持Microsoft Active Directory,我想避免额外的配置参数,如“Novell是/否”。
那么,是否有其他方法可以确定计算机连接到Microsoft Active Directory还是Novell网络?
我刚刚在我的应用程序中实施了Novell eDirectory。由于我们的应用程序支持Microsoft Active Directory,我想避免额外的配置参数,如“Novell是/否”。
那么,是否有其他方法可以确定计算机连接到Microsoft Active Directory还是Novell网络?
Get-WmiObject Win32_NTDomain
ClientSiteName : Default-First-Site-Name
DcSiteName : Default-First-Site-Name
Description : DOM
DnsForestName : dom.fr
DomainControllerAddress : \\192.168.183.100
DomainControllerName : \\WM2008R2ENT
DomainName : DOM
Roles :
Status : OK
Win32_ComputerSystem
WMI 类。PS> (Get-WMIObject Win32_ComputerSystem).PartOfDomain
False
using System;
using System.Collections.Generic;
using System.Text;
using System.Management;
namespace WMIQuery
{
class WmiQuery
{
static void Main(string[] args)
{
ManagementObjectSearcher domainInfos = new ManagementObjectSearcher("select * from WIN32_NTDomain");
foreach (ManagementObject domainInfo in domainInfos.Get())
{
Console.WriteLine("Name : {0}", domainInfo.GetPropertyValue("Name"));
Console.WriteLine("Computer/domain : {0}", domainInfo.GetPropertyValue("Caption"));
Console.WriteLine("Domain name : {0}", domainInfo.GetPropertyValue("DomainName"));
Console.WriteLine("Status : {0}", domainInfo.GetPropertyValue("Status"));
}
// Edition according to @ScottTx comment you can also use `Win32_ComputerSystem` WMI class
ManagementObjectSearcher ComputerInfos = new ManagementObjectSearcher("select * from Win32_ComputerSystem");
foreach (ManagementObject ComputerInfo in ComputerInfos.Get())
{
if ((bool)ComputerInfo.GetPropertyValue("PartOfDomain"))
Console.WriteLine("This computer is part of domain");
else
Console.WriteLine("This computer is not part of domain");
}
}
}
}
System.Management
程序集的引用像“连接到Novell网络”这样的陈述比以前模糊得多。如果工作站上使用Novell(Netware)客户端的用户已登录到Netware服务器或提供类似于OES在Linux上的NCP(Netware Core Protocol)服务的服务器,则Edirectory中的网络地址属性仅应在用户当前登录到EDirectory(NDS)时存在。
有时由于错误的客户端,即使用户已登录,该属性也不存在,但通常可以使用该属性。此外,用户同时登录AD和NDS也是完全正常的。此外,根据配置或使用Novell产品,工作站本身也可以登录到NDS。