Skip to content

Add support for parametrized @Query #453

Closed
@chess-levin

Description

@chess-levin

I'm trying to build a filter using @Query in my LdapRepository class that uses a parameter and the parameter most likely contains '*'.

The queries are successful when using a parameter cn without wildcard '*'. I'm expecting one entry and I' getting one result. Log output:

finalFilter=(&(&(objectclass=top)(objectclass=group))(cn=us_dbl_ci_user_grp))

When trying to add '*' to query-parameter cn the result is always empty. Log output:

finalFilter=(&(&(objectclass=top)(objectclass=group))(cn=us_ci_\2a))

@Repository
public interface GroupRepository extends LdapRepository<LdapGroup> {

    @Query( base = "OU=jenkins,OU=gruppen,OU=MYORG", searchScope = SearchScope.SUBTREE, value = "(cn={0})")
    List<LdapGroup> suchDistinguishedNameJenkins(String cn);

    @Query( base = "OU=itsqs,OU=gruppen,OU=MYORG", searchScope = SearchScope.SUBTREE, value = "(cn={0})")
    List<LdapGroup> suchDistinguishedNameItsqs(String cn);
}
@Entry(base="OU=gruppen,OU=MYORG", objectClasses = {"top", "group"})
final public class LdapGroup {

    @JsonIgnore
    @Id
    private Name id;

    @Attribute(name = "distinguishedName")
    private String distinguishedName;

    @Attribute(name = "cn")
    private String cn;

    @Attribute(name = "name")
    private String name;

    @Attribute(name="member")
    private List<String> members;

    public LdapGroup() {}
}

Is this behavior intended, is it a bug or am I doing something wrong?

Just in case I'm trying to explain what I try to achieve with my code:

My main goal is to narrow down the ldap base for this to different queries.

I set the ldap base in my entry class to the upper 'folder' in the ldap hierarchy.

@Entry(base="OU=gruppen,OU=MYORG", objectClasses = {"top", "group"})

Because this path contains >1000 subfolders and because I know exactly which subfolder I want to query, I narrow it down when I define the @Query (btw: it would be great to use params like {1} for base as well)

@Query( base = "OU=jenkins,OU=gruppen,OU=MYORG", searchScope = SearchScope.SUBTREE, value = "(cn={0})")

@Query( base = "OU=itsqs,OU=gruppen,OU=MYORG", searchScope = SearchScope.SUBTREE, value = "(cn={0})")

If I'm on the wrong path, please give me some advise, how to do this query the correct way. THX

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions