blob: f2360e33aed073a38e15fc393e987c0e5b8f3346 [file] [log] [blame]
<?php
class Ldap {
#*****************************************************************************
#
# ldap.class.php
#
# Author: Denis Roy
# Date: 2005-12-12
#
# Description: functions for querying LDAP
#
# HISTORY:
#
#****************************************************************************
var $ldaphost = "main";
var $list = array();
function getUserGroupList($_uid_dn) {
/* @return: Array of Strings
*
* Using the DN passed as a param, query LDAP to get User groups (DN)
*
* 2005-12-06: droy
* - initial code
*/
if($_uid_dn != "") {
$ds = ldap_connect($this->ldaphost);
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
if ($ds) {
$r = @ldap_bind($ds); # anonymous bind
if($r) {
$sr = ldap_search($ds, "ou=group,dc=eclipse,dc=org", "(cn=*)");
$groupList = ldap_get_entries($ds, $sr);
for( $i = 0; $i < $groupList["count"]; $i++ ) {
for($j=0; $j<$groupList[$i]["member"]["count"]; $j++) {
$data2 = $groupList[$i]["member"][$j];
if($data2 == $_uid_dn) {
$this->list[count($this->list)] = $groupList[$i]["dn"];
}
}
}
}
}
ldap_close($ds);
}
return $this->list;
}
}
?>