Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. <?php
  2.  
  3. $domain = 'xxxx.com';
  4. $username = 'xxxxxx';
  5. $password = 'xxxxxx';
  6. $ldapconfig['host'] = 'xxx.xxx.xxx.xxx';
  7. $ldapconfig['port'] = 389;
  8. $ldapconfig['basedn'] = 'dc=xxxx,dc=com';
  9.  
  10. $ds=ldap_connect($ldapconfig['host'], $ldapconfig['port']);
  11. ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
  12. ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
  13.  
  14. $dn="ou=Technology,".$ldapconfig['basedn'];
  15. $bind=ldap_bind($ds, $username .'@' .$domain, $password);
  16. $isITuser = ldap_search($bind,$dn,'(&(objectClass=User)(sAMAccountName=' . $username. '))');
  17. if ($isITuser) {
  18. echo("Login correct");
  19. } else {
  20. echo("Login incorrect");
  21. }
  22.  
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement