[ome-devel] change user id in the API

josh.moore at gmx.de josh.moore at gmx.de
Tue Mar 3 14:52:54 GMT 2009


Hi Matthias,

There is, though at the moment it requires two omero.client objects. As
root, do:

   omero.sys.Principal p = new omero.sys.Principal();
   // user name, etc.
   ISessionPrx sessionPrx = sf.getSessionService();
   omero.model.Session session =
       sessionPrx.createSessionWithTimeouts(p, timeToLiveInMillis);

   omero.client sudo = new omero.client("localhost");
   sudo.joinSession(session.getUuid().getValue());

Cheers,
~Josh.

P.S. from API.ice:

 omero::model::Session createSessionWithTimeout(omero::sys::Principal p,
   long timeToLiveMilliseconds) throws ServerError;
 omero::model::Session createSessionWithTimeouts(omero::sys::Principal p,
   long timeToLiveMilliseconds, long timeToIdleMilliseconds) throws ServerError;



Matthias Dunda writes:
 > Hi,
 > 
 > is it possible to change to an arbitrary user after logging in as
 > an administrator (like root)?
 > 
 > Example:
 > 
 > client = new omero.client("localhost");
 > sf = client.createSession("root", "ome");
 > 
 > now change context to user id 1
 > 
 > all newly created projects, datasets, etc. belong to user 1
 > 
 > 
 > So pratically something like doing a "su - username" as root in Linux.
 > 
 > Cheers
 > Matthias


More information about the ome-devel mailing list