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

findAll() ignoring base attribute from @Entry

Open jenslofgren opened this issue 9 years ago • 10 comments

SimpleLdaprepository's findAll() wich in turn calls

ldapOperations.findAll(clazz);

Seems to ignore any base set in the @Entry class

    /**
     * {@inheritDoc}
     */
    @Override
    public <T> List<T> findAll(Class<T> clazz) {
        return findAll(LdapUtils.emptyLdapName(),
                getDefaultSearchControls(defaultSearchScope, RETURN_OBJ_FLAG, ALL_ATTRIBUTES),
                clazz);
    }

Wich results in that the base attribute in the @Entity doens't work for LdapRepositorys findAll() method.

jenslofgren avatar Aug 24 '15 12:08 jenslofgren

Also seeing this on any find methods

trorbyte avatar Nov 26 '15 12:11 trorbyte

I am also seeing this. Has this really been open for over a year? It seems like a fairly major bug in Spring LDAP that should be more clearly documented if it can't be fixed more easily.

Should ObjectDirectoryMapper override the baseFilter when calling ObjectDirectoryMapper#filterFor (e.g. should DefaultObjectDirectoryMapper#addManagedClass be handling this)? Or should we be checking for class annotations in https://github.com/spring-projects/spring-ldap/blob/master/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java#L1814?

lewisheadden avatar Aug 01 '16 13:08 lewisheadden

@lewisheadden I've fixed this at https://github.com/bhuism/spring-ldap.

bhuism avatar Aug 05 '16 09:08 bhuism

I'm also observing this behaviour. Any chance to get this fixed?

hoalex avatar Apr 09 '17 10:04 hoalex

#469

I issued a pull request to fix this issue with findAll(Class<T> clazz)

dustins avatar Oct 26 '17 21:10 dustins

#470

Ok, if the API can't be changed for the foreseeable future, here is at least a fix so that the correct search is performed.

dustins avatar Oct 28 '17 13:10 dustins

Any idea when the pull request will be accepted ?

jkeruzec avatar May 03 '18 15:05 jkeruzec

Will #470 ever get merged? If not, what would the recommended way of getting around the issue?

barchiesi avatar Jan 28 '20 13:01 barchiesi

Should ObjectDirectoryMapper override the baseFilter when calling ObjectDirectoryMapper#filterFor

@lewisheadden, I don't think so. Ultimately, DirContext#search keeps the concepts of base and filter separate and Spring LDAP should probably preserve that in its API.

Or should we be checking for class annotations in https://github.com/spring-projects/spring-ldap/blob/master/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java#L1814?

This could work, though it seems to me that this work is already done in ObjectDirectoryMapper and it would be nice to maintain the abstraction so it can be switched out.

I'm inclined to introduce something that allows LdapTemplate to derive the base from ObjectDirectoryMapper, though I still wonder the right way to do it. LDAP 2.4's baseline is JDK 8, so adding an interface method to ObjectDirectoryMapper is now an option.

jzheaux avatar Jan 19 '22 21:01 jzheaux

Any idea when the pull request will be accepted ?

mrahman-vf-ic-bd avatar Jun 12 '23 13:06 mrahman-vf-ic-bd