<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Dear Célio.<br><br>I was searching long time for an good solution of this problem, I found only a bad workaround.<br><br>My solution<br>- normal login with <span style="font-weight: bold;">cmso</span>.loginUser ("name", password) and - do something ...<br><br>- CmsObject <span style="font-weight: bold;">cmsoa</span> = OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest());<br> and login as an admin => cmsoa.loginUser("Admin", password); <br>- get the context =>getRequestContext().setSiteRoot(OpenCms.getSiteManager().getDefaultSite().getSiteRoot());<br>- get the right project<br>=>getRequestContext().setCurrentProject(cmsoa.readProject("Offline"));<br><br>- do something with admin rights<br><br>- login (or logout) as an guest, cmsoa.loginUser("Guest", password); and do not use this cmsoa-Object anymore.<br><br>- now you have only the original rights.<br><br>I am also interested in an more "nice" solution. I hope this is, what do you was looking for.<br><br><br>greetings<br>Aden<br><br><blockquote><hr>Date: Mon, 14 Jan 2008 23:48:39 -0300<br>From: celiofariajr@gmail.com<br>To: opencms-dev@opencms.org<br>Subject: [opencms-dev] Login as Admin and "login back" as the previous user<br><br>Hi all,<br><br>I am trying to programatically create a scheduled job and write some "acceptance" files (for the users to agree with the site Terms of Use). In order to do that, I have to login as Admin, because common users 1 - do not have the permission to schedule jobs and 2- cannot create files into the "acceptance" files directory (which is located inside my module).
<br><br>The problem is, when I logout the Admin after do the writing and/or scheduling, the session is lost and the OpenCms current user is now "Guest" (or at least I think so). <br><br>I was wondering if there is an elegant way to log as Admin, do some tasks and "login back" as the previous user...
<br><br>Another solution would be giving the users permission to schedule jobs, but the role that allows this also gives them other permissions I don´t want them to have.<br><br>Someone having the same problem? Any clues on other solutions?
<br><br>TIA,<br><br>Célio.<br>
</blockquote><br /><hr />Kostenlos bloggen + eigene Homepage + Fotospeicher = MSN Spaces <a href='http://clk.atdmt.com/GBL/go/mcrsddsp0020000048gbl/direct/01/' target='_new'>Hier klicken! </a></body>
</html>