Troubleshooting
Problem
Is there any way to programmatically change the user locale?
Background:
==========
Customer is trying to do change the user locale by using below code:
----------------------
final IDirectorySystem system = DirectorySystemFactory
.getDirectorySystem();
IDirectorySession session = system.createSession();
try {
IDirectoryUser directoryUser = (IDirectoryUser) session.lookupPrincipalByName(userId, IDirectoryPrincipal.TYPE_USER);
if (directoryUser == null) {
log.error(mName, "Can not find user with id: " + userId); throw new SAGSFrameworkException("Can not find user with id: " + userId + " in DirectorySystem");
}
Map<String, Object> userAttributes = directoryUser.getAllAttributes();
userAttributes.put("locale", locale);
session.modifyPrincipal(directoryUser.getID(), userAttributes);
system.destroySession(session);
session = null;
} finally {
if (session != null) { system.destroySession(session); }
}
--------------------
But this produces the following error:
--------------
com.webmethods.portal.PortalException: [POP.001.0001] Methode "setAttribute" wurde nicht implementiert.
at com.webmethods.portal.PortalException.notImplemented(PortalException.java:618)
at com.webmethods.portal.portlet.wm_xt_ldapdirsvc.service.LdapDirService.setAttribute(LdapDirService.java:260)
at com.webmethods.portal.mech.dir.impl.PrincipalAttributeMechanics.modifyPrincipal(PrincipalAttributeMechanics.java:276)
at com.webmethods.portal.bizPolicy.command.dir.ModifyPrincipal._modifyPrincipal(ModifyPrincipal.java:153)
at com.webmethods.portal.bizPolicy.command.dir.ModifyPrincipal.modifyPrincipal(ModifyPrincipal.java:124)
at com.webmethods.portal.bizPolicy.biz.dir.impl.PrincipaAttributeBizPolicy.modifyPrincipal(PrincipaAttributeBizPolicy.java:105)
at com.webmethods.sc.directory.impl.DirectorySession.modifyPrincipal(DirectorySession.java:594)
at com.tsystems.icto.tom.user.util.WmDirectoryLookup.setUserLocale(WmDirectoryLookup.java:89)
-------------
Looking at the source of LdapDirService.java I can see that the method setAttribute has intentionally not been implemented:
----------
public void setAttribute(IURI principalURI, String attrName, Object attrValue) throws PortalException {
throw PortalException.notImplemented("setAttribute");
}
---------
Customer is calling method modifyPrincipal(String principalID, Map attributes) of IDirectorySession, documented here: http://documentation.softwareag.com/webmethods/wmsuites/wmsuite8-2_sp2/My_webMethods/8-2-SP1_CAF_and_MWS_Java_API_Reference/com/webmethods/sc/directory/IDirectorySession.html
They use an LDAP connection to retrieve the userid and password. The locale is stored in MWS.
==========
Document Location
Worldwide
Log InLog in to view more of this document
Was this topic helpful?
Document Information
Modified date:
20 March 2025
UID
ibm17213074