Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = $_POST['username'];
- $password = $_POST['password'];
- $ldap_server_url = "";
- $ldap_bind_dn = "";
- $bind_dn_password = "";
- $search_base = "";
- $search_filter = "(&(objectClass=*)(samaccountname=?))";
- $modified_search_filter = str_replace("?", $username, $search_filter);
- $ldapconn = ldap_connect($ldap_server_url);
- ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
- ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
- $ldap_bind = @ldap_bind($ldapconn, $ldap_bind_dn, $bind_dn_password);
- if($ldap_bind){
- $user_search_result = ldap_search($ldapconn, $search_base, $modified_search_filter);
- $info = ldap_first_entry($ldapconn, $user_search_result);
- var_dump($info);
- } else{
- echo "Could not bind!!";
- }
- ?>
Add Comment
Please, Sign In to add comment