How to find a Global Catalog server?
With DNS Requests (NSLOOKUP)
In an Active Directory environment, all Global Catalogs are anchored in DNS . There is a separate subdomain 'GC._msdcs ....' in the namespace of the AD root domain (please remember: the global catalog does not refer to individual domains, but to the entire forest). So if your root domain in the forest is e.g. example.root, then you get a list of all GCs with this command:
C:\> nslookup gc._msdcs.example.root
The container _msdcs contains the infrastructural DNS records of the Active Directory. This is also where all the SRVservice records for the domain controllers are stored.
You can also use the standard command line tool DSQUERY for searching GCs. The search can be limited to certain domains or AD sites. However, you must be authenticated in the regarding forest and DSQUERY must be available on your machine (this is usually the case on Widows servers). As a result, the server objects in the Configuration partition is displayed:
C:\> dsquery server -isgc
C:\> dsquery server -isgc -domain "dev.example.com"
C:\> dsquery server -isgc -site "Site-Auckland"
Per Script with an LDAP filter
In the last section we have seen that the global catalog servers are present in the configuration partition of the directory as specific objects. Her we can look for them with our own script. These servers have set the first bit in their 'options' attribute. All we need is the appropriate LDAP filter:
Caution: For the actual server object exists the attribute msDS-isGC (since Windows Server 2008). But this is a constructed attribute and can not be used directly in LDAP filters for the search. Therefore there is only the detour via the attribute options for the regarding NTDSA object below the server.