glacier2: retrieve the session user id of who invokes a call

area51area51 Member Wout BettensOrganization: Key Technology (Visys) - BelgiumProject: Machine session management

Hi,

We've got some servants running behind icegrid / glacier2

  • some servants run as root (1 instance each)
  • some are allocatable, they run as the authenticated user, in the icegrid xml it's set to activation="session" user="${session.id}"

A client user logs on via username/password (permission verifier) and creates the session. The default session manager is being used.

So now, at the server side, how do we get the user identity of who is invoking a remote call?
Can it be retrieved via the Current object?

Thanks in advance!

Best Answers

  • benoitbenoit Rennes, FranceBenoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Accepted Answer

    Hi,

    No, you can't retrieve this information through the Ice.Current object. I suggest that you setup a property in the server configuration with the session ID, for example:

    <property name="SessionId" value="${session.id}"/>
    

    You can then read this property in the servant implementation.

    Cheers,
    Benoit.

  • benoitbenoit Rennes, FranceBenoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Accepted Answer

    Hi,

    Ice doesn't provide this information. This is something the client will need to provide to the server. You could use request contexts to pass this information.

    Cheers,
    Benoit.

Answers

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Accepted Answer

    Hi,

    No, you can't retrieve this information through the Ice.Current object. I suggest that you setup a property in the server configuration with the session ID, for example:

    <property name="SessionId" value="${session.id}"/>
    

    You can then read this property in the servant implementation.

    Cheers,
    Benoit.

  • area51area51 Member Wout BettensOrganization: Key Technology (Visys) - BelgiumProject: Machine session management

    Oh perfect, thank you very much for this amazingly quick reply!

  • area51area51 Member Wout BettensOrganization: Key Technology (Visys) - BelgiumProject: Machine session management

    I guess this solves the problem for allocatable servants, but how would you know the user id when it makes a remote call on a 'root' service?

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff

    Hi,

    Can't you just rely on the property not being set for these servers? In other words, if the value of the {{SessionId}} property is empty, the servant assumes it's ran as root.

    Cheers,
    Benoit.

  • area51area51 Member Wout BettensOrganization: Key Technology (Visys) - BelgiumProject: Machine session management

    Hi,

    I do know which servant runs as root and which is allocated by whom, but what I'd like to know is: 'who is the user which makes a remote call to this root servant'?

    For example, servant S runs as root, then user X logs on via glacier2/permissionVerifier, the user X makes a remote method call to S... so now within S's method I'd like to know who the user was that made the call. (The answer should be user X.)

    Is this possible in any way? I've searched around, but I may have missed it.

    Thanks,
    Wout

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Accepted Answer

    Hi,

    Ice doesn't provide this information. This is something the client will need to provide to the server. You could use request contexts to pass this information.

    Cheers,
    Benoit.

  • area51area51 Member Wout BettensOrganization: Key Technology (Visys) - BelgiumProject: Machine session management

    Cool, using request contexts seems to be a nice and easy solution, thanks!

Sign In or Register to comment.