[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Problem using ldap_search_s to get attributeTypes

On Mon, Aug 12, 2002 at 02:56:16PM +0100, White, Jonathan wrote:
> For the program I am writing I need to return a list of all the attributes
> in a directory.

I don't think there is an easy way to list all the attributes actually
*present* but you can certainly get hold of all those *known* in the

> The two ldap_search_s calls I am making to get the attributeTypes are:
> 1) Get the subschemaSubentry for the root DSE - scope=base, basedn="",
> filter="objectClass=*"
> 2) Get the list of attributeTypes - scope=base, basedn=<result of search 1>,
> filter="objectclass=subschema"
> Using Ldp I get the desired results, however using OpenLDAP I always get
> return code 32 (No such Object), and my question is why, what am I doing
> wrong?

Try this:

ldapsearch -H ldap://cat.ourshack.com/ -s base -x subschemaSubentry

That will return something like:

	subschemaSubentry: cn=Subschema

(subschemaSubentry is an operational attribute so you have to request
it explicitly)

So next you do:

ldapsearch -H ldap://<your ldap server>/ -s base -x -b 'cn=Subschema' \
	objectclass=subschema attributeTypes

Another useful query is:

ldapsearch -H ldap://<your ldap server>/ -s base -x 'objectclass=*' \

And if you want *all* of the operational attributes:

ldapsearch -H ldap://cat.ourshack.com/ -s base -x subschemaSubentry

|                 From Andrew Findlay, Skills 1st Ltd                 |
| Consultant in large-scale systems, networks, and directory services |
|        Andrew.Findlay@skills-1st.co.uk       +44 1628 782565        |