Ldap icon indicating copy to clipboard operation
Ldap copied to clipboard

Add the ability to set named base filters

Open flartet opened this issue 8 years ago • 1 comments

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.

flartet avatar Nov 08 '16 10:11 flartet

Hi Florent, Thank you for your work. It seems to be working. I've just tried it but I haven't got much time just now to take a closer look at it. I'll try and do that next week if it's OK with you.

Regards,

Xavier

XavRsl avatar Nov 10 '16 09:11 XavRsl