Add attributes from an LDAP server.
139 {
140 assert('is_array($request)');
141 assert('array_key_exists("Attributes", $request)');
142
144
145
146
147
149 $arrSearch[] = '%'.$attr.'%';
150
151 if (strlen($val[0]) > 0) {
153 } else {
154 $arrReplace[] = '';
155 }
156 }
157
158
159 $filter = str_replace($arrSearch, $arrReplace, $this->search_filter);
160
161 if (strpos($filter, '%') !== false) {
163 $this->search_filter.')');
164 return;
165 }
166
167 if (!in_array($this->attr_policy, array('merge', 'replace', 'add'), true)) {
169 "'replace' or 'add'.");
170 return;
171 }
172
173
174 try {
176 } catch (Exception $e) {
177
179 return;
180 }
181
182 try {
183 $entries =
$ldap->searchformultiple(
184 $this->base_dn,
185 $filter,
186 array_values($this->search_attributes),
187 true,
188 false
189 );
190 } catch (Exception $e) {
191 return;
192 }
193
194
195 foreach ($entries as $entry) {
196 foreach ($this->search_attributes as
$target =>
$name) {
199 }
200
203 }
205 if (isset($entry[
$name])) {
206 unset($entry[
$name][
'count']);
208 foreach (array_values($entry[
$name]) as $value) {
209 if ($this->attr_policy === 'merge') {
212 }
213 } else {
215 }
216 }
217 } else {
219 }
220 }
221 }
222 }
223 }
static escape_filter_value($values=array(), $singleValue=true)
Borrowed function from PEAR:LDAP.
getLdap()
Getter for the LDAP connection object.