[opencms-dev] Registering users using Java code ?

SAIF ABAYAZID abayazid at uiuc.edu
Wed Nov 28 20:51:06 CET 2007


Hello Olivier we did some thing close to what you are trying to do.
We created an admin user manually in cms then we used this code sniped
  *CmsObject cmsAdminObj = 
OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest());
  cmsAdminObj.loginUser("Admin", "password"); *
We gave this Admin user the privilege's of Administrator, then we use 
this admin user to create other users on a fly when the user try to log 
in. Our script check
if the user is in our AD then check if he/she is in CMS.
To check the user's existence in CMS you need:
*CmsObject cmsObj = loginBean.getCmsObject();
cmsObj.readUser(user);*
where *user *is:
*String user = request.getParameter("user");

*About the "Map info" here is the code sniped that will help you:*

              CmsUser aduser  = **cmsObj**.readUser(user);
              String Key = "USER_DESCRIPTION";
              Map des = aduser.getAdditionalInfo();
              String adinfo = des.get(Key).toString() ;

*To create a nue user again you need *
CmsUser newuser = null;
newuser = cmsAdminObj.createUser( user, password,"Your user 
descriptions", params);
*where *params *is
*Hashtable params = new Hashtable();

Hope this will answer some of your questions.
**
*
>
> Check if the user already exists (How I can do ?)
>   
In your script you can create a user using
> If it not exists, create it (How I can do ?)
> When user is created, I want to create an xmlcontent file where I put
> some values coming from my form and giving rights only to Admin and
> concerned user ... (How can I do ?)
>
> Other questions :
> what is the content of "Map info" in the creatUser() method of CmsObject
> class ? what are keys to used with this map ?
> Can I use directly
> OpenCms.getValidationHandler().checkUserName(username) ? to check if the
> user name exists ?
>
> Sorry but I am lost when I use the OpenCms Javadoc. 
> I feel it is not enought exhaustive for me ...
>
>
>
>
>
>   
>
> _______________________________________________
> 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
>   

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20071128/f503b742/attachment.bin>


More information about the opencms-dev mailing list