Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function aduserlookup ($UserName)
- {
- include_once 'config.php';
- $ldapconn = ldap_connect("ldap://<IP>:389") or die("Could not connect to the ldap server");
- if($ldapconn) {
- $r = @ldap_bind($ldapconn, $ldapuser."@test.com", $ldappass);
- $sr=ldap_search($ldapconn, "OU=Employees,OU=Users,DC=test,DC=com",
- "cn=" . $UserName);
- $info = ldap_get_entries($ldapconn, $sr);
- ldap_close($ldapconn);
- return $info;
- } else {
- echo "<h4>Unable to connect to LDAP server</h4>";
- }
- }
- $user = aduserlookup('test');
- $directreports = $user[0]['directreports'];
- echo '<pre>';
- var_dump($directreports);
- echo '</pre>';
- foreach ($directreports as $key => $value)
- {
- $directreports = substr($value, 0, strpos($value, ","));
- $directreports = strstr($directreports, '=');
- $directreports = str_replace('=', '', $directreports);
- $directreports1 = aduserlookup(''' . $directreports . ''');
- echo $directreports1 . "<br>";
- }
- ?>
- (manager:1.2.840.113556.1.4.1941:=CN=manager,OU=users,DC=willeke,DC=com)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement