spring-data-ldap icon indicating copy to clipboard operation
spring-data-ldap copied to clipboard

Create ability to do string replacements on base= @Query in interfaces [DATALDAP-22]

Open spring-projects-issues opened this issue 8 years ago • 1 comments

Brett Maxfield opened DATALDAP-22 and commented

It would be nice to be able to replace parameters in base dn of a custom @Query

For example, you can do this as of 1.0.0 (using default SimpleLdapRepository) :

@Query(value="(mail={0})", searchScope=SearchScope.SUBTREE, base="o=hosting,dc=example,dc=com")
MailAccount findByMail(String mail);

The {0} is replaced with the 0'th parameter on the interface, tokens repalced by the spring QueryBuilder

But something you cannot do (so it's a theoretical example, of scope single) :

@Query(value="(mail={0})", searchScope=SearchScope.ONELEVEL, base="jvd={1},o=hosting,dc=example,dc=com")
MailAccount findByDomain(String mail, String domain);

The intent would be to expands the placeholder(s) in the base= field in the annotation, with the numbered argument, and do a search in the requested scope, using the search filter with the replaced parameters. Alternatively (perhaps in addition) using the named @Param annotation, as used by spring-data-jpa

In this case there is a LDAP structure like :

o=hosting jvd=domain1 mail=somebody@domain1 jvd=domain2 ...

The first query is valid, and it works, as it has a subtree scope, and it so happens the mail=* entries under the jvd=domain structure are also unique when queried from o=hosting scope, but it is only a happy accident. In my application i do a findAll() with an LdapQuery incl., a crafted base, this was pushed up to the business objects implementations, a bit messy.

A per-domain search in this application should search in that subtree only. The standard @DnAttribute paradigm is too inflexible for this, as the domain does not stand by itself in any ldap field, that can be mapped to a bean field (without custom logic to split the mail).

If there were (uid=x) entries, which are only valid if searched within the jvd=domain structure, then this would not be appropriate. The (jvd=x) structures are managed by separate organizations, it is a standard structure for virtual mailbox applications


Affects: 1.0 GA (Ingalls)

spring-projects-issues avatar Feb 25 '17 05:02 spring-projects-issues

Hello, Any update in this matter ?

Best Regards, Ionut C

CapatanaIonut-rsi avatar Nov 10 '22 14:11 CapatanaIonut-rsi