Guest User

Untitled

a guest
Nov 1st, 2016
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. <?php
  2. $username = $_POST['username'];
  3. $password = $_POST['password'];
  4.  
  5. $ldap_server_url = "";
  6. $ldap_bind_dn = "";
  7. $bind_dn_password = "";
  8. $search_base = "";
  9. $search_filter = "(&(objectClass=*)(samaccountname=?))";
  10.  
  11. $modified_search_filter = str_replace("?", $username, $search_filter);
  12.  
  13. $ldapconn = ldap_connect($ldap_server_url);
  14. ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
  15. ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
  16. $ldap_bind = @ldap_bind($ldapconn, $ldap_bind_dn, $bind_dn_password);
  17. if($ldap_bind){
  18. $user_search_result = ldap_search($ldapconn, $search_base, $modified_search_filter);
  19. $info = ldap_first_entry($ldapconn, $user_search_result);
  20. var_dump($info);
  21. } else{
  22. echo "Could not bind!!";
  23. }
  24.  
  25. ?>
Add Comment
Please, Sign In to add comment