[Building Sakai] Retrieving current user from session
Sergio Muriel
sergioame at hotmail.com
Tue Jul 22 16:00:39 PDT 2014
Dear Sam,I'm having a org.sakaiproject.user.api.User object, but when I fetch it into, like this:
User currentUser = userDirectoryService.getCurrentUser(); System.out.println("*** User.getFirstName(): " + currentUser.getFirstName()); System.out.println("*** User.getDisplayId(): " + currentUser.getDisplayId()); System.out.println("*** User.getDisplayName(): " + currentUser.getDisplayName()); System.out.println("*** User.getEid(): " + currentUser.getEid()); System.out.println("*** User.getEmail(): " + currentUser.getEmail()); System.out.println("*** User.getFirstName(): " + currentUser.getFirstName()); System.out.println("*** User.getId(): " + currentUser.getId()); System.out.println("*** User.getLastName(): " + currentUser.getLastName()); System.out.println("*** User.getSortName(): " + currentUser.getSortName()); System.out.println("*** User.getType(): " + currentUser.getType()); System.out.println("*** User.getUrl(): " + currentUser.getUrl());
I get:
*** User.getFirstName(): *** User.getDisplayId(): null*** User.getDisplayName(): null*** User.getEid(): null*** User.getEmail(): *** User.getFirstName(): *** User.getId(): *** User.getLastName(): *** User.getSortName(): null*** User.getType(): null*** User.getUrl(): http://localhost:8080/access/user
And this is actually the information that I have in the database:
USER_ID;EMAIL;EMAIL_LC;FIRST_NAME;LAST_NAME;TYPE;PW;CREATEDBY;MODIFIEDBY;CREATEDON;MODIFIEDON849c5404-47ea-418e-bb6e-3a7ca8d760b6;sergioame at hotmail dot com;sergioame at hotmail dot com;Sergio;Muriel;Web Services Accessor;cceylQ==:hNIh42AwPO6m39+Ucnp+BvJgBhEm/jt1hf9OWUiOBoU=;admin;admin;2014-05-06 16:42:38;2014-05-06 16:42:38
And this is actually what Sakai shows me:My Account DetailsUserUser Idsergioame at hotmail dot comFirst NameSergioLast NameMurielEmailsergioame at hotmail dot comTypeWeb Services AccessorCreated BySakai AdministratorCreatedMay 6, 2014 4:42 pmModified BySakai AdministratorModifiedMay 6, 2014 4:42 pm
Do you have any clue about what could be going on with that object? I'm testing it using the same browser but different tabs: One for logging into Sakai, and the other for calls the web service. Am I doing it right?
I appreciate any help.
Best Regards,
Sergio Muriel
From: ottenhoff at longsight.com
Date: Tue, 22 Jul 2014 16:51:16 -0400
Subject: Re: [Building Sakai] Retrieving current user from session
To: sergioame at hotmail.com
CC: sakai-dev at collab.sakaiproject.org
/** * Get a user's email address based on their session id * * @param sessionid the session id of the user who's email address you wish to retrieve
* @return the email address for the user * @throws AxisFault * */public String getUserEmailForSession( String sessionid ) throws AxisFault{
Session session = establishSession(sessionid); User user = userDirectoryService.getCurrentUser(); return user.getEmail();}
On Tue, Jul 22, 2014 at 4:44 PM, Sergio Muriel <sergioame at hotmail.com> wrote:
Dear All,Does anyone have a good working example of a web service in which the current user is retrieved from the current session?Please note that what I need to retrieve is an object of the class:
org.sakaiproject.user.api.User
Best Regards,
Sergio Muriel
_______________________________________________
sakai-dev mailing list
sakai-dev at collab.sakaiproject.org
http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20140722/bf8867ef/attachment.html
More information about the sakai-dev
mailing list