Le 13/12/16 à 18:26, Greg Thomas a écrit :
> Firstly, apologies for all the recent questions. I recently started looking
> at our LDAP code, and would like to migrate away from JNDI, The Apache LDAP
> API seems like the way to go, but I'm having fun with the API.
>
> Secondly, can I say congratulations on all the good work that you've done;
> the API seems streets ahead of JNDI, and it makes it /much/ easier to use.
>
> Finally, my question. Our LDAP server is, from the client we're
> considering, read-only - so I'm only interesting in reading information out
> of it. It models what I suspect is a fairly normal hierarchy of objects.
> For simplicity, let's assume it models equipment that people are
> responsible for, which is close enough to explain my problem. So
> conceptually, we may have
>
> Alice (objectclass=person)
> |
> +--> PC (objectclass=equipment)
> +--> Monitor (objectclass=equipment)
> +--> Phone (objectclass=equipment)
>
> Bob
> |
> +--> PC (objectclass=equipment)
> +--> Monitor (objectclass=equipment)
> +--> Phone (objectclass=equipment)
>
> etc. etc.
>
> Now, I can find just the people
>
> connectionTemplate.search(baseDn.add("ou=people"), "(objectClass=*person*
> *)"*, SearchScope.ONELEVEL, PERSON_MAPPER);
>
> I can also find just the equipment
>
> connectionTemplate.search(baseDn.add("ou=people").add("ou=equipment"),
> "(objectClass=equipment*)"*, SearchScope.ONELEVEL, EQUIPMENT_MAPPER);
>
> Is there a way I could use an EntryMapper to somehow map both people and
> equipment in the one search? Something like ...
>
> connectionTemplate.search(baseDn.add("ou=people"), "(|(objectClass=*person*
> )(objectClass=equipment*))"*, SearchScope.SUBTREE,
> PEOPLE_AND_EQUIPMENT_MAPPER);
>
> Although that does pass in a sequence of Entry objects to the mapper, the
> order is "all the people" followed by "all the equipment". Unless I've
> missed something, there's no easy way to add the equipment to the person as
> part of the mapper - i.e. it has to be done as part of a two part process;
> find all the people, find all the equioment, and then assign the equipment
> back to the people.
>
> Have I missed anything here?Hi Greg, Lucas, please correct me if I'm wrong. LDAP does not do any joint, so when you need to get back 2 different informations from a LDAP server, you need to send 2 different LDAP requests. Here, it's even worse, because youc an get all the users in one single request, but you will have to iterate on all the result etries in order to grab the sub entries containing their equipement, one by one. This is clearly not efficient. Now, you should consider another path : LDAP accepts multi-value attributes, so you can imagine adding the equipements into a dedicated AttributeType in a version of person. Of course, if you need to add some more informations related to each equipement, you will have to augment your person ObjectClass up to a point it becomes quite coplicated to manage. -- Emmanuel Lecharny Symas.com directory.apache.org
