73 if (isset(
$config[
'ldap_host'])) {
76 if (isset(
$config[
'ldap_port'])) {
79 if (isset(
$config[
'ldap_bind_user'])) {
82 if (isset(
$config[
'ldap_bind_pwd'])) {
85 if (isset(
$config[
'userid_attribute'])) {
88 if (isset(
$config[
'ldap_search_base_dn'])) {
91 if (isset(
$config[
'ldap_search_filter'])) {
94 if (isset(
$config[
'ldap_search_attribute'])) {
97 if (isset(
$config[
'new_attribute_name'])) {
111 $config[
'ldap_search_base_dn'],
113 $config[
'ldap_search_attribute'],
118 parent::__construct(
$config, $reserved);
121 $this->search_attributes = $this->config->getArrayize(
'attributes',
array());
122 if (empty($this->search_attributes)) {
123 $new_attribute = $this->config->getString(
'attribute.new',
'');
124 $this->search_attributes[$new_attribute] = $this->config->getString(
'search.attribute');
126 $this->search_filter = $this->config->getString(
'search.filter');
129 $this->attr_policy = $this->config->getString(
'attribute.policy',
'merge');
140 assert(
'is_array($request)');
141 assert(
'array_key_exists("Attributes", $request)');
149 $arrSearch[] =
'%'.$attr.
'%';
151 if (strlen($val[0]) > 0) {
159 $filter = str_replace($arrSearch, $arrReplace, $this->search_filter);
161 if (strpos($filter,
'%') !==
false) {
163 $this->search_filter.
')');
167 if (!in_array($this->attr_policy,
array(
'merge',
'replace',
'add'),
true)) {
169 "'replace' or 'add'.");
183 $entries =
$ldap->searchformultiple(
186 array_values($this->search_attributes),
195 foreach ($entries as $entry) {
196 foreach ($this->search_attributes as
$target =>
$name) {
205 if (isset($entry[
$name])) {
206 unset($entry[$name][
'count']);
208 foreach (array_values($entry[$name]) as $value) {
209 if ($this->attr_policy ===
'merge') {
210 if (!in_array($value,
$attributes[$target],
true)) {
__construct($config, $reserved)
Initialize this filter.
process(&$request)
Add attributes from an LDAP server.
static escape_filter_value($values=array(), $singleValue=true)
Borrowed function from PEAR:LDAP.
Create styles array
The data for the language used.
getLdap()
Getter for the LDAP connection object.