Filter duplicate results from LDAP by checking for empty fields

540 views
Skip to first unread message

Luke Whitworth

unread,
Dec 4, 2013, 10:57:59 AM12/4/13
to kurog...@googlegroups.com
Hi all,

I'm using the LDAP lookup to query our AD for people to return from the directory.  Unfortunately there are a number of test/service accounts in there, so if for example someone searches for my name they see two entries, one for my proper account and one for my test account (I'm not the worse either, some people return 9 or so results!).  The only common way I can think of filtering out these test accounts is by filtering out all those that have an empty "manager" field in LDAP, as all "proper" accounts have this field filled, while the test and a service accounts don't.

Sadly though I've hit the limit of my abilities with this (doesn't take long when it comes to PHP) and was just wondering if it's anything that any of you fine folk have achieved, and if so if you'd been kind enough to share your solution?

Cheers,

Luke
Message has been deleted

Eebs Kobeissi

unread,
Dec 4, 2013, 11:39:02 AM12/4/13
to kurog...@googlegroups.com
Hi Luke,

The LDAPPeopleRetriever allows you to specify additional LDAP filters that are applied to the search query. In sites/YOURSITE/config/people/feeds.ini you can do the following to add filters:

LDAP_FILTER[] = "(someAttribute=someValue)" # Records where the 'someAttribute' attribute is set to 'someValue'
LDAP_FILTER[] = "(|(attr1=val1)(attr2=val2))" # Records where the 'attr1' attribute is set to 'val1' OR the 'attr2' attribute is set to 'va2'.
LDAP_FILTER[] = "(requiredAttribute=*)" # Records where the 'requiredAttribute' attribute is set to any value.

The LDAP_FILTER option is an array of LDAP filters that will be AND-ed together with the search query. The value is a standard LDAP query filter. If you do "(manager=*)" this will match records that have any value set for the 'manager' attribute. You may add as many LDAP_FILTER options as you need.

-Eebs

Whitworth, Luke

unread,
Dec 5, 2013, 3:34:36 AM12/5/13
to kurog...@googlegroups.com

Brilliant!  Thanks very much for the quick answer.

 

Luke

--
You received this message because you are subscribed to the Google Groups "Kurogo-Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kurogo-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages