[opencms-dev] Registering users using Java code ?
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 =
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();
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
*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
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
More information about the opencms-dev