Symantec Access Management

  • 1.  How to use the Search Method in SDK

    Posted Apr 11, 2017 08:20 AM

    I am currently working on CA Siteminder R12.52 SP01 CR06 .. I am currently working audit script that check realms if correctly. I had notice that there is a search method of the  SmPolicyApiImpl object.

     

    SmApiResult search(SmObject searchObj,                    java.lang.String[] searchProps,                    java.util.Vector searchResults)                    throws SmApiException

     

     

    May I ask how I should use the searchProps ?

    I am was using the command to return all Realm OID that use this specific Agent OID.  But somehow the search is returning all the Realms in the Policy Server Instance

     

     

    below is a short snipit of my code

     

       Vector v =new Vector ();

       String [] strSearchProp = new String [1] ;

       strSearchProp [0] = "01-00093e9e-01fa-1536-a840-57220a7d309d";

       SmRealm mySMRealm = new SmRealm();

     

       objMyPolicyAPI.search(mySMRealm, strSearchProp, chldrn);

       System.out.println(chldrn.size());

     

     

    I just need to a sample to properly populate the Search Proper Method of the API.



  • 2.  Re: How to use the Search Method in SDK
    Best Answer

    Posted Apr 13, 2017 10:59 AM

    Hi,

     

    Here is the complete details on the search method of smpolicyapi.

     

    search

    public SmApiResult search(SmObject searchObj,                           java.lang.String[] searchProps,                           java.util.Vector searchResults)                    throws SmApiException
    Description copied from interface: SmPolicyApi
    Searches the policy store for the specified object using the specified search criteria.

     

    Specified by:
    search in interface SmPolicyApi
    Parameters:
    searchObj - The object to search for.

     

    searchProps - One or more search criteria. Valid search criteria values are constants that:

     

    • Begin with Prop and that are defined in the class of the object you are searching for.

    • Are documented as being searchable properties.
    For example, you can use PropPolicy to search for SmUserPolicy objects, and PropIpAddr to search for SmAgent objects.

     

    searchResults - This Vector will be populated with the search results.
    Returns:
    An SmApiResult object for the search.
    SmApiException

    sample example given below:
    public SmApiResult search (SmObject searchObj, String [] searchProps,Vector searchResults)throws SmApiException
    {
    Hashtable props = new Hashtable();
    searchObj.writeSearchProperties(props, searchProps);
    //searchObj.writeProperties(props);
    SmApiObject trobj = new SmApiObject(props);
    SmApiResult result = m_ApiSession.getApiConnection().execute (
    getSessionspec(),SmApiConstants.POLICYAPI_CMD_SEARCH,trobj);
    if (result.isSuccess())
    {
    // a list of object OIDs is returned
    Hashtable oids = result.getDecoderObject().getProperties();
    putPropsToStringVector(oids, searchResults);
    }
    return result;
    }


    Hope this helps.

    Thanks,
    Sharan



  • 3.  Re: How to use the Search Method in SDK

    Posted Jul 23, 2017 09:33 PM

    Hi AI John,

     

    For your specific use case, here is what needs to be done :

    Note : You can search based on the AgentOID as well as the actual 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>

     

    Hope it helps.


    Regards,

    Ujwol