[
https://issues.apache.org/jira/browse/DIRAPI-380?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17443988#comment-17443988
]
Emmanuel Lécharny commented on DIRAPI-380:
------------------------------------------
A simple fix is to change the way we deal with DN in the
{{AbstractLdapConnection}} class:
{code:java}
/**
* {@inheritDoc}
*/
@Override
public void bind( String name ) throws LdapException
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_04145_BIND_REQUEST, name ) );
}
bind( new Dn( schemaManager, new Dn( name ) ), null );
}
/**
* {@inheritDoc}
*/
@Override
public void bind( String name, String credentials ) throws LdapException
{
bind( new Dn( schemaManager, new Dn( name ) ), credentials );
}
{code}
instead of
{code:java}
/**
* {@inheritDoc}
*/
@Override
public void bind( String name ) throws LdapException
{
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_04145_BIND_REQUEST, name ) );
}
bind( new Dn( schemaManager, name ), null );
}
/**
* {@inheritDoc}
*/
@Override
public void bind( String name, String credentials ) throws LdapException
{
bind( new Dn( schemaManager, name ), credentials );
}
{code}
fixes the bind.
Now, the problem is in the {{distinguishedName.g}} parser, which claims to
order the AVAs but does not:
{code:java}
/**
* Parses a Rdn string.
*
* RFC 4514, Section 3
* <pre>
* relativeDistinguishedName = attributeTypeAndValue
* *( PLUS attributeTypeAndValue )
* </pre>
*
* RFC 2253, Section 3
* <pre>
* name-component = attributeTypeAndValue *("+" attributeTypeAndValue)
* </pre>
*
* RFC 1779, Section 2.3
* <pre>
* <name-component> ::= <attribute>
* | <attribute> <optional-space> "+"
* <optional-space> <name-component>
* </pre>
*
* @param schemaManager The SchemaManager
* @param rdn The Rdn to update
* @throws RecognitionException If the token is invalid
* @throws TokenStreamException When we weren't able to fetch a token
*/
relativeDistinguishedName [SchemaManager schemaManager, Rdn rdn]
{
// blah
}
:
(
// more blah
)
{
rdn.hashCode();
rdn.setUpName( rdnStr.toString() );
if ( schemaManager != null )
{
// process the multi-value RDN, ordering them by attributes
<<<----- Fake news !!!
boolean isFirst = true;
for ( Ava ava : rdn )
{
if ( isFirst )
{
isFirst = false;
}
else
{
rdnNormStr.append( '+' );
}
rdnNormStr.append( ava.getAttributeType().getOid() );
rdnNormStr.append( '=' );
val = ava.getValue();
if ( ( val != null ) && ( val.getNormalized() != null ) )
{
rdnNormStr.append( val.getNormalized() );
}
}
}
rdn.setNormName( rdnNormStr.toString() );
}
;
{code}
> Binding using a DN which RDN is complex may fail
> ------------------------------------------------
>
> Key: DIRAPI-380
> URL: https://issues.apache.org/jira/browse/DIRAPI-380
> Project: Directory Client API
> Issue Type: Bug
> Affects Versions: 2.0.2, 2.1.0
> Reporter: Emmanuel Lécharny
> Priority: Major
> Fix For: 2.1.1, 2.0.3
>
>
> Trying to bind with a DN like {{cn=John
> Doe+uid=jdoe,ou=Users,dc=example,dc=com}} may fail because the DN is
> improperly handled. The added entry normalized DN order the AVAs, while the
> Bind does not.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]