res = ldap_connect($ldap_server,$ldap_port); if (! $this->res) { return -1; } if (! ldap_set_option($this->res,LDAP_OPT_PROTOCOL_VERSION,3)) syslog(LOG_WARNING,'se3-ldap : cannot fix ldap protocol version to 3'); if ($anonymous) { ldap_bind($this->res); } else { ldap_bind($this->res,$adminRdn.",".$ldap_base_dn,$adminPw); } $this->dn=array(); $this->dn['base']= $ldap_base_dn; $this->dn['people']= $peopleRdn.",".$ldap_base_dn; $this->dn['groups']= $groupsRdn.",".$ldap_base_dn; $this->dn['rights']= $rightsRdn.",".$ldap_base_dn; $this->dn['parcs']= $parcsRdn.",".$ldap_base_dn; $this->dn['computers']= $computersRdn.",".$ldap_base_dn; $this->dn['printers']= $printersRdn.",".$ldap_base_dn; $this->dn['trash']= $trashRdn.",".$ldap_base_dn; } function __destruct() { if ($this->res) { ldap_unbind($this->res); } } function get_groups($filter='') { $groups=array(); $search_dn=$this->dn['groups']; $filter="(cn=".$filter."*)"; $ldap_search_result=ldap_search($this->res,$search_dn,$filter); $info=ldap_get_entries($this->res,$ldap_search_result); $number_groups=$info['count']; for ($i=0;$i<$number_groups;$i++) { $groups[$info[$i]['cn']['0']]=$info[$i]['description']['0']; } return $groups; } function get_equipes() { return $this->get_groups('Equipe_'); } function get_matieres() { return $this->get_groups('Matiere_'); } } ?>