LDAP Authentication in PHP made simple
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<?php require_once('Auth.php'); // Authenticating with Active Directory $auth = new Auth("LDAP", array( 'host' => 'ldap://hostname.domain.com', 'version' => 3, 'binddn' => 'CN=Morpheus,DC=domain', 'bindpw' => 'fishburne', 'basedn' => 'OU=Users,DC=domain', 'userattr' => 'samaccountname', 'userfilter' => '(objectClass=person)', 'start_tls' => 'true' )); $auth->start(); if ($auth->getAuth()) { // validated users print "Welcome to the desert of the real"; } else { // not yet authenticated print "Don't think you are, know you are."; } $auth->logout(); ?> |