Advertisement
Guest User

Untitled

a guest
Mar 14th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. <?php
  2. // Set the ldap server
  3. $ldapurl = "host.domain.tld";
  4. $ldapuser = "user@domain.tld";
  5. $ldappass = 'userpassword';
  6.  
  7. // Set the debug flag
  8. $debug = true;
  9.  
  10. // Set debugging
  11. if ($debug) {
  12. ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
  13. }
  14.  
  15. // connect to ldap server
  16. $ldapconn = ldap_connect($ldapurl) or die ("Couldn't connect");
  17.  
  18. // binding to ldap server
  19. echo "Trying to bind with $ldapuser - $ldappass\n";
  20. $ldapbind = @ldap_bind($ldapconn, $ldapuser, $ldappass);
  21.  
  22. if (!$ldapbind) {
  23. echo "Unable to bind to server $ldapurl\n";
  24. echo "OpenLdap error message: " . ldap_error($ldapconn) . "\n";
  25. exit;
  26. }
  27.  
  28. // Rest of code goes here
  29.  
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement