SHARE
TWEET

Untitled

a guest Jun 26th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function aduserlookup ($UserName)
  4. {
  5.     include_once 'config.php';
  6.     $ldapconn = ldap_connect("ldap://<IP>:389") or die("Could not connect to the ldap server");
  7.  
  8.     if($ldapconn) {
  9.         $r = @ldap_bind($ldapconn, $ldapuser."@test.com", $ldappass);
  10.         $sr=ldap_search($ldapconn, "OU=Employees,OU=Users,DC=test,DC=com",
  11. "cn=" . $UserName);  
  12.         $info = ldap_get_entries($ldapconn, $sr);
  13.         ldap_close($ldapconn);
  14.         return $info;
  15.     } else {
  16.             echo "<h4>Unable to connect to LDAP server</h4>";
  17.     }
  18. }
  19.  
  20. $user = aduserlookup('test');
  21. $directreports = $user[0]['directreports'];
  22. echo '<pre>';
  23. var_dump($directreports);
  24. echo '</pre>';
  25.  
  26. foreach ($directreports as $key => $value)
  27. {
  28.         $directreports = substr($value, 0, strpos($value, ","));
  29.         $directreports = strstr($directreports, '=');
  30.         $directreports = str_replace('=', '', $directreports);
  31.         $directreports1 = aduserlookup(''' . $directreports . ''');
  32.         echo $directreports1 . "<br>";
  33. }
  34. ?>
  35.      
  36. (manager:1.2.840.113556.1.4.1941:=CN=manager,OU=users,DC=willeke,DC=com)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top