Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. <?
  2.  
  3. $user = '<AD_User>'; // get from post
  4. $ldappass = '<AD_Password>'; // associated password
  5.  
  6. // using ldap bind
  7. $ldaprdn = $user . '@<domain>.local'; // ldap rdn or dn
  8. $ldap_server = 'ldap://<domaindc>'; //domain controller
  9.  
  10. // connect to ldap server
  11. $ldapconn = ldap_connect($ldap_server, 389)
  12. or die("Could not connect to LDAP server.");
  13.  
  14. if ($ldapconn) {
  15.  
  16. // binding to ldap server
  17. $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
  18.  
  19. // verify binding
  20. if ($ldapbind) {
  21. echo "LDAP bind successful...";
  22.  
  23.  
  24. } else {
  25. echo "LDAP bind failed...";
  26. }
  27. }
  28.  
  29. else{
  30. echo "LDAP Connection to " . $ldap_server . "failed";
  31. }
  32.  
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement