Sorting elements of an LDAP array
| From: | Brian | Date: | Sat, 03 May 2003 17:05:08 +0000 |
| Subject: | Sorting elements of an LDAP array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-146290@lists.php.net to get a copy of this message | ||
Hello,
I'm writing some scripts to manage unix accounts via OpenLDAP and I've
encountered a small roadblock. I can get a listing through an ldap_list
of all users with relevant uidNumber and then use ldap_get_entries to get
info about those users. I then use a for loop to get the two relevant
fields I want ...
$params = array("uidNumber", "gidNumber");
$output = ldap_list($conn, $base_dn, "uidNumber=*", $params);
$info = ldap_get_entries($conn, $output);
for ($i=0; $i<$info["count"]; $i++)
{
$useduids = $info[$i]["uidnumber"][0]);
$usedgids = $info[$i]["gidnumber"][0];
}
My aim is to take all of the userid's and groupid's and sort them in
ascending order and then get the values of the highest number, increment
it by one, and use that as the next available uid and gid for creating new
entries in an LDAP database. I figured I could take the values in
useduids and usedgids and run them through asort() followed by end() and
then increment that value by one. So far, it hasn't worked. Can anyone
give me any pointers on how to accomplish this?
--
Brian