Skip Headers
Oracle® Workspaces Web Services Application Developer's Guide
10g Release 1 (10.1.2.2)

Part Number B28207-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

6 Users Service

The Users service allows you to retrieve users by email, nickname, or Oracle Internet Directory group and reading and modifying user preferences.

Example: Retrieve Users

The following sample retrieves users from a specified group that has been defined in Oracle Internet Directory. Before executing the sample, either add users to the group as specified in the sample or specify your own group in Oracle Internet Directory and populate it with users.

Example 6-1 UsersServiceSample.java

package oracle.sample.workspaces.ws;
 
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import oracle.workspaces.ws.AuthenticationService;
import oracle.workspaces.ws.UsersService;
import oracle.workspaces.ws.UsersServiceServiceLocator;
import oracle.workspaces.ws.UsersServiceSoapBindingStub;
import oracle.workspaces.ws.beans.User;
import oracle.workspaces.ws.exceptions.CwWSException;
import org.apache.axis.transport.http.HTTPConstants;
 
public class UsersServiceSample 
{
  public static UsersService configureUsersService(
    String szAuthCookie)
    throws ServiceException
  {
    UsersServiceServiceLocator ussl = new UsersServiceServiceLocator();
    UsersService uService = ussl.getUsersService();
    ((UsersServiceSoapBindingStub)uService).setMaintainSession(true);
    ((javax.xml.rpc.Stub)uService).
      _setProperty(HTTPConstants.HEADER_COOKIE,szAuthCookie);
    return uService;
  }
  
  public static User[] getUsersFromGroupDN(
    UsersService szUsersService,
    String szGroupDN) throws CwWSException, RemoteException
  {
    oracle.workspaces.ws.beans.User[] value = null;
    value = szUsersService.getMembersByGroupDN(szGroupDN, null);
    
    // Output users retrieved from Oracle Internet Directory
    
    if (value != null) {
      for(int i=0; i<value.length; i++) {
          System.out.println("User" + i + ":" + value[i].getNickname());
        }
      }
    return value;      
  }
 
  public static void main(String[] args)
  {
    try {
    
      // Get authentication cookie
      
      AuthenticationService myAuthenticationService =
        AuthenticationSample.configureAuthenticationService(
          "orcladmin",
          "welcome1");
          
      String authCookie = AuthenticationSample.getAuthenticationCookie
        (myAuthenticationService);
        
      System.out.println("Retrieved authentication cookie : " + authCookie);
      
      // Get UsersService and set authentication cookie
      UsersService myUsersService =
        UsersServiceSample.configureUsersService(authCookie);
        
      // Output users from specified DN
      
      UsersServiceSample.getUsersFromGroupDN(
        myUsersService,
        "cn=raymond_group,cn=Groups,dc=us,dc=oracle,dc=com");
      
      myAuthenticationService.logout();                     
        
    } catch (CwWSException cwwse) 
    {
      System.out.println("CwWSException caught: " + cwwse.getMessage());
    } catch (Exception e) 
    {
      System.out.println("Exception caught: " + e.toString());
    }
    
  }
 
}