You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This happens because org.springframework.ldap.filter.EqualsFilter will be encoded and the backslashes will be escaped. This encoding is incorrect for the binary strings.
Please,
provide a way to pass a value to the query builder without the encoding
provide a way to pass binary values to the query builder
fix the log at LdapTemplate.java[find]:1843 to show the propper encoded finalFilter
P.S. There is a workaround to fix the encoding issue but it finalizes the query builder
@Repository
classLdapUserRepository(
privatevalldapTemplate:LdapTemplate,
) {
funfindById(guid:UUID): LdapUser {
val byteBuffer =ByteBuffer.wrap(ByteArray(16))
byteBuffer.putLong(guid.mostSignificantBits)
byteBuffer.putLong(guid.leastSignificantBits)
val bytes = byteBuffer.array()
val guidByteString = bytes.joinToString("\\", "\\") { "%02x".format(it) }
val guidFilter =HardcodedFilter("(objectGUID=$guidByteString)")
return ldapTemplate.find(
query().filter(guidFilter),
LdapUser::class.java
).firstOrNull() ?: error("Could not find user")
}
The text was updated successfully, but these errors were encountered:
Suppose the following classes:
When you search the user with guid
90d1c68e-01be-4485-aafd-b3ffb9ddb026
. The following log will be generated but nothing would be found:The query is correct, but it will not be executed. The following query will be executed instead:
base=ou=users, finalFilter=(&(&(objectclass=top)(objectclass=person)(objectclass=user))(objectGUID=\5c90\5cd1\5cc6\5c8e\5c01\5cbe\5c44\5c85\5caa\5cfd\5cb3\5cff\5cb9\5cdd\5cb0\5c26))
This happens because
org.springframework.ldap.filter.EqualsFilter
will be encoded and the backslashes will be escaped. This encoding is incorrect for the binary strings.Please,
LdapTemplate.java[find]:1843
to show the propper encodedfinalFilter
P.S. There is a workaround to fix the encoding issue but it finalizes the query builder
The text was updated successfully, but these errors were encountered: