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("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) {
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();
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) {
e.printStackTrace();
}
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());
} catch (SmApiException e) {
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() + ">");
}
}
Result:
Group containing agent: agent_iis_01 are as follows:
<agent_group1>
Let me know if any questions.
Regards,
Ujwol Shrestha