12/19/2017

Test LDAP Bind With Powershell


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{
    $_
}

MacOS Tweaking 101

Is your beloved hunk of Cupertino silicon underperforming?  Wish your Mac had a little more zip?  Then you'll love these tips on squeez...