Hi!

long story short: we have added some more check that break your code...

More detailed answer:
* when you inject some filter in your request, we parse it and try as much as possible to detect which AttributeType is to be associated with each attribute. * Those AttributeTypes contain information about the type of attribute (is it Human Readable (HR) or not). * To do that, we need a SchemaManager which needs to be initialized at some point
* Then we need to inject a parsed filter into the DsmlSearchRequest.

The code then looks like that:

SearchRequestDsml searchRequest = new
    SearchRequestDsml(LdapApiServiceFactory.getSingleton());

SchemaManager schemaManager = new DefaultSchemaManager();

ExprNode filter = FilterParser.parse( schemaManager,
    "(uid=SomeArbitraryBenignString)" );

searchRequest.setFilter( filter );

and now, the filter knows that uid is HR...


Ultra complex :/


There is no silmple way to get that fixed, because it's not simple to propagate the schemaManager into all the DSML classes. Ideally speaking, we should expose some method like:

searchRequest.setFilter( schemaManager, `
    "(uid=SomeArbitraryBenignString)" );

to make the LDAP API life easier.

On 04/12/2023 21:18, Patrick Peer wrote:
Hello!

I recently upgraded the version of org.apache.directory.api:api-all from 2.1.0 to 2.1.5 in the dependencies of our product, which resulted in some test failures on my end. As it seems, values for equality filters are not set in the request anymore. For your convenience, I cobbled together a minimal test case to reproduce the condition [1]. It works with Version 2.1.0 and does not work with 2.1.5.

Upon further investigation, I think I found some issues in org.apache.directory.api.dsmlv2.request.SearchRequestDsml.toDsml(Element, ExprNode)@2.1.5: + On line 559 value.isHumanReadable() is queried to decide whether to use the value as is, or to encode it in base64. => This seems broken, since, as far as I can tell, the org.apache.directory.api.ldap.model.entry.Value.isHR flag is always false at this particular point in the code. + org.apache.directory.api.dsmlv2.ParserUtils.base64Encode(Object) only yields base64 values for byte[] and String, however here a org.apache.directory.api.ldap.model.entry.Value is passed, which will always result in an empty String.

The corresponding commit should be [2].

Do you agree that this is a bug, and should I jump through the hoops to open a Jira issue, or is there an alternative/intended way to work around this?

Cheers,
Patrick Peer



[1]
@Test
public void testMinimalEqualityRequest() throws Exception {
    SearchRequestDsml searchRequest = new SearchRequestDsml(LdapApiServiceFactory.getSingleton());
     searchRequest.setFilter("(uid=SomeArbitraryBenignString)");

     BatchRequestDsml batchRequest = new BatchRequestDsml();
     batchRequest.addRequest(searchRequest);
     String dsmlString = batchRequest.toDsml();

     assertThat(dsmlString).contains("SomeArbitraryBenignString");
}

[2] https://github.com/apache/directory-ldap-api/commit/1dd1248d33ffed80cc225e76b2769e4558bbc859 <https://github.com/apache/directory-ldap-api/commit/1dd1248d33ffed80cc225e76b2769e4558bbc859>

--
*Emmanuel Lécharny* P. +33 (0)6 08 33 32 61
[email protected]

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to