This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Lookup methods and Attributes

Jul 25th, 2006, 02:27 AM

Since I've started with LdapTemplate, I'm wondering why there's no
"lookup(String dn, String [] attributes, AttributesMapper mapper)" method.
Let's take a real case, each time I use the lookup method, all
attributes of the entry are retrieved.
In my LDAP, each entry has about 20 or 30 attributes, it's a real mess
if I only need the uid.

The thing is, we forward all method calls to corresponding methods in the DirContext interface, and there are no lookup methods there that take the Attributes to return as an argument. We could of course implement the requested functionality in LdapTemplate, but that would problably not result in any great performance improvement.

However, there are overloaded search methods in the DirContext interface that take an array containing the attributes to return. We should probably add corresponding methods in LdapOperations/LdapTemplate, especially since using those methods are the only way to have operational attributes returned. We'll probably add that in the first release of Spring-LDAP.

Comment

Of course there's no 'lookup' method in DirContext but there are two 'getAttributes' methods :

Attributes getAttributes(Name name, String[] attrIds)
Retrieves selected attributes associated with a named object.
Attributes getAttributes(String name)
Retrieves all of the attributes associated with a named object.

Maybe these could be interesting ?

Thanks for your answer.

Comment

You can call any method in DirContext using the executeReadOnly() and executeReadWrite() methods respectively. What you do is you define a ContextExecutor implementation which executes the operation of your choice and supply it to the corresponding LdapTemplate method depending on whether it's a readonly or readwrite operation.

It's possible that the requested operations will be implemented in the Spring-LDAP release, but the above should get you on your way until then.