Symantec Access Management

  • 1.  How to Get AgentGroup with AgentName/OID using JAVA API

    Posted Jul 21, 2017 09:59 AM

    Hello All,

     

    I would like to get your advise/idea on How to Get AgentGroup with AgentName/OID using JAVA API.

     

    I am trying to collect the AgentGroup, DomainName using the AgentName as a input. please share your idea on how can we try it. 

     

    Regards,

    RaamVeera



  • 2.  Re: How to Get AgentGroup with AgentName/OID using JAVA API
    Best Answer

    Posted Jul 23, 2017 10:24 PM

    Hi Raam,

     

    There is no straight forward way of doing it.

     

    If the property being searched is a searchable property in the object then it can be searched easily using PolicyApi.search() API like this :

     

    In the following example , I am searching for realm containing a specific agent OID. You can also search with the agentname.

     

    private void search(SmPolicyApi policyapi){
            
             SmRealm realm = new SmRealm();
             //realm.setAgent("agent-ohs");
             realm.setAgent("01-92748450-299c-409a-a569-439e1b5e4f8b");
             SmApiResult result = new SmApiResult();
              Vector realmOids = new Vector(5);
              try {
                   result = policyapi.search (
                                                 realm,
                                                 new String[] {
                                                      SmRealm.PropAgent
                                                             },
                                                 realmOids);
                  
                   System.out.println("\n RealmOIds : ");
                  
                   Enumeration evalues = ((Vector)realmOids).elements();
                   while (evalues.hasMoreElements())
                   {
                        System.out.println ("<" + evalues.nextElement() + ">");
                   }
              } catch (SmApiException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              }
    }

    Result :

     

    RealmOIds :
    <06-1421108a-33b7-4d55-bf4c-d9a8d2c4b4f3>

     

    Now, to identify if the property is searchable or not you will need to look at the doco :

     

    CA SiteMinder SDK r12.52sp1 

    com.netegrity.sdk.policyapi.SmRealm

     

    PropAgent

    public static final java.lang.String PropAgent
    Constant to indicate the property Agent (searchable). You can search realm objects based on this property.

     

    Now, 

    SmAgentGroup does NOT have a searchable PropAgent property so unfortunately you can't use this method.

     

    What you will need to do is a long shot method like this ;

    • Get All group of type "Web Agent"
    • Iterate through all group, get groups by OID and then check if group has specified agentname as member

     

     private void search(SmPolicyApi policyapi, String agentNameToBeSearched){

             Vector<String> returnGroup = new Vector();
            
             //Get All AgentGroups of Type "Web Agent"
             SmAgentGroup agentGroup = new SmAgentGroup();
             agentGroup.setAgentType("Web Agent");
             SmApiResult result = new SmApiResult();
              Vector agentGroupOids = new Vector(5);
              try {
                   result = policyapi.search (
                             agentGroup,
                                  new String[] {
                                  SmAgentGroup.PropAgentType
                                              },
                             agentGroupOids);
              } catch (SmApiException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              }
             
             
              // Get groups by OID and then check if agent group has specified agentname as member.
              for (Object agentGroupId :  agentGroupOids) {
                  
                   SmAgentGroup group = new SmAgentGroup();
                   Vector agentNames = new Vector();
                   try {
                        policyapi.getObject((String)agentGroupId, group);
                        policyapi.getGroupMembers(SmGroup.Agent_Group_Prop, group.getName(), "", agentNames);
                        if (agentNames.contains(agentNameToBeSearched))
                             returnGroup.add(group.getName());
                       
                        //System.out.println(group.getName());
                       
                   } catch (SmApiException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                   }
                  
              }
              System.out.println("\nGroup containing agent: "+ agentNameToBeSearched + " are as follows: ");
              Enumeration evalues = ((Vector)returnGroup).elements();
              while (evalues.hasMoreElements())
              {
                   System.out.println ("<" + evalues.nextElement() + ">");
              }
    //          printResult (result);
    //          printObject (agentGroupOids);
        }

     

    Result:

    Group containing agent: agent_iis_01 are as follows:
    <agent_group1>

     

    Let me know if any questions.

     

    Regards,

    Ujwol Shrestha