Created
May 12, 2009 20:19
-
-
Save sarahhodne/110716 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This will print all the ClueNet usernames | |
$ldap = ldap_connect("ldap.cluenet.org", 389); | |
if (!$ldap) { | |
die("Connection failed!\r\n"); | |
} | |
echo "Connected\r\n"; | |
if (!ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3)) { | |
die("Failed to set the LDAP version to 3\r\n"); | |
} | |
echo "Set LDAP version to 3"; | |
if (!ldap_start_tls($ldap)) { | |
die("Failed to do START_TLS\r\n"); | |
} | |
echo "Started TLS\r\n"; | |
if (ldap_bind($ldap)) { | |
$result = ldap_search($ldap, "ou=people,dc=cluenet,dc=org", "(uid=*)", array("uid")); | |
$info = ldap_get_entries($ldap, $result); | |
echo "Got " . $info["count"] . " users\n"; | |
//print_r($info); | |
foreach($info as $count => $entry) { | |
echo $entry["uid"][0] . "r\n"; | |
} | |
} else { | |
die("Failed to bind\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment