|
39 | 39 | use RuleRightParameter;
|
40 | 40 | use Glpi\Application\View\TemplateRenderer;
|
41 | 41 | use PluginFormcreatorAbstractField;
|
42 |
| -use Toolbox; |
43 | 42 |
|
44 | 43 | class LdapselectField extends SelectField
|
45 | 44 | {
|
@@ -187,53 +186,17 @@ public function prepareQuestionInputForSave($input) {
|
187 | 186 | }
|
188 | 187 |
|
189 | 188 | $ldap_values['ldap_attribute'] = $input['ldap_attribute'] ?? ($ldap_values['ldap_attribute'] ?? null);
|
190 |
| - $attribute = []; |
191 | 189 | if (isset($ldap_values['ldap_attribute'])) {
|
192 | 190 | $ldap_dropdown = RuleRightParameter::getById((int) $ldap_values['ldap_attribute']);
|
193 | 191 | if (!($ldap_dropdown instanceof RuleRightParameter)) {
|
194 | 192 | return [];
|
195 | 193 | }
|
196 |
| - $attribute = [$ldap_dropdown->fields['value']]; |
197 | 194 | }
|
198 | 195 |
|
199 | 196 | if (isset($input['ldap_filter'])) {
|
200 | 197 | $input['ldap_filter'] = html_entity_decode($input['ldap_filter']);
|
201 | 198 | }
|
202 | 199 | $ldap_values['ldap_filter'] = $input['ldap_filter'] ?? ($ldap_values['ldap_filter'] ?? '');
|
203 |
| - set_error_handler([self::class, 'ldapErrorHandler'], E_WARNING); |
204 |
| - |
205 |
| - try { |
206 |
| - $cookie = ''; |
207 |
| - $ds = $config_ldap->connect(); |
208 |
| - if ($ds === false) { |
209 |
| - Session::addMessageAfterRedirect(__('Connection to the directory failed.', 'formcreator'), false, ERROR); |
210 |
| - } |
211 |
| - ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); |
212 |
| - if (AuthLDAP::isLdapPageSizeAvailable($config_ldap)) { |
213 |
| - $controls = [ |
214 |
| - [ |
215 |
| - 'oid' => LDAP_CONTROL_PAGEDRESULTS, |
216 |
| - 'iscritical' => true, |
217 |
| - 'value' => [ |
218 |
| - 'size' => $config_ldap->fields['pagesize'], |
219 |
| - 'cookie' => $cookie |
220 |
| - ] |
221 |
| - ] |
222 |
| - ]; |
223 |
| - $result = ldap_search($ds, $config_ldap->fields['basedn'], $ldap_values->ldap_filter, $attribute, 0, -1, -1, LDAP_DEREF_NEVER, $controls); |
224 |
| - ldap_parse_result($ds, $result, $errcode, $matcheddn, $errmsg, $referrals, $controls); |
225 |
| - $cookie = $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'] ?? ''; |
226 |
| - } else { |
227 |
| - $result = ldap_search($ds, $config_ldap->fields['basedn'], $ldap_values->ldap_filter, $attribute); |
228 |
| - } |
229 |
| - ldap_get_entries($ds, $result); |
230 |
| - } catch (Exception $e) { |
231 |
| - restore_error_handler(); |
232 |
| - trigger_error($e->getMessage(), E_USER_WARNING); |
233 |
| - Session::addMessageAfterRedirect(__('Cannot recover LDAP informations!', 'formcreator'), false, ERROR); |
234 |
| - } |
235 |
| - |
236 |
| - restore_error_handler(); |
237 | 200 |
|
238 | 201 | $input['values'] = json_encode($ldap_values, JSON_UNESCAPED_UNICODE);
|
239 | 202 | unset($input['ldap_auth']);
|
|
0 commit comments