Symantec IGA

Expand all | Collapse all

Sample Java Code - ModifyGroupMembership

Jump to Best Answer
  • 1.  Sample Java Code - ModifyGroupMembership

    Posted 01-28-2018 09:11 PM

    Hi, I am new to IDM and tasked to do a customized Java code for the management of ad users to groups.  As I look into the sample files to pattern with, I came across ModifyGroupMembership.java, but I can't seem to locate this tews6 jar file which contains the other relevant files.  Any help on this would be greatly appreciated.

     

    Here's the location of the sample files:

       <Installation Path>\CA\Identity Manager\IAM Suite\Identity Manager\tools\samples\WebService\Axis

     


    import java.math.BigInteger;

    import com.netegrity.ims.tews6.ImsStatus;
    import com.netegrity.llsdk6.imsapi.type.OperatorType;

    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=SuperAdmin,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();
    ModifyGroupMembershipMembershipTabGroupMembersAdd[] membersToAdd= new ModifyGroupMembershipMembershipTabGroupMembersAdd[1];
    ModifyGroupMembershipMembershipTabGroupMembersAddFilter[] membersFilter= new ModifyGroupMembershipMembershipTabGroupMembersAddFilter[1];
    membersFilter[0]=new ModifyGroupMembershipMembershipTabGroupMembersAddFilter();
    membersFilter[0].setField("%USER_ID%");
    membersFilter[0].setOp(OperatorType.EQUALS);
    membersFilter[0].setValue("*");
    membersFilter[0].setIndex(new BigInteger("0"));
    membersToAdd[0]=new ModifyGroupMembershipMembershipTabGroupMembersAdd();
    membersToAdd[0].setFilter(membersFilter);
    membersToAdd[0].setIndex(0);

    members.setAdd(membersToAdd);
    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());

    }

    }



  • 2.  Re: Sample Java Code - ModifyGroupMembership
    Best Answer

    Broadcom Employee
    Posted 01-29-2018 05:45 AM

    Hi CSison,

     

    In a first step, you need to involve the org.apache.axis.wsdl.WSDL2Java class which will generate the Java source proxies from your WSDL.
    e.g.:
    java org.apache.axis.wsdl.WSDL2Java http://MyImServer:8080/iam/im/TEWS6/neteauto?wsdl -w -o wsdl2java\src

    Then (2nd step) you need to compile those generated java source proxies.
    e.g.:
    %JAVA_HOME%\bin\javac -classpath %CLASSPATH% -d .. tews6\wsdl\*.java

     

    Those generated java class proxies will deal with your program import statement (import tews6.wsdl.*;).

    Note: You will get proxies only for the IM admin tasks you have exposed to the web service usage.


    The 2 steps I previously mentioned can be led (recommended if you are novice) by using the provided

    "IAM Suite\Identity Manager\tools\samples\WebService\Axis\build.xml" script.

    So look at the instructions about how to configure and run the script:

    at "IAM Suite\Identity Manager\tools\samples\WebService\Axis\Readme.txt".


    Also I suggest you to review the doc
    https://docops.ca.com/ca-identity-manager/12-6-8/EN/programming/programming-guide-for-java/tews-sample-client-code
    https://docops.ca.com/ca-identity-manager/14-1/EN/programming/programming-guide-for-java/tews-sample-client-code

     

    Regards,

    Philippe.