Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $domain = 'xxxx.com';
- $username = 'xxxxxx';
- $password = 'xxxxxx';
- $ldapconfig['host'] = 'xxx.xxx.xxx.xxx';
- $ldapconfig['port'] = 389;
- $ldapconfig['basedn'] = 'dc=xxxx,dc=com';
- $ds=ldap_connect($ldapconfig['host'], $ldapconfig['port']);
- ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
- ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
- $dn="ou=Technology,".$ldapconfig['basedn'];
- $bind=ldap_bind($ds, $username .'@' .$domain, $password);
- $isITuser = ldap_search($bind,$dn,'(&(objectClass=User)(sAMAccountName=' . $username. '))');
- if ($isITuser) {
- echo("Login correct");
- } else {
- echo("Login incorrect");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement