Add the ability to set named base filters #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I realized multi-attribute queries were not possible and that the module itself was not completely made for it (attributeFilter as class variable) so I implemented the ability to set named base filters to apply to the LDAP requests. Changes are made in Directory.php and config.php
From the client, it's possible to set filters
Ldap::setNamedBaseFilters(['LDAP_EMPLOYEE_FILTER' => env('LDAP_EMPLOYEE_FILTER')]);
There is also the ability to add filters
Ldap::addNamedBaseFilters(['LDAP_EMPLOYEE_FILTER' => env('LDAP_EMPLOYEE_FILTER')]);
In my .env, here I set
LDAP_EMPLOYEE_FILTER=(&(eduPersonAffiliation=employee)#filters#)
It's a shame that you could not set arrays in .env but it's not a big deal.
To use the filter I set :
Ldap::useNamedFilter('LDAP_EMPLOYEE_FILTER')
returns true if ok or false if the name has not been set as a filter first.
Then a classic Ldap::find
Ldap::find('people')->where('supannAliasLogin', "*$username*")->get(['cn', 'supannAliasLogin']));
On the LDAP log side I have a request with
filter="(&(eduPersonAffiliation=employee)(|(supannAliasLogin=*florent*)))"
which is great for what I need.
I would be glad if you could have a look into it and integrate it or tell me what's wrong.
Thanks,
Florent.