Get Server Domain

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • R Chown

    #1

    Get Server Domain

    Using vbscript I can get the domain of a server by binging to the WinNT provider and then getting the ADsPath

    Set comp = GetObject("WinN T://MyComputer"
    sComputerAndDom ain = comp.ADsPat

    How do I do the same using c# and the .net framework

    Thank
    Richard Chown
  • richlm

    #2
    RE: Get Server Domain

    Following code works for me

    using System.Director yServices
    ...
    DirectoryEntry entry = new DirectoryEntry( "WinNT://Server03a")
    string domain = entry.Parent.Na me
    Console.WriteLi ne(domain)
    ...

    Note in general System.Director yServices does not provide access to all the ADSI functionality, so you may need to resort to adding a reference to the COM ADSI library (activeds.tlb) - then you will have access to the functionality you are familiar with

    Richard

    Comment

    • R Chown

      #3
      RE: Get Server Domain

      Thanks, works for me too. Exactly what I was looking for

      ----- richlm wrote: ----

      Following code works for me

      using System.Director yServices
      ..
      DirectoryEntry entry = new DirectoryEntry( "WinNT://Server03a")
      string domain = entry.Parent.Na me
      Console.WriteLi ne(domain)
      ..

      Note in general System.Director yServices does not provide access to all the ADSI functionality, so you may need to resort to adding a reference to the COM ADSI library (activeds.tlb) - then you will have access to the functionality you are familiar with

      Richard

      Comment

      Working...