Frans Thamura wrote:

> Hi,
>
> Would you send me the full run version of the script?
>
> Frans
> ----- Original Message -----
> From: "Skondras P." <[EMAIL PROTECTED]>
> To: "Turbine Users List" <[EMAIL PROTECTED]>
> Sent: Wednesday, December 05, 2001 5:39 AM
> Subject: Re: Getting a USER_ID from Turbine User
>
> > Gopal Ramasammy-Cook wrote:
> >
> > > Hi
> > >
> > > Why is it not possible to retrieve  a USER_ID from the Turbine User
> table? I tried the getPerm method, it returns null. I made sure I had a user
> to work with since I could retrieve a login name etc. Is there something
> special about the USER_ID?
> > >
> > > TIA,
> > > Karim
> > >
> > > --
> > > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> > Try this
> >   long userID = Long.parseLong((((BaseObject)data.getUser()).
> >                            getPrimaryKey().getValue().toString()));
> >
> >
> >

The full run script is  the following

    public void doPerform( RunData data, Context ctx )
        throws Exception
    {
        String username = data.getParameters().getString ( "username", "" );
        String password = data.getParameters().getString ( "password", "" );

        User user = null;
        try
        {
            // Authenticate the user and get the object.
            user = TurbineSecurity.getAuthenticatedUser( username.toUpperCase(),
password );
            //check whether he is allowed to enter from this ip


            // Store the user object.
            data.setUser(user);

            // Mark the user as being logged in.
            user.setHasLoggedIn(new Boolean(true));

            // Set the last_login date in the database.
            user.updateLastLogin();

            // This only happens if the user is valid; otherwise, we
            // will get a valueBound in the User object when we don't
            // want to because the username is not set yet.  Save the
            // User object into the session.
            data.save();


            // A CSR user belong to one or more group in differents realm
            // we load all this parameter in the session
            long userID = Long.parseLong((((BaseObject)data.getUser()).
                              getPrimaryKey().getValue().toString()));


        }
        catch ( TurbineSecurityException e )
        {

data.getTemplateInfo().setScreenTemplate(TurbineResources.getString("template.login"));

            data.setMessage(Localization.getString(data, "AUTH_LOGIN_ERROR"));
        }


    }


This script logsin a user using the turbine db and
stores the user in the data object in the session
from there you can get the User object and get the user id as i mentioned before

>
> >
> >
>
> ----------------------------------------------------------------------------
> ----
>
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to