[opencms-dev] Create user programmatically

gnorrus at libero.it gnorrus at libero.it
Tue Jun 18 20:31:50 CEST 2013


Hi

which is the right way to create a user programmatically in opencms If I don't 
want to use Alkacon web registration form?

The following code work only if I'm loggd:

            CmsUser user = cms.createUser(username, password, description, 
null);
            user.setFirstname (name);
            user.setLastname(surname);
            user.setEmail(email);
            cms.writeUser(user);
            

If I execute it in Online it says that the user "Guest" doesn't have access to 
account management, so it doesn't create the user

So I suppose I have to login before creating user, maybe with an account 
created only for that purpose (like "Export" user)

is this right?
After login and after creating the user, I need to logout that user?

If I add also:
cms.loginUser("AccountManagerUser", "password");

before createUser, then, even if I do login with the new credentials, in every 
page it seem to be logged the "AccountManagerUser" user

thanks



More information about the opencms-dev mailing list