Add the ability to set named base filters#10
Open
flartet wants to merge 4 commits intoXavRsl:masterfrom
Open
Conversation
Through 2 class variables : $namedBaseFilters, associative array with 'baseFilterName' => 'filter with key for custom search replacement' $currentFilterName, the name (or null), of the base filter to use If a $currentFilterName is set, the corresponding filter is used in the main ldap request Also 3 methods : addNameBasedFilters / setNameBasedFilters to set the associative array of filters useNamedFilter : to choose the base filter, it allows to switch the filter as much as needed
See comment in file. This is a more informative config option, at least to make visible the key to put in the custom base filter.
Owner
|
Hi Florent, Regards, Xavier |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.