Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 924
bugfixr Avatar asked Apr 14 '09 20:04

bugfixr


People also ask

How can I tell which server is the domain controller?

If you just desire to identify which domain controller the user retrieved group policies from you can type gpresult /r. The returned results will provide you the name of the domain controller that provided the logged on user with GPOs.


2 Answers

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.

like image 69
Stefan Gehrig Avatar answered Sep 19 '22 12:09

Stefan Gehrig


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.

like image 33
Joe Avatar answered Sep 17 '22 12:09

Joe