Sample TEWS code for removing users from Identity Manager groups

book

Article ID: 40537

calendar_today

Updated On:

Products

CA Identity Manager CA Identity Governance CA Identity Portal CA Risk Analytics CA Secure Cloud SaaS - Arcot A-OK (WebFort) CLOUDMINDER ADVANCED AUTHENTICATION CA Secure Cloud SaaS - Advanced Authentication CA Secure Cloud SaaS - Identity Management CA Secure Cloud SaaS - Single Sign On

Issue/Introduction

Question: 

How can users be removed from an Identity Manager group via TEWS?  The Java Axis samples do not include a sample to remove users from groups.

Environment:  

Applies to all supported environments for IM.

Answer: 

See below ModifyGroupMembership.java sample code:

 

import java.math.BigInteger;

import tews6.wsdl.*;

 

public class ModifyGroupMembership {

static final Tews6Locator locator = new Tews6Locator();

 

// set this to true if you have set up a SiteMinder realm+rule to protect TEWS

static final boolean bIsProtectedBySiteMinder = false;

 

public static void main(String[] args) {

 

try {

ExecModifyGroupMembership();

}

catch (ImsException imsEx) {

SampleUtils.handleException(imsEx);

}

catch (Exception e) {

e.printStackTrace();

}

 

}

 

public static void ExecModifyGroupMembership() throws Exception {

 

Tews6PortType port=locator.getTews6Port();

String adminid = "nobody";

if (bIsProtectedBySiteMinder) {

Tews6SoapBindingStub stub = (Tews6SoapBindingStub) port;

stub.setUsername("SuperAdmin");

stub.setPassword("test");

stub.setMaintainSession(true);

stub._setProperty("Cookie","SMCHALLENGE=YES");

} else {

adminid = "uid=imadmin,ou=People,ou=Employee,ou=NeteAuto,dc=security,dc=com";

}

 

// get the port to use to send this request over

 

tews6.wsdl.ModifyGroupMembership mg = new tews6.wsdl.ModifyGroupMembership();

 

ModifyGroupMembershipSearchSubject subj[] = new ModifyGroupMembershipSearchSubject[1];

subj[0] = new ModifyGroupMembershipSearchSubject();

subj[0].setIndex(new BigInteger("0"));

subj[0].setName("Group1");

 

ModifyGroupMembershipSearch search=new ModifyGroupMembershipSearch();

search.setSubject(subj);

mg.setModifyGroupMembershipSearch(search);

 

/****************************************Members Tab********************************/

ModifyGroupMembershipMembershipTab membersTab = new ModifyGroupMembershipMembershipTab();

ModifyGroupMembershipMembershipTabGroupMembers members = new ModifyGroupMembershipMembershipTabGroupMembers();

ModifyGroupMembershipMembershipTabGroupMembersRemove[] membersToDelete= new ModifyGroupMembershipMembershipTabGroupMembersRemove[1];

membersToDelete[0]=new ModifyGroupMembershipMembershipTabGroupMembersRemove();        

membersToDelete[0].setIndex(0);

membersToDelete[0].setName("user001");

 

members.setRemove(membersToDelete);

membersTab.setGroupMembers(members);

mg.setModifyGroupMembershipMembershipTab(membersTab);

TaskContext ctx = new TaskContext();

ctx.setAdmin_id(adminid); ctx.setAdmin_password("test");

 

ImsStatus status=port.modifyGroupMembership(ctx, mg);

System.out.println(status.getInfoMessage());

 

}

 

}

Additional Information:

This sample code does not require a user search filter when removing group members. The filter isn't needed because the Modify Group Members task automatically displays all the current members (i.e. this is how it behaves in the IM UI) so you are not actually searching for a user to remove.  Users to be removed from the group are added to a vector of members to delete from the group.

 

 

 


 

Environment

Release:
Component: IDMGR