How can I find out which server hosts LDAP on my windows domain? How can I find out which server hosts LDAP on my windows domain? asp.net asp.net

How can I find out which server hosts LDAP on my windows domain?


AD registers Service Location (SRV) resource records in its DNS server which you can query to get the port and the hostname of the responsible LDAP server in your domain.

Just try this on the command-line:

C:\> nslookup > set types=all> _ldap._tcp.<<your.AD.domain>>_ldap._tcp.<<your.AD.domain>>  SRV service location:      priority       = 0      weight         = 100      port           = 389      svr hostname   = <<ldap.hostname>>.<<your.AD.domain>>

(provided that your nameserver is the AD nameserver which should be the case for the AD to function properly)

Please see Active Directory SRV Records and Windows 2000 DNS white paper for more information.


If you're using AD you can use serverless binding to locate a domain controller for the default domain, then use LDAP://rootDSE to get information about the directory server, as described in the linked article.


If the machine you are on is part of the AD domain, it should have its name servers set to the AD name servers (or hopefully use a DNS server path that will eventually resolve your AD domains). Using your example of dc=domain,dc=com, if you look up domain.com in the AD name servers it will return a list of the IPs of each AD Controller. Example from my company (w/ the domain name changed, but otherwise it's a real example):

    mokey 0 /home/jj33 > nslookup example.ad    Server:         172.16.2.10    Address:        172.16.2.10#53    Non-authoritative answer:    Name:   example.ad    Address: 172.16.6.2    Name:   example.ad    Address: 172.16.141.160    Name:   example.ad    Address: 172.16.7.9    Name:   example.ad    Address: 172.19.1.14    Name:   example.ad    Address: 172.19.1.3    Name:   example.ad    Address: 172.19.1.11    Name:   example.ad    Address: 172.16.3.2

Note I'm actually making the query from a non-AD machine, but our unix name servers know to send queries for our AD domain (example.ad) over to the AD DNS servers.

I'm sure there's a super-slick windowsy way to do this, but I like using the DNS method when I need to find the LDAP servers from a non-windows server.