Search code examples
ldapldap-query

Reducing the amount of attributes returned


I have a filter in one of my user importers, which looks like:

(&(objectCategory=user)(memberOf=CN=somegroup,OU=some,OU=thing,DC=org,DC=company,DC=com))

The filter works like expected, but due to the fact that each user has tons of attributes I'm looking for a method on how to cut down the output a little bit. I.e. fields I need are sAMAaccountName, authorizedPassword and about 5 other fields.

Is there a way on how to cut the output down, that only those fields (or attributes?) are shown, but for all users in that group. Haven been looking around for a while but did not find any proper hint.

Many thanks in advance, regards, Thomas


Solution

  • You need to place the returned attributes for the searchRequest as an example similar to:

    ldapsearch -x -LLL -h <domain> -b "OU=thing,DC=org,DC=company,DC=com)" -s sub "(&(objectCategory=user)(memberOf=CN=somegroup,OU=some,OU=thing,DC=org,DC=company,DC=com))" samaccountName
    

    You can "Google/Bing" for ldapsearch examples or read https://www.openldap.org/software/man.cgi?query=ldapsearch

    Since you did not mention how the search was being done, kin of hard to offer more information.

    -jim