Skip to content
Permalink
Browse files
Fixing bind issue with certain ldap servers, when user not found
Subsequent calls of NamingResult#hasMoreElements returns different values in some
environments and situations.
e.g. it occured on IBM JDK 7 with Windows Active Directory LDAP when the first value of 'hasMoreElements'
was false.
The first value is cached now.
  • Loading branch information
effrafax committed Sep 9, 2016
1 parent c02519d commit 5ce2714a373ece65661bfd769698ee755b641f5b
Showing 1 changed file with 14 additions and 7 deletions.
@@ -122,18 +122,25 @@ public AuthenticationResult authenticate( AuthenticationDataSource s )

results = context.search( mapper.getUserBaseDn(), filter, ctls );

log.debug( "Found user '{}': {}", source.getUsername(), results.hasMoreElements() );
boolean moreElements = results.hasMoreElements();

if ( results.hasMoreElements() )
log.debug( "Found user '{}': {}", source.getUsername(), moreElements );

if ( moreElements )
{
SearchResult result = results.nextElement();
try {
SearchResult result = results.nextElement();

userDn = result.getNameInNamespace();
userDn = result.getNameInNamespace();

log.debug( "Adding userDn {} for user {} to the cache..", userDn, source.getUsername() );
log.debug("Adding userDn {} for user {} to the cache..", userDn, source.getUsername());

// REDBACK-289/MRM-1488 cache the ldap user's userDn to lessen calls to ldap server
ldapCacheService.addLdapUserDn( source.getUsername(), userDn );
// REDBACK-289/MRM-1488 cache the ldap user's userDn to lessen calls to ldap server
ldapCacheService.addLdapUserDn(source.getUsername(), userDn);
} catch (Exception e) {
log.error("Error occured on LDAP result retrieval: {}, {}", userDn, e.getMessage());
return new AuthenticationResult( false, source.getUsername(), e);
}
}
else
{

0 comments on commit 5ce2714

Please sign in to comment.