Page MenuHomePhabricator

Support use of login user credentials for search (no admin user needed)
Closed, ResolvedPublic

Description

In LDAPProvider/src/Client.php, the search() function forces the LDAP connection to re-bind to the admin user credentials even if the connection is already bound to the login user's credentials. It does this by calling establishBinding() explicitly rather than just init().

In our environment, which is Active Directory, all users can search. This means it is not necessary to specify a separate admin account for searching. This reduces complexity in those environments. This task is to change the logic in Client.php to determine which user to bind to before searching.

Before any call to ldap_* that requires a user bound to the connection, if the connection is already bound to the admin user, or bound to the login user and there are no admin user credentials, then do nothing. Otherwise get the admin user credentials, if any, and use them to bind. If there are no admin user credentials, then the connection is bound to the anonymous (null) user.

This change in logic allows the login user to be used if no admin user was specified.

Event Timeline

Submitted change 499844 with code changes to Client.php.

Change 499844 had a related patch set uploaded (by Aklapper; owner: Chiefgeek157):
[mediawiki/extensions/LDAPProvider@master] Use login user for search when admin user not given

https://gerrit.wikimedia.org/r/499844

Osnard triaged this task as Medium priority.
Osnard added a project: LDAP-Extensions.

Thanks for the contribution. I will look at it asap!

Change 506055 had a related patch set uploaded (by Robert Vogel; owner: Chiefgeek157):
[mediawiki/extensions/LDAPProvider@REL1_31] Use login user for search when admin user not given

https://gerrit.wikimedia.org/r/506055

Change 499844 merged by jenkins-bot:
[mediawiki/extensions/LDAPProvider@master] Use login user for search when admin user not given

https://gerrit.wikimedia.org/r/499844

Change 506055 merged by jenkins-bot:
[mediawiki/extensions/LDAPProvider@REL1_31] Use login user for search when admin user not given

https://gerrit.wikimedia.org/r/506055