2

i am trying a ldap search by java. I am using ldap ctx.

I found that there are two small trees i need to search from. For example:

resultsTest = lctx.search("OU=Company Beta,DC=example,DC=com", "something", SUBTREE_SCOPE);

(I am sure that "something" is correct because i tested a lot for the result)

There are team A, team B, team C, and team D inside Company Beta.

I found that if i add any one of them to the beginning of the search,

OU=team A

or

OU=team B

I can search the member in team A or team B. But i want to result search from team A and team B instead of search either one of them.

Can any one provide a helping hand? I had search from a lot of website but cannot found the solution.

Jbisgood9999999
  • 253
  • 1
  • 5
  • 15
  • 1
    Unfortunately [this answer](http://stackoverflow.com/questions/9184978/ldap-root-query-syntax-to-search-more-than-one-specific-ou) says no, you can't. Unfortunately there's no syntax that would allow you to specify a different search base like that. However, if all the users were in groups for `team A` and `team B` then you could filter with the `memberOf` attribute with a logical or condition (this is presuming active directory which has `memberOf` attributes for group memberships for user accounts) – Anya Shenanigans Nov 04 '15 at 22:24

1 Answers1

1

many LDAP Server implementations will allow an extensible match search filter as defined in RFC 2254 that may allow you to perform just that.

Define your base above the OUs you wish to include within the search and then use a filter something like:

(&(|(ou:dn:=TeamA)(ou:dn:=TeamB))(objectclass=inetorgperson)(sn=willeke))

Let us know hot it goes.

jwilleke
  • 10,467
  • 1
  • 30
  • 51