开发者

How to find out if a computer is connected to novell eDirectory or Microsoft ActiveDirectory?

开发者 https://www.devze.com 2023-03-05 15:25 出处:网络
I just implemented Novell eDirectory in 开发者_如何学Pythonmy application. Since our application supports Microsoft ActiveDirectory I would like to prevent an additional configuration parameter like \

I just implemented Novell eDirectory in 开发者_如何学Pythonmy 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?


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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号