Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ldap filter to search for multiple values for an attribute

Tags:

ldap

In AD, I have multi valued attribute "departmentNumber" which may store multiple values like "dept1" and "dept2".

I am looking for ldap filter which should retrieve the users who has more than 1 departmentnumber.

I looked at other threads but that doesn't seems to work.

Any help is appreciated.

like image 858
user2961454 Avatar asked Nov 06 '13 17:11

user2961454


People also ask

What is LDAP search filter?

1. Search Filter is a basic LDAP Query for searching users based on mapping of username to a particular LDAP attribute. 2. The following are some commonly used Search Filters. You will need to use a search filter which uses the attributes specific to your LDAP environment.

What is Group filter LDAP?

LDAP filter used to search for groups according a search criteria. Searches for groups can be done using the user-search command or in the web administration console. $ SEARCH_STRING is the place holder for the search criteria. Group Member Attributes.

How do you create a query in LDAP?

To create an LDAP queryBrowse the Directory manager tree and select an object in the LDAP directory. The query that you're creating will return results from this point in the tree down. Click the New LDAP query toolbar button. Type a descriptive name for the query.


1 Answers

The server will return each of the values of a multi-valued attribute for each entry which matches the search parameters (assuming the authorization state of the connection permits). The search response will be a list of objects which match the search parameters, and with each object all be a list of attributes (name and value pairs) which is specified in the requested attributes parameter of the search request. All values of a multi-valued attribute will be included in the search result.

If the client desires dept1 and dept2, then include those as assertions in the filter, for example:

(&(departmentNumber=dept1)(departmentNumber=dept2)(objectClass=whatever..))

demonstration

Given the follow entries from which only cn and departmentNumber are shown:

$ ldapsearch --baseDN 'ou=people,c=us' --searchScope one '(&)' cn departmentNumber

dn: cn=user.1,ou=People,C=us
cn: user.1
departmentNumber: dept1
departmentNumber: dept2

dn: cn=user.2,ou=People,C=us
cn: user.2
departmentNumber: dept2

Note that the search response included both entries, and both values of departmentNumber for cn=user.1,ou=people,c=us.

like image 55
Terry Gardner Avatar answered Oct 26 '22 03:10

Terry Gardner