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.