Checking Domain Controllers for Secure LDAP connections with PowerShell

imageI wanted to blog this quick bit of PowerShell as I could not find it anywhere else on the web whilst searching.

I needed to check the connected domain on a machine to see if SSL was configured and enabled for LDAP, the following script checks to see if SSL is enabled on one of the domain controllers in the current domain and then tries to make a connection to see if it works.

This can of course be altered to list and check all domain controllers easy enough:

$dc = [System.DirectoryServices.ActiveDirectory.Domain]::getCurrentDomain().DomainControllers | Select -First 1
$LDAPS = [ADSI]"LDAP://$($dc.name):636"
try {
	$Connection = [adsi]($LDAPS)
} Catch {
}
If ($Connection.Path) {
	Write-Host "Active Directory server correctly configured for SSL, test connection to $($LDAPS.Path) completed."
} Else {
	Write-Host "Active Directory server not configured for SSL, test connection to LDAP://$($dc.name):636 did not work."
}

10 thoughts on “Checking Domain Controllers for Secure LDAP connections with PowerShell

  1. Rob I

    Awesome! I re-wrote this to loop through all DC’s and I kept the status output to a single line. Thanks!!!!

  2. Rob I

    Awesome! Thanks! I re-wrote this to loop through all DC’s and I kept the status output to a single line.

  3. Dayle

    Thanks a heap for posting this, nice quick & easy script. I also made a very slight modification to test all the DCs in the domain, helped a lot for telling the Linux guys that LDAPS works fine!

  4. JimP

    This is a very useful task to perform before installing VMware’s SSO, as we recently had a problem in “locating” Identity Sources. This started a case with VMware, however, we identified an LDAPS problem due to Certificate expiration on a DC which had problems communicating with the PKI. So this test would have saved us a lot of time.

  5. Pingback: Обзор блогов от 21/01/13 | vMind.ru

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.