[opencms-dev] OpenCms 6.0.4: How to update web user password? Nothing happens in the database
Michael Kraus
michael.kraus at mindmatics.de
Mon Aug 14 11:17:40 CEST 2006
Dear all,
my apologies for "hammering" this mailing list with my problems, but for me, OpenCms is not quite working as expected or described in the Java API documentation.
I have the following code to add/update a web user:
String username = (String) request.getParameter("username");
String randomString = Long.toString(System.currentTimeMillis(), 36);
String newPassword = randomString.substring(randomString.length() >= 6 ? randomString.length() - 6 : 0).toUpperCase();
try {
CmsUser cmsUser = cmsObject.addWebUser(username, newPassword, OpenCms.getDefaultUsers().getGroupGuests(), "dummy", new HashMap());
cmsObject.writeWebUser(cmsUser);
} catch (CmsException exception) {
try {
CmsUser cmsUser = cmsObject.readWebUser(username);
if (cmsUser != null) {
cmsUser.setPassword(newPassword);
*** cmsObject.writeWebUser(cmsUser);
}
} catch (CmsException innerException) {
// failed
}
}
When calling this for the first time, a new web user is created and can be seen in the CMS_USERS database table. When calling it the second time, nothing changes in the database, although the line marked with *** is being called. No exception is thrown.
How can I update web user information correctly?
Kind regards,
Michael
More information about the opencms-dev
mailing list