<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:blue;
text-decoration:underline;}
p
{mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman";}
code
{font-family:"Courier New";}
span.EstiloCorreo19
{mso-style-type:personal-reply;
font-family:Arial;
color:navy;}
@page Section1
{size:595.3pt 841.9pt;
margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=ES link=blue vlink=blue>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>Hello Célio.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>Have you take a look at
the method?<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='text-indent:35.4pt'><font size=2 color=navy
face=Arial><span lang=EN-GB style='font-size:10.0pt;font-family:Arial;
color:navy'>CmsRequestContext.switchUser (CmsUser user, CmsProject project,
java.lang.String ofFqn)<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:35.4pt;text-indent:35.4pt'><font size=2
color=navy face=Arial><span lang=EN-GB style='font-size:10.0pt;font-family:
Arial;color:navy'>“Switches the user in the context, required after a
login”<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>Maybe this is what you
are looking for.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>Kind regards.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>
<hr size=2 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>De:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> karl adenener [mailto:adenener@hotmail.com]
<br>
<b><span style='font-weight:bold'>Enviado el:</span></b> martes, 15 de enero de
2008 16:22<br>
<b><span style='font-weight:bold'>Para:</span></b> The OpenCms mailing list<br>
<b><span style='font-weight:bold'>Asunto:</span></b> Re: [opencms-dev] Login as
Admin and "login back" as the previous user</span></font><o:p></o:p></p>
</div>
<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-bottom:12.0pt'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>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 <b><span style='font-weight:bold'>cmso</span></b>.loginUser
("name", password) and - do something ...<br>
<br>
- CmsObject <b><span style='font-weight:bold'>cmsoa</span></b> =
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<o:p></o:p></span></font></p>
<div class=MsoNormal align=center style='text-align:center'><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
<hr size=2 width="100%" align=center>
</span></font></div>
<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'>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.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'><o:p> </o:p></span></font></p>
<div class=MsoNormal align=center style='text-align:center'><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
<hr size=2 width="100%" align=center>
</span></font></div>
<p class=MsoNormal><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'>Kostenlos bloggen + eigene Homepage + Fotospeicher = MSN
Spaces <a href="http://clk.atdmt.com/GBL/go/mcrsddsp0020000048gbl/direct/01/"
target="_new">Hier klicken! </a><o:p></o:p></span></font></p>
</div>
</body>
</html>