Listing12_Find_FSMOs (VBScript)

This code can be found in Chapter 7 of Managing Enterprise Active Directory Services

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

'# From the book "Managing Enterprise Active Directory Services"
'# ISBN: 0-672-32125-4

Dim user, passwd, server, rootDSE, forestDN, domainDN, ldapObj
Dim pdcfsmo, ridfsmo, schemafsmo, infrafsmo, dnfsmo

' Authentication Information
user   = "administrator@xyz.com"
passwd = "password"
server = "dc1"

' Need to get domain's default naming context
Set rootDSE = GetObject("LDAP://" & server & "/RootDSE")
forestDN  = rootDSE.Get("rootDomainNamingContext")
domainDN  = rootDSE.Get("defaultNamingContext")

Set ldapObj = GetObject("LDAP:")

Wscript.Echo "FSMOs known by " & server & ":"

' PDC Emulator
Set pdcfsmo = ldapObj.OpenDsObject("LDAP://" & server & "/" & domainDN, _
                                   user, passwd, 1)
Wscript.Echo "PDC Emulator: " & pdcfsmo.fsmoroleowner

' RID Master
Set ridfsmo = ldapObj.OpenDsObject("LDAP://" & server & "/" _
                                  & "cn=RID Manager$,cn=system," _
                                  & domainDN, _
                                  user, passwd, 1)
Wscript.Echo "RID Master: " & ridfsmo.fsmoroleowner

' Schema Master
Set schemafsmo = ldapObj.OpenDsObject("LDAP://" & server & "/" _
                                  & "cn=Schema,cn=Configuration," _
                                  & forestDN, _
                                  user, passwd, 1)
Wscript.Echo "Schema Master: " & schemafsmo.fsmoroleowner

' Infrastructure Master
Set infrafsmo = ldapObj.OpenDsObject("LDAP://" & server & "/" _
                                  & "cn=Infrastructure," _
                                  & domainDN, _
                                  user, passwd, 1)
Wscript.Echo "Infrastructure Master: " & infrafsmo.fsmoroleowner

' Domain Naming Master
Set dnfsmo = ldapObj.OpenDsObject("LDAP://" & server & "/" _
                                  & "cn=Partitions,cn=Configuration," _
                                  & forestDN, _
                                  user, passwd, 1)
Wscript.Echo "Domain Naming Master: " & dnfsmo.fsmoroleowner

This code has been viewed 1061 times.

New from the creators of TechTasks.com: StatSheet.com