[opencms-dev] ver. 5 -- CmsUser as a session variable

Xavier Ottolini xavier.ottolini at adelis.com
Thu Apr 7 15:49:12 CEST 2005


I found the solution. It is necessary to begin the JSP with the 
following scriptlet :
<%@ page session="true" %>


Xavier Ottolini a écrit :

> Hi,
>
> I created CmsUser . I put them into a priviledged group as described 
> below
>
> http://mail.opencms.org/pipermail/opencms-dev/2003q3/006787.html
>
> But I can not log in. The users are always recognized as Guest
>
> Here is the code of my JSP
>
> if("POST".equals(request.getMethod())) {
>    CmsJspActionElement cms = new CmsJspActionElement(pageContext, 
> request, response);
>    CmsObject cmso = cms.getCmsObject();
>
>    String username = request.getParameter("username");
>    String password = request.getParameter("password");
>      try
>    {
>        boolean estMembre = false;
>        String webUser = cmso.loginUser(username,password);
>        message = "You are now logged in as " + username;
>        message += "<br>User is a member of the following groups:<br>";
>            Vector userGroups = cmso.getDirectGroupsOfUser(username);
>        CmsGroup thisGroup;
>
>        for (Enumeration allGroups = userGroups.elements(); 
> allGroups.hasMoreElements();) {
>            thisGroup = (CmsGroup)allGroups.nextElement();
>            if("Members".equals(thisGroup.getName())) estMembre = true;
>            message += "<br>" + thisGroup.getName() + ": " + 
> thisGroup.getDescription();
>        }
>
>        if(estMembre) {
>                response.sendRedirect(cms.link("fr/appels/index.html"));
>                return;
>        }
>    } catch (Exception ex) {
>        message = "Error logging in";
>    }
>
> }
>
> out.write(cms.user("group"));
> // Display "Guests"
> out.write(cms.user("name"));
> // Display Guest
>
>
> To Add the users into the database, I used the following script
>            int userType= cmso.C_USER_TYPE_SYSTEMUSER;
>            String defaultGroup = "Members";
>            if("3".equals(userFields[1])) {
>                defaultGroup = "Projectmanager";
>            }
>            username = userFields[4];
>
>            CmsUser cmsu = 
> cmso.addImportUser(username,cmso.digest(password),cmso.digest(password),"",|firstname|,|lastname|,|email|,cmso.C_FLAG_ENABLED,additionalInfos,defaultGroup,"","",userType); 
>
>
> I read messages about this topic. But the opinons are always different.
> Can some help me about this problems.
> Thanks
>



More information about the opencms-dev mailing list