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

150,154

Solution 1

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.

Solution 2

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.

Solution 3

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.

Share:
150,154
bugfixr
Author by

bugfixr

Computer programmer; indy game hobbyist.

Updated on July 29, 2020

Comments

  • bugfixr
    bugfixr almost 4 years

    I am trying develop an application (C#) to query an LDAP server. I don't know the actual server named to query - is there a way to find out using standard windows tools or something in .net?

    I've also heard rumors that having the server name (ldap://server/) is not always needed as long as I've got dc=domain,dc=com in my query string, but I've so far been able to work with it this way.

    Any tips?

    Thanks

  • icfantv
    icfantv over 12 years
    to clarify, the <<your.AD.domain>> is probably the part after the @ in your email address.
  • Admin
    Admin about 11 years
    You could also omit the domain name to retrieve all available domains: C:\> nslookup > set types=all > _ldap._tcp _ldap._tcp.<<your.AD.domain1>> SRV service location: priority = 0 weight = 100 port = 389 svr hostname = <<ldap.hostname1>>.<<your.AD.domain1>> _ldap._tcp.<<your.AD.domain2>> SRV service location: priority = 0 weight = 100 port = 389 svr hostname = <<ldap.hostname1>>.<<your.AD.domain2
  • deltree
    deltree over 9 years
    it's type=all, not types
  • zquanghoangz
    zquanghoangz over 7 years
    So how can I create LDAP connection string from the info that I got from above query. Here is mine: PORT: 389, HOSTNAME: winabc.sp2010.coc.