use of com.novell.security.nmas.jndi.ldap.ext.SetPwdResponse in project ldapchai by ldapchai.
the class InetOrgPersonImpl method setPassword.
public void setPassword(final String newPassword, final boolean enforcePasswordPolicy) throws ChaiUnavailableException, ChaiPasswordPolicyException {
final boolean useNmasSetting = this.getChaiProvider().getChaiConfiguration().getBooleanSetting(ChaiSetting.EDIRECTORY_ENABLE_NMAS);
if (!useNmasSetting) {
try {
writeStringAttribute(ATTR_PASSWORD, newPassword);
} catch (ChaiOperationException e) {
throw new ChaiPasswordPolicyException(e.getMessage(), ChaiErrors.getErrorForMessage(e.getMessage()));
}
} else {
final SetPwdRequest request = new SetPwdRequest();
request.setData(newPassword);
request.setObjectDN(this.getEntryDN());
final ExtendedResponse response;
try {
response = getChaiProvider().extendedOperation(request);
} catch (ChaiOperationException e) {
throw new ChaiPasswordPolicyException(e.getMessage(), ChaiErrors.getErrorForMessage(e.getMessage()));
}
if (response != null) {
final SetPwdResponse setResponse = (SetPwdResponse) response;
final int responseCode = setResponse.getNmasRetCode();
if (responseCode != 0) {
LOGGER.debug("error setting nmas password: " + responseCode);
final String errorString = "nmas error " + responseCode;
throw new ChaiPasswordPolicyException(errorString, ChaiErrors.getErrorForMessage(errorString));
}
}
}
}
Aggregations