I am totally new to LDAP, and have just started. I have seen a couple of examples, which to my understanding have used the query as I have done, but in my case it seems to be not working.
I have a hierarchy like this (I am using Apache Directory Studio):
If I double click on the object with ou=scientists
then its info will pop up as followed:
So this group with ou=scientists
has a cn=Scientists
(I have checked and there are no following spaces after Scientists.
I want to simply find stuff inside the group with ou=scientists
.
There is 1 way to do it like this:
ou=scientists,dc=example,dc=com
which gives the expected result.
But I want to be able to find the content inside the group with ou=scientists
not by its ou
value, but by its cn
value. So I thought to myself, ok I can use this: cn=Scientists,dc=example,dc=com
But this yields 0 results. I think I am missing a key point here. What should I actually do?
There are multiple things to consider when you query a LDAP directory.
In your case you want to lookup from a branch (call search base dn in LDAP) and apply a filter in all the childrens of this branch to select those you want :
ldapsearch ... -b <search base dn> -s sub "<FILTER>"
So for your DIT :
ldapsearch ... -b dc=example,dc=com -s sub "(&(objectClass=groupOfUniqueNames)(cn=scientists))"
Consider learning how the search request works in LDAP if you want to work more deeply with ldap : https://ldapwiki.com/wiki/SearchRequest