Get PDC Emulator in Active Directory using .NET

Get PDC Emulator

Imports System.DirectoryServices

Module Module1

 Sub Main()

  Dim strDomain As String = “dc=steve,dc=schofield,dc=com”
  GetPDC(strDomain)

 End Sub

 Function GetPDC(ByVal strDomain As String) As String

  Dim Entry As DirectoryEntry
  Dim mySearcher As DirectorySearcher

  Try
 
   Entry = New DirectoryEntry(“LDAP://” & strDomain)
   mySearcher = New DirectorySearcher(Entry)
   mySearcher.Filter = “(&(objectClass=top))”
   Console.WriteLine(mySearcher.SearchRoot.Properties.Item(“fsmoroleowner”).Value)
 
  Catch f As Exception
   Console.WriteLine(f.Message)
  End Try
 End Function
End Module

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s