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

发布于 2024-11-06 15:10:29 字数 177 浏览 5 评论 0原文

我刚刚在我的应用程序中实现了 Novell eDirectory。由于我们的应用程序支持 Microsoft ActiveDirectory,我想阻止其他配置参数,例如“Novell yes/no”。

那么,是否有其他方法可以查明计算机是否连接到 Microsoft ActiveDirectory 或 Novell 网络?

I just implemented Novell eDirectory in my application. Since our application supports Microsoft ActiveDirectory I would like to prevent an additional configuration parameter like "Novell yes/no".

So, is there another way to find out if the computer is connected to a Microsoft ActiveDirectory or a Novell network?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

避讳 2024-11-13 15:10:29

如果您想知道计算机是否属于 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 程序集的引用

I you want to know if a computer is part of a Windows domain you can get the Win32_NTDomain WMI information.

In powerShell it gives :

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

Edition according to @ScottTx comment you can also use Win32_ComputerSystem WMI class

PS> (Get-WMIObject Win32_ComputerSystem).PartOfDomain
False

According to Win32_NTDomain class documentation in C# you can get it by :

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");
      }
    }
  }
}

Adding a reference to System.Management assembly

心不设防 2024-11-13 15:10:29

嗯,像“连接到 Novell 网络”这样的说法比以前模糊得多。如果使用 Novell (Netware) 客户端的工作站上的用户登录到 Netware 服务器或提供 NCP(Netware 核心协议)之类服务(例如 Linux 上的 OES)的服务器,则仅当用户登录时,Edirectory 中的网络地址属性才应存在当前已登录到 EDirectory (NDS)。

有时,由于客户端有问题,如果用户登录,则该属性不存在,但通常您可以使用该属性。用户登录 AD 和 AD 也是完全正常的。同时进行NDS。此外,根据配置或使用的 Novell 产品,工作站本身也可以记录到 NDS。

Well a statement like "being connected to a Novell network" is a lot vaguer then it used to be. If a user on a workstation using the Novell (Netware) client is logged into a netware server or a server offering NCP (Netware Core Protocol) like services such as OES on linux then the Network Address Attribute in Edirectory should only be present if the user is currently logged into EDirectory (NDS).

Some times due to a buggy client this attribute is not present if a user is logged in but generally that attribute is what you can use. Also it is entirely normal for user to be logged into AD & NDS at the same time. Also the workstation itself can also be logged to NDS depending on configuration or Novell products in use.

倾城°AllureLove 2024-11-13 15:10:29

你如何连接?通过 LDAP?如果是这样,请查找 sAMAccountName,它是 Active Directory 所特有的。 AD 中的每个用户和组都将具有该属性(这是强制性的)。而在 eDirectory 中,没有人会拥有它,除非他们奇怪地扩展了 eDirectory 架构来添加它。

RootDSE 中可能有一些内容可以指示哪个是您的源目录。但我不确定有什么好的例子。

How are you connecting? Via LDAP? If so, look for sAMAccountName and that is unique to Active Directory. Every user and group in AD will have that attribute (It is mandatory). Whereas in eDirectory no one will have it, unless they oddly extended the eDirectory schema to add it.

There is probably something in the RootDSE that will indicate which is your source directory. But I am not sure of a great example offhand.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文