如何确定计算机是否连接到 Novell eDirectory 或 Microsoft ActiveDirectory?

4

我刚刚在我的应用程序中实施了Novell eDirectory。由于我们的应用程序支持Microsoft Active Directory,我想避免额外的配置参数,如“Novell是/否”。

那么,是否有其他方法可以确定计算机连接到Microsoft Active Directory还是Novell网络?

3个回答

2
如果你想知道计算机是否属于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类文档,您可以通过以下方式获得它:
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 程序集的引用

1
Win32_ComputerSystem.PartOfDomain 返回 true / false。两者都可以。 - ScottTx

1

像“连接到Novell网络”这样的陈述比以前模糊得多。如果工作站上使用Novell(Netware)客户端的用户已登录到Netware服务器或提供类似于OES在Linux上的NCP(Netware Core Protocol)服务的服务器,则Edirectory中的网络地址属性仅应在用户当前登录到EDirectory(NDS)时存在。

有时由于错误的客户端,即使用户已登录,该属性也不存在,但通常可以使用该属性。此外,用户同时登录AD和NDS也是完全正常的。此外,根据配置或使用Novell产品,工作站本身也可以登录到NDS。


0
你是如何连接的?通过LDAP吗?如果是这样,查找sAMAccountName,它在Active Directory中是唯一的。AD中的每个用户和组都将具有该属性(它是强制性的)。而在eDirectory中,除非他们奇怪地扩展了eDirectory模式以添加它,否则没有人会拥有它。
可能在RootDSE中有一些指示哪个是您的源目录的内容。但我不确定有一个很好的例子。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接