User SPI 

You can use the IBM Connections User SPIs to access information about the users in your IBM Connections deployment.

You can use the User SPI to learn the following things about users:

You must have one of the following pieces of information about the person before you can retrieve more information:

If you attempt to retrieve information for a user who is not found in the directory, a UserNotFoundException message is displayed.

The following code sample retrieves all available information about a user based on first, the person's email address, then her user ID, and lastly, her login ID.

import java.util.List;
 
import com.ibm.connections.spi.user.User;
import com.ibm.connections.spi.user.UserHelper;
import com.ibm.connections.spi.user.UserNotFoundException;
 
 
public class UserSPIExample {
 
   public void lookupUserByEmail(String emailAddress) {
      try { 
         User user = 
        UserHelper.INSTANCE().getUserByEmailAddress(emailAddress);
         
         printUser(user);
    catch (UserNotFoundException unfe) {
         // User doesn't exist
   

   
   public void lookupUserByUserID(String userID) {
      try { 
         User user = UserHelper.INSTANCE().getUserByExtID(userID);
         
         printUser(user);
    catch (UserNotFoundException unfe) {
         // User doesn't exist
   

   
   public void lookupUserByLoginID(String loginID) {
      try { 
         User user = 
       UserHelper.INSTANCE().getUserByLoginID(loginID);
         
         printUser(user);
    catch (UserNotFoundException unfe) {
         // User doesn't exist
   

   
   private void printUser(User user) {
      System.out.println("User (Ext) ID: " + user.getExtID());
      System.out.println("User display name: " + user.getDisplayName());
      System.out.println("User Email address: " + user.getEmailAddress());
      System.out.print("Login IDs: ");
      List<String> loginIDs = user.getLoginIDs();
      for(String loginID : loginIDs) {
         System.out.print(loginID + " ");
   
      System.out.println("User status: " + user.getStatus());

}

For more information about how to use the SPI, see the IBM_Connections_3.0.1_Service_and_User_SPI">User SPI javadoc.


Parent topic

IBM Connections SPIs

+

Search Tips   |   Advanced Search