Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ldaphost = "dc.mydomain.com"; // your ldap server
- $ldapport = 389; // your ldap server's port number
- $ldapuser = "username@mydomain.com";
- $ldappass = "somepass";
- $basedn = 'dc=mydomain,dc=com';
- $searchfor = 'seconduser';
- //Connecting to LDAP
- $ldapconn = ldap_connect($ldaphost, $ldapport) or die("Could not connect to" . $ldaphost);
- if ($ldapconn)
- {
- ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
- ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
- // binding to ldap server
- $ldapbind = ldap_bind($ldapconn,$ldapuser, $ldappass);
- $filter = '(&(samaccounttype=805306368)(samaccountname=' . $searchfor . '))';
- $result = ldap_search($ldapconn, $basedn, $filter, array('samaccountname'));
- $info = ldap_get_entries($ldapconn, $result);
- echo '<pre>';
- print_r($info);
- }
- $ldapbind = ldap_bind($ldapconn,$ldapuser, $ldappass);
- $ldapbind = ldap_bind($ldapconn);
- ldap_search(): Search: Operations error
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement