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

Binary attributes are converted to string when queried by

Open goto1134 opened this issue 3 years ago • 2 comments

I have the following Entity

@Entry(objectClasses = ["top", "person", "user"], base = "ou=users")
class LdapUser {

    @Id
    lateinit var id: Name

    @Attribute(name = "objectGUID", type = Attribute.Type.BINARY, readonly = true)
    lateinit var guid: ByteArray
}

interface LdapUserRepository : Repository<LdapUser, Name> {
    fun findByGuid(guid: ByteArray): AlternativeLdapUser
}

When I search by guid with value 90d1c68e-01be-4485-aafd-b3ffb9ddb026 converted to a 32 element byte array, the library generates the following request:

base=ou=users, finalFilter=(&(&(objectclass=top)(objectclass=person)(objectclass=user))(objectGUID=[B@7363e35b))

And the result is always empty. The correct filter would be:

base=ou=users, finalFilter=(&(&(objectclass=top)(objectclass=person)(objectclass=user))(objectGUID=\90\d1\c6\8e\01\be\44\85\aa\fd\b3\ff\b9\dd\b0\26))

Please, support binary attribute query parameters.

goto1134 avatar Apr 09 '22 22:04 goto1134

This issue may somehow be related to https://github.com/spring-projects/spring-ldap/issues/634

goto1134 avatar Apr 09 '22 22:04 goto1134

ConditionCriteria supports only String arguments. We can proceed here once Spring LDAP accepts other value types.

mp911de avatar Apr 19 '22 12:04 mp911de