KEYCLOAK-4042 Better error message when failed updating MSAD password in account mgmt
This commit is contained in:
parent
287593d75f
commit
ba51640c61
4 changed files with 28 additions and 3 deletions
|
@ -488,9 +488,20 @@ public class LDAPStorageProvider implements UserStorageProvider,
|
|||
UserCredentialModel cred = (UserCredentialModel)input;
|
||||
String password = cred.getValue();
|
||||
LDAPObject ldapUser = loadAndValidateUser(realm, user);
|
||||
ldapIdentityStore.updatePassword(ldapUser, password);
|
||||
if (updater != null) updater.passwordUpdated(user, ldapUser, input);
|
||||
return true;
|
||||
|
||||
try {
|
||||
ldapIdentityStore.updatePassword(ldapUser, password);
|
||||
if (updater != null) updater.passwordUpdated(user, ldapUser, input);
|
||||
return true;
|
||||
} catch (ModelException me) {
|
||||
if (updater != null) {
|
||||
updater.passwordUpdateFailed(user, ldapUser, input, me);
|
||||
return false;
|
||||
} else {
|
||||
throw me;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.keycloak.storage.ldap.mappers;
|
||||
|
||||
import org.keycloak.credential.CredentialInput;
|
||||
import org.keycloak.models.ModelException;
|
||||
import org.keycloak.models.UserModel;
|
||||
import org.keycloak.storage.ldap.idm.model.LDAPObject;
|
||||
|
||||
|
@ -25,5 +26,8 @@ import org.keycloak.storage.ldap.idm.model.LDAPObject;
|
|||
* @version $Revision: 1 $
|
||||
*/
|
||||
public interface PasswordUpdated {
|
||||
|
||||
void passwordUpdated(UserModel user, LDAPObject ldapUser, CredentialInput input);
|
||||
|
||||
void passwordUpdateFailed(UserModel user, LDAPObject ldapUser, CredentialInput input, ModelException exception) throws ModelException;
|
||||
}
|
||||
|
|
|
@ -89,6 +89,11 @@ public class MSADUserAccountControlStorageMapper extends AbstractLDAPStorageMapp
|
|||
updateUserAccountControl(ldapUser, control);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passwordUpdateFailed(UserModel user, LDAPObject ldapUser, CredentialInput input, ModelException exception) {
|
||||
throw processFailedPasswordUpdateException(exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserModel proxy(LDAPObject ldapUser, UserModel delegate) {
|
||||
return new MSADUserModelDelegate(delegate, ldapUser);
|
||||
|
|
|
@ -88,6 +88,11 @@ public class MSADLDSUserAccountControlStorageMapper extends AbstractLDAPStorageM
|
|||
ldapProvider.getLdapIdentityStore().update(ldapUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passwordUpdateFailed(UserModel user, LDAPObject ldapUser, CredentialInput input, ModelException exception) {
|
||||
throw processFailedPasswordUpdateException(exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserModel proxy(LDAPObject ldapUser, UserModel delegate) {
|
||||
return new MSADUserModelDelegate(delegate, ldapUser);
|
||||
|
|
Loading…
Reference in a new issue