This explains basic usage of the Sakai UserDirectoryService. This service is used to find out things like who the current user accessing your app is and get meta data about users.
If you have a Sakai userId (String) and want to get more information about the user you can do the following to get the Sakai User object
try {
User user = userDirectoryService.getUser(userId);
} catch (UserNotDefinedException e) {
thrownew IllegalArgumentException("Could not find user with id: " + userId);
}
If you want to find a Sakai User based on an email address you can do the following:
Collection c = userDirectoryService.findUsersByEmail(userEmail);
if (!c.isEmpty()) {
User aUser = (User) c.iterator().next();
} else {
thrownew IllegalArgumentException("Could not find user by email: " + userEmail);
}
Site running on a free Atlassian Confluence Open Source Project License granted to Sakai Foundation. Evaluate Confluence today.