Posts

Showing posts with the label ldap

Use PHP to perform an LDAP Bind to Windows Active Directory for User Authentication

This example shows some basic LDAP bind lookups on a Windows 2003 active directory server. The sequence is: Connect  Bind using privileged user  search for 'dn' of supplied credentials re-bind using this dn and password of supplied credentials unbind The per-requisite is that php_ldap modules are loaded and compiled.  These are fairly standard now days.  In fedora it was just a matter of executing: # yum install php-ldap Anyway:  Here is the example.  It's farily well commented so should be a simple matter to make work in your own environment. <?php // example.php // // David Latham @ 2010 // david-latham.blogspot.com // // This code cannot be executed on the same server as AD is installed on!!! // // Active Directory has an Organizational Unit of "_Test_Users" with 3 users loaded // into it. // user1 | User One // user2 | User Two // ldapbind | ldap bind // // execute with php -q example.php // credentials to test $user='user2@example.local';...