Ever wanted to test LDAP binding with Powershell? It's possible with the code below.
$LdapServer = "ldap.server.fqdn"
$Connection=New-Object System.DirectoryServices.Protocols.LDAPConnection("$($LdapServer):636")
$Options=$Connection.SessionOptions;
$Options.ProtocolVersion = 3
$Options.SecureSocketLayer = $true
$Connection.AuthType = "Basic"
$Credential = Get-Credential -Message "Enter User Account To Test LDAP Bind"
$Connection.Credential = $credential
try{
$Connection.Bind();
Write-Host "Account '$($Credential.UserName)' bind using SSL successful." -ForegroundColor Green
Write-Host "`nLDAP Options" -ForegroundColor Green
Write-Host ($Options | Format-List | Out-String).Trim() -ForegroundColor Gray
if($Options.SecureSocketLayer){
Write-Host "`nLDAP SSL Information" -ForegroundColor Green
Write-Host ($options.sslinformation | Format-List | Out-String).Trim() -ForegroundColor Gray
}
}
catch{
$_
}