[opencms-dev] Switch users and project programatically

Paul-Inge Flakstad flakstad at npolar.no
Wed Mar 30 22:06:17 CEST 2011


Hi list,

I need to modify some files in the VFS programatically in a JSP, so I do this:

        if (cms.getRequestContext().currentProject().isOnlineProject()) {
            cmso.loginUser("myadmin", "mypassword");
            cmso.getRequestContext().setCurrentProject(cmso.readProject("Offline"));
        }
        // Now I modify the files in the VFS

My questions:
1.) Should I set the project to "Online" again, after I'm finished modifying the files?
2.) Do I also need to login the "Guest" user, to ensure regular guest users do not get the privileges assigned to "myadmin" user? (How do I do this?)
3.) Is the order of loginUser() and setCurrentProject() correct? (First login user and then set project?)

Appreciate any help! :)

Cheers,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20110330/c87d2342/attachment.htm>


More information about the opencms-dev mailing list