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

Xavier Ottolini xavier.ottolini at adelis.com
Thu Apr 7 14:59:02 CEST 2005


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

-- 
Xavier Ottolini
Développeur multimédia

Adelis
37, rue d'Engwiller
67350 La Walck
France
Téléphone : +33 (0) 3 88 72 29 10
Télécopie : +33 (0) 3 88 72 29 19
http://www.adelis.com





More information about the opencms-dev mailing list