我刚刚在我的应用程序中实现了Novell eDirectory。因为我们的应用程序支持微软的ActiveDirectory,所以我想防止像"Novell yes/no“这样的额外配置参数。
那么,有没有其他方法可以知道电脑是连接到微软的ActiveDirectory还是Novell网络上呢?
发布于 2011-05-12 00:48:13
如果你想知道一台计算机是否是Windows域的一部分,你可以获得Win32_NTDomain WMI信息。
在powerShell中,它提供了:
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根据@ScottTx注释进行编辑您也可以使用Win32_ComputerSystem WMI类
PS> (Get-WMIObject Win32_ComputerSystem).PartOfDomain
False根据C#中的Win32_NTDomain class documentation,你可以通过以下方式获得它:
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程序集的引用
发布于 2011-05-19 04:45:30
嗯,像“连接到Novell网络”这样的说法比以前模糊了很多。如果使用Novell ( netware )客户端的工作站上的用户登录到Netware服务器或提供类似NCP (Netware核心协议)服务的服务器(例如linux上的OES ),则只有当用户当前登录到Edirectory (NDS)时,才应该存在电子目录中的网络地址属性。
有时,由于客户端有but,如果用户登录,则此属性不存在,但通常您可以使用该属性。另外,用户同时登录到AD和NDS也是完全正常的。此外,根据使用中的配置或Novell产品,也可以将工作站本身记录到NDS。
发布于 2011-05-12 00:36:01
您是如何连接的?通过LDAP?如果是,请查找sAMAccountName,它是Active Directory所特有的。AD中的每个用户和组都将具有该属性(这是必需的)。而在eDirectory中,没有人会拥有它,除非他们奇怪地扩展了eDirectory模式来添加它。
在RootDSE中可能有一些东西将指示哪个是您的源目录。但我现在还不确定有没有很好的例子。
https://stackoverflow.com/questions/5964390
复制相似问题