[opencms-dev] OpenCms 6.0.4: How to update web user password? Nothing happens in the database

Claus Priisholm cpr at codedroids.com
Tue Aug 15 13:09:36 CEST 2006


Is is unfortunately not very obvious from the API docs that your 
approach won't work, but to change password on an existing user use the 
setPassword() on CmsObject:

http://www.codedroids.com/javadocs/opencms/build_6_2_1/docs/api/org/opencms/file/CmsObject.html#setPassword(java.lang.String,%20java.lang.String,%20java.lang.String)

Michael Kraus wrote:
> 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
> 
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
> 

-- 
Claus Priisholm, CodeDroids ApS
Phone: +45 48 22 46 46
cpr (you know what) codedroids.com - http://www.codedroids.com
cpr (you know what) interlet.dk - http://www.interlet.dk
--
Javadocs and other OpenCms stuff: 
http://www.codedroids.com/community/opencms



More information about the opencms-dev mailing list