Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/LdapService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/LdapService.java,v diff -u -r1.17.6.1 -r1.17.6.2 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/LdapService.java 6 Nov 2009 06:54:37 -0000 1.17.6.1 +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/LdapService.java 23 May 2010 23:11:30 -0000 1.17.6.2 @@ -301,6 +301,7 @@ // get column name of lams_organisation to match ldapOrgAttr to String orgField = Configuration.get(ConfigurationKeys.LDAP_ORG_FIELD); + boolean isAddingUserSuccessful = true; if (ldapOrgs != null && ldapRoles != null && orgField != null) { // get list of possible matching organisations for (String ldapOrg : ldapOrgs) { @@ -321,30 +322,33 @@ org = (Organisation) orgList.get(0); } else { log.warn("More than one LAMS organisation found with the " + orgField + ": " + ldapOrg); - return false; + isAddingUserSuccessful = false; + break; } } - // if the user is a member of any other groups, remove them - if (Configuration.getAsBoolean(ConfigurationKeys.LDAP_ONLY_ONE_ORG)) { - service.removeUserFromOtherGroups(userId, org.getOrganisationId()); - break; - } - // now convert the roles to lams roles and add the user to the - // org + + // now convert the roles to lams roles and add the user to the org List roleIds = getRoleIds(ldapRoles); if (roleIds != null && !roleIds.isEmpty()) { service.setRolesForUserOrganisation(user, org.getOrganisationId(), roleIds); - return true; } else { log.warn("Couldn't map any roles from attribute: " + Configuration.get(ConfigurationKeys.LDAP_ROLES_ATTR)); + isAddingUserSuccessful = false; } + + // if the user is a member of any other groups, remove them + if (Configuration.getAsBoolean(ConfigurationKeys.LDAP_ONLY_ONE_ORG)) { + service.removeUserFromOtherGroups(userId, org.getOrganisationId()); + break; + } } else { log.warn("No LAMS organisations found with the " + orgField + ": " + ldapOrg); + isAddingUserSuccessful = false; } } } - return false; + return isAddingUserSuccessful; } // get list of LAMS role ids from list of ldap roles