000013307 - AxM 6.X - Adding a new user to an administrative group using the API

Document created by RSA Customer Support Employee on Jun 14, 2016Last modified by RSA Customer Support Employee on Apr 21, 2017
Version 2Show Document
  • View in full screen mode

Article Content

Article Number000013307
Applies To

RSA Access Manager 6.1


RSA Access Manager 6.0
IssueAxM 6.X - Adding a new user to an administrative group using the API
CauseThe existing SDK includes a sample program UserExample.java which demonstrates adding a user with the administrative API.  This example code does not show how the user would be inserted into a non-default administrative group.
Resolution

The following code is a simple example of how the administrative API might be used to insert a user into a non-default administrative group.

 

 

// com.emc.rsa.mjbond.ct.ConnectionTest

package com.emc.rsa.mjbond.ct;

 

import sirrus.connect.ConnectionDescriptor;

 

import sirrus.api.client.APIServerProxy;

import sirrus.api.client.IUser;

import sirrus.api.client.IAdministrativeGroup;

 

import java.util.Date;

 

/**

 * <p>Title: Adding a user to ClearTrust</p>

 *

 * <p>

 * Description: This sample code demonstrates adding a user to CT and setting a specific

 * administrative group.  This demonstrates the exception generated when the AD system reaches

 * its limits on the size of membership of non-default administrative group.<br>

 * <br>

 * This code os not supported by RSA in anyway and is supplied 'as is' to demonstate

 * specific behaviour

 * </p>

 *

 * <p>Copyright: Copyright (c) 2011</p>

 *

 * <p>Company: RSA, The Security Division of EMC</p>

 *

 * @author Matthew J Bond

 * @version 1.1

 */

public class ConnectionTest {

  private static final String ESERVERIP = "10.32.27.98"; // $NON-NLS-1$

  private static final int ESERVERPORT = 5601;

  private static final int ESERVERTIMEOUT = 60000;

 

  private static final String ADMINUSER = "administrator"; // $NON-NLS-1$

  private static final String ADMINPW = "passwd01"; // $NON-NLS-1$

  private static final String ADMINGROUP = "Default Administrative Group"; // $NON-NLS-1$

  private static final String ADMINROLE = "Default Administrative Role"; // $NON-NLS-1$

 

  /**

   * Supply a single argument as the UserID of the user to be added.  This

   * is then used as userID/first/last values

   *

   * @param args String[]

   */

  public static void main(String[] args) {

 

    APIServerProxy myServerProxy = null;

 

    try {

      String userID = args[0];

      String firstName = args[0];

      String lastName = args[0];

      final boolean isPublic = true;

      Date startDate = new Date();

      Date endDate = new Date();

      String emailAddr = userID + "@csau-ct.ap.rsa.net"; // $NON-NLS-1$

      String password = "Joes1InitialPassword";// $NON-NLS-1$

      String adminGroupForUser="Second admin group";// $NON-NLS-1$

 

      IUser user = null;

      IAdministrativeGroup aAdministrativeGroup = null;

     

      ConnectionDescriptor eserver =

          new ConnectionDescriptor(ESERVERIP, ESERVERPORT,

                                   ConnectionDescriptor.SSL_ANON, // ssl mode

                                   ESERVERTIMEOUT); //timeout

 

      myServerProxy = new APIServerProxy(eserver);

 

      // Connect to the Entitlements Server..

      myServerProxy.connect(ADMINUSER, ADMINPW,

                            ADMINGROUP,

                            ADMINROLE);

      System.out.println("Connected"); // $NON-NLS-1$

 

 

      // Create a User Object.

      user =

          myServerProxy.createUser(userID, isPublic, startDate, endDate,

                                   firstName, lastName, emailAddr, password);

 

      // if adminGroup provided, see if it exists

 

 

      aAdministrativeGroup = (IAdministrativeGroup) myServerProxy.

          getAdminGroups()

          .getByName(adminGroupForUser); 

 

      user.setAdministrativeGroup(aAdministrativeGroup);

 

      // Save the new user in the Entitlements database.

      user.save();

      System.out.println("User " // $NON-NLS-1$

                         + user.getName() + " saved.");// $NON-NLS-1$

 

    }

    catch (Exception e) {

      e.printStackTrace();

    }

    finally {

      try {

        myServerProxy.disconnect();

      }

      catch (Exception ignore) {

        ignore.printStackTrace();

      }

    }

  }

}

 


 

 

 

 

Legacy Article IDa53900

Attachments

    Outcomes