public function import_from_filter($filter_) { $filter = LDAP::join_filters(array($this->preferences['filter'], $filter_), '&'); $configLDAP = $this->get_usergroup_ldap_config(); $ldap = new LDAP($configLDAP); $sr = $ldap->search($filter, array_values($this->preferences['match'])); if ($sr === false) { Logger::error('main', 'UserGroupDB::ldap::import_from_filter search failed'); return NULL; } $result = array(); $infos = $ldap->get_entries($sr); if (!is_array($infos)) { return $result; } foreach ($infos as $dn => $info) { $g = $this->generateUsersGroupFromRow($info, $dn, $this->preferences['match']); if (!is_object($g)) { continue; } $result[$dn] = $g; } return $result; }
public static function prefsIsValid($prefs_, &$log = array()) { $config_ldap = $prefs_->get('UserDB', 'ldap'); $LDAP2 = new LDAP($config_ldap); $ret = $LDAP2->connect($log); $LDAP2->disconnect(); if ($ret === false) { return false; } if (is_null(LDAP::join_filters(array($config_ldap['filter']), '|'))) { $log['LDAP user filter'] = false; return false; } $log['LDAP user filter'] = true; if (!array_keys_exists_not_empty(array('login', 'displayname'), $config_ldap['match'])) { $log['LDAP users match'] = false; return false; } $log['LDAP users match'] = true; return true; }