Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $user = "domain\user";
- $pass = "password";
- $dn = "OU=...";
- $time = microtime();
- $time = explode(" ", $time);
- $time = $time[1] + $time[0];
- $start = $time;
- $ldap = $_GET['host'];
- $conn = ldap_connect($ldap) or die("Couldn't connect to AD!");
- ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
- $bind = ldap_bind($conn,$user,$pass) or die("can't bind");
- $attributes = array("displayname", "l");
- $filter = "(cn=*)";
- $result = ldap_search($conn, $dn, $filter, $attributes);
- $entries = ldap_get_entries($conn, $result);
- for ($i=0; $i<$entries["count"]; $i++)
- {
- echo $entries[$i]["displayname"]
- [0]."(".$entries[$i]["l"][0].")<br />";
- }
- ldap_unbind($conn);
- ldap_close($conn);
- $time = microtime();
- $time = explode(" ", $time);
- $time = $time[1] + $time[0];
- $finish = $time;
- $totaltime = ($finish - $start);
- printf ("This page took %f seconds to load.", $totaltime);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement