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


i implemented novell edirectory in application. since our application supports microsoft activedirectory prevent additional configuration parameter "novell yes/no".

so, there way find out if computer connected microsoft activedirectory or novell network?

i want know if computer part of windows domain can win32_ntdomain wmi information.

in powershell 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 @scotttx comment can use win32_computersystem wmi class

ps> (get-wmiobject win32_computersystem).partofdomain false 

according win32_ntdomain class documentation in c# can :

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 * 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 @scotttx comment can use `win32_computersystem` wmi class        managementobjectsearcher computerinfos = new managementobjectsearcher("select * win32_computersystem");       foreach (managementobject computerinfo in computerinfos.get())       {         if ((bool)computerinfo.getpropertyvalue("partofdomain"))           console.writeline("this computer part of domain");         else           console.writeline("this computer not part of domain");       }     }   } } 

adding reference system.management assembly


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -