Guest User

Untitled

a guest
Jan 25th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <?php
  2. $adServer = "ldap://WEB-SERVER.domain.com";// set the connection path...
  3. session_start();// Set if login is required...
  4. $ldap = ldap_connect($adServer);
  5. $ldap_id[] = $ldap;
  6. $username = 'username';//username for binding...
  7. $password = 'password';//password for bindind...
  8.  
  9. $ldaprdn = 'domain' . "\" . $username;
  10.  
  11. ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);//ldap version...
  12. ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
  13.  
  14. $bind = @ldap_bind($ldap, $ldaprdn, $password);//Binding with user...
  15.  
  16. if ($bind)
  17. {
  18. echo 'connection successful.';
  19. //Codes tobe executed...
  20. ldap_unbind($ldap); // Unbind...
  21. }
  22. else
  23. {
  24. echo 'connection unsuccessful';
  25.  
  26. ?>
Add Comment
Please, Sign In to add comment