PHP ldap successful connection checker

Today in work we was having this little issue is the credentials we have for connecting to LDAP is right ?
So i wrote this little php script to check the connection params is right or not

Add this script to a file ex: test.php and you can run with this command
php test.php


// using ldap bind
$ldaprdn = ‘XXXXXX’; // ldap rdn or dn
$ldappass = ‘XXXXXX’; // associated password

// connect to ldap server
//Params is server IP “or domain”, and port “Default ldap port over ssl is 636”
$ldapconn = ldap_connect(“”,”xxx”)

or die(“Could not connect to LDAP server.”);

if ($ldapconn) {

// binding to ldap server
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);

// verify binding
if ($ldapbind) {
echo “LDAP bind successful…”;
} else {
echo “LDAP bind failed…”;



Feel free to use this little script


About mido18

Student how addicted to computer and internet
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s