OK, you have "c=fr" as your base. This means that all LdapTemplate operations automatically prepends "c=fr" to all DNs. Looking at your first attempt:
Code:
return ldapTemplate.search("ou=OSGE", "(cn=*)", getContextMapper());
Here you use "ou=OSGE" as your search base (the node in the tree where the search should begin). Your base, "c=fr", will be prepended, giving this DN: "ou=OSGE, c=fr". According to your tree graph, there is no such node and you'll get no results.
In your next attempt, you're very close:
Code:
return ldapTemplate.search("ou=OSGE,ou=SVO,ou=DEPT,o=EDFGDF,c=fr", "(cn=*)", getContextMapper());
Here the problem is that you already have the base, "c=fr", first in your search base DN. The base will be prepended regardless, giving you this DN: "ou=OSGE,ou=SVO,ou=DEPT,o=EDFGDF,c=fr,c=fr". Same problem as before; no such node.
Your third attempt succeeds simply because your search base is at the root of the tree. You will find all entries with that cn in the whole tree.
Code:
return ldapTemplate.search("", "cn=Somebody Else", getContextMapper());
You should try this code:
Code:
return ldapTemplate.search("ou=OSGE,ou=SVO,ou=DEPT,o=EDFGDF", "(cn=*)", getContextMapper());