tags:

views:

298

answers:

2

Hi Community!

I am currently programming a tool (in ANSI C) for my company which reads from an LDAP Directory and outputs all the data in a specific format (that is: the name format of our old proprietary directory db). This is then handled by another tool which reads the output and so on ... don't ask.

Anyways, for my "ldaplist ..." command I need to print out all attributes belonging to that entry, even those which have no value set.

Unfortunately ldap_first_attribute / ldap_next_attribute does not return them, only those which have a value set, and I can't find an ldap_search_ext_s parameter or an ldap_set_option switch that would help me here. Hope one of you knows how to do that.

Thanks for your time and help in advance!

+1  A: 

I have not used ldap_search_ext_s so I don't know its options and I can't tell you a solution based on using this function. However I would like to suggest one idea.

  1. You need to retrieve a schema from an LDAP server. DN of the schema entry is in the root node. After that you have to retrieve the schema entry and its "objectClasses" attribute. It contains specifications of each class and its allowed attribute types (the schema).

  2. When you run LDAP search you normally get zero, one or more entries. Each entry has an objectClass attribute. Read its values which are names of object classes. And then find each object classs in the schema and retrieve its attribute types. If in the returned entry there is no one or a few attributes it means that either an attribute doesn't have any values or you are not allowed to read the attribute in this entry.

skwllsp
+1, Thanks for your suggesstion! Seems to be the only way to pull this off. I'm currently trying to figure out how to read out the schema files. If I managed to do it, you'll get a "Problem solved" unless someone has another suggestion which is simpler *g*
lx
According to LDAP you can read schema simply using the LDAP search operation. You just need make a search request for subschema subentry. It is described in RFC for LDAP.
skwllsp
A: 

I agree, with skwllsp. You will need to return the schema for each objectclass on each entry and display each attribute. Unfortunately this will probably be a lot more than you expected as there maybe a lot of "useless" data in that type of return.

You would well served to show the populated attributes and then a list of desired attributes that are not populated.

You might get some help by looking at: http://developer.novell.com/documentation/samplecode/cldap%5Fsample/index.htm Good luck -jim

jeemster