Advertisement
Guest User

Untitled

a guest
Feb 9th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. $ldaphost = "dc.mydomain.com"; // your ldap server
  2. $ldapport = 389; // your ldap server's port number
  3. $ldapuser = "username@mydomain.com";
  4. $ldappass = "somepass";
  5. $basedn = 'dc=mydomain,dc=com';
  6.  
  7. $searchfor = 'seconduser';
  8.  
  9. //Connecting to LDAP
  10. $ldapconn = ldap_connect($ldaphost, $ldapport) or die("Could not connect to" . $ldaphost);
  11.  
  12. if ($ldapconn)
  13. {
  14.  
  15. ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
  16. ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
  17.  
  18. // binding to ldap server
  19. $ldapbind = ldap_bind($ldapconn,$ldapuser, $ldappass);
  20.  
  21. $filter = '(&(samaccounttype=805306368)(samaccountname=' . $searchfor . '))';
  22.  
  23. $result = ldap_search($ldapconn, $basedn, $filter, array('samaccountname'));
  24.  
  25. $info = ldap_get_entries($ldapconn, $result);
  26.  
  27. echo '<pre>';
  28. print_r($info);
  29.  
  30. }
  31.  
  32. $ldapbind = ldap_bind($ldapconn,$ldapuser, $ldappass);
  33.  
  34. $ldapbind = ldap_bind($ldapconn);
  35.  
  36. ldap_search(): Search: Operations error
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement