--- C:/tempp/a Fri Oct 12 17:18:34 2007 +++ C:/tempp/b Fri Oct 12 17:18:38 2007 @@ -165,7 +165,7 @@ protected int searchTimeLimit = 10000; protected int searchScope = SearchControls.SUBTREE_SCOPE; protected boolean trace; - protected boolean ContextCreated= false; + public LdapExtLoginModule() { } @@ -192,14 +192,6 @@ */ protected Group[] getRoleSets() throws LoginException { - if(!ContextCreated && useFirstPass){//ValidatePassword must be call createLdapInitContext to fill in userRoles - //This does not happen when using useFirstPass if the use was already authenticated by another module - try { - createLdapInitContext(getUsername(),getCredentials(),false); - }catch (Exception e) { - log.error("Error retrieving roles for useFirstPass",e); - } - } Group[] roleSets = {userRoles}; return roleSets; } @@ -277,16 +269,9 @@ @throws NamingException */ private boolean createLdapInitContext(String username, Object credential) - throws Exception - { - return createLdapInitContext(username,credential,true); - } - - private boolean createLdapInitContext(String username, Object credential, boolean checkCredential) throws Exception { - ContextCreated=true; - bindDN = (String) options.get(BIND_DN); + bindDN = (String) options.get(BIND_DN); bindCredential = (String) options.get(BIND_CREDENTIAL); String securityDomain = (String) options.get(SECURITY_DOMAIN_OPT); if (securityDomain != null) @@ -348,7 +333,7 @@ { ctx = constructInitialLdapContext(bindDN, bindCredential); // Validate the user by binding against the userDN - String userDN = bindDNAuthentication(ctx, username, credential, baseDN, baseFilter,checkCredential); + String userDN = bindDNAuthentication(ctx, username, credential, baseDN, baseFilter); // Query for roles matching the role filter SearchControls constraints = new SearchControls(); @@ -375,7 +360,7 @@ @throws NamingException */ protected String bindDNAuthentication(InitialLdapContext ctx, - String user, Object credential, String baseDN, String filter, boolean checkCredential) + String user, Object credential, String baseDN, String filter) throws NamingException { SearchControls constraints = new SearchControls(); @@ -405,11 +390,9 @@ results.close(); results = null; // Bind as the user dn to authenticate the user - if(checkCredential) - { - InitialLdapContext userCtx = constructInitialLdapContext(userDN, credential); - userCtx.close(); - } + InitialLdapContext userCtx = constructInitialLdapContext(userDN, credential); + userCtx.close(); + return userDN; }