cancel
Showing results for 
Search instead for 
Did you mean: 
jkaipa
Level 9
Report Inappropriate Content
Message 1 of 12

Query for Policy Object Id by policy name

Jump to solution

How can I query for a unique policy object id using Web API if I know the policy name and the product name?

I want to use the method 

policy.assignToGroup

But it takes object id (this is from PolicyAssignment table). The query policy.find takes searchText but unfortunately in my scenario, it is returning multiple objects and the corresponding objectId value. Is there a way I can filter policy.find or a way I can retrieve objectId in a unique manner?

Thanks 

1 Solution

Accepted Solutions
jkaipa
Level 9
Report Inappropriate Content
Message 10 of 12

Re: Query for Policy Object Id by policy name

Jump to solution

The only way possible is

1. Use this api to retrieve policies that match the name

https://epohost:8443/remote/policy.find?searchText=McAfee Default&:output=json

2. As the hierarchy is Feature -> TypeName -> Policy Name, now in this step parse the json and filter by "featureName" and "typeName" and "objectName"

3. This would exactly return one record which will have "objectId" which is the "Policy Object Id"

Api should offer such a kind of filtering so that, client of the api dont need to bother about the working.

Thanks to all for your help on this issue.

View solution in original post

11 Replies
McAfee Employee AdithyanT
McAfee Employee
Report Inappropriate Content
Message 2 of 12

Re: Query for Policy Object Id by policy name

Jump to solution

Hi @jkaipa 

Thank you for your post. Glad to hear from you again!

Once again disclaimer: I am really not the expert here, but just ran the help command to understand what is supported by policy.find. Looks like it does not support anything other than searchText and hence I don't think it can help us find a unique policy object ID using the policy name and product name.

https://localhost:8443/remote/core.help?command=policy.find

The above help command clearly displays the accepted params:

policy.find [searchText]
Finds policies filtered by specified search text
Requires view permission for at least one product
Parameters:
 searchText (param 1) - Search text. Wildcards and regular expressions are not
supported.

If we have multiple policies with the same name for different products, we have to differentiate them by naming them differently denoting the product in the name (for example using prefix ENS_TP_AP to show this is an ENS Threat Prevention Access Protection policy). I know this is definitely not the ideal "solution" here, but this is only to maintain the uniqueness on name itself to avoid browsing through multiple results for a policy.find query.

I sincerely hope this information is helpful!

Was my reply helpful?
If you find this post useful, Please give it a Kudos! Also, Please don't forget to select "Accept as a solution" if this reply resolves your query!

Thanks and regards,
Adithyan T
McAfee Employee AdithyanT
McAfee Employee
Report Inappropriate Content
Message 3 of 12

Re: Query for Policy Object Id by policy name

Jump to solution

Hi @jkaipa 

I have been breaking my head over this for the past 2 hours only to find out this:

So I tried to run a SQL query and grab the required data, later import it into API based query. However it kept failing. So I tried to import the query in an XML format readable by ePO and ePO failed to import it saying this table does not exist (My idea was to execute it via ePO and then use the query ID generated to get the results via webAPI).

However, the query itself was formatted correct, which made me run this:

 

https://epo:8443/remote/core.listTables

 

This shows up all the tables that is visible to us via API queries and this does not contain the table that I was working on to get the query done "EPOPolicyObjects". I am afraid other tables that are accessible via API is not really going to be of any help here. Hence I am afraid this may just not be possible.

I sincerely hope this information helps.

*Note: Although, I would love to be wrong on this if someone has a different approach towards this!

Was my reply helpful?
If you find this post useful, Please give it a Kudos! Also, Please don't forget to select "Accept as a solution" if this reply resolves your query!

Thanks and regards,
Adithyan T
jkaipa
Level 9
Report Inappropriate Content
Message 4 of 12

Re: Query for Policy Object Id by policy name

Jump to solution

Thanks for your research. I did the same this morning and those tables are not visible to executeQuery and trying to see if there are any hidden features available through the policy.find which are not documented 😄

 

Thanks

McAfee Employee AdithyanT
McAfee Employee
Report Inappropriate Content
Message 5 of 12

Re: Query for Policy Object Id by policy name

Jump to solution

Hi @jkaipa 

Thank you for the update! There is no hidden method I am aware of. I confirmed with a peer(an expert in ePO) as well regarding the possibility. Hopefully, We will wait for someone to help us out here! Kudos to your efforts here!

Was my reply helpful?
If you find this post useful, Please give it a Kudos! Also, Please don't forget to select "Accept as a solution" if this reply resolves your query!

Thanks and regards,
Adithyan T
McAfee Employee cdinet
McAfee Employee
Report Inappropriate Content
Message 6 of 12

Re: Query for Policy Object Id by policy name

Jump to solution

Have you tried using an ad-hoc query?  There is a section in the attached web api scripting guide.  Either it won't work because of where it might pull the data from, or it may give you what you want.

 

Was my reply helpful?
If this information was helpful in any way or answered your question, will you please select Accept as Solution in my reply and together we can help other members?

jkaipa
Level 9
Report Inappropriate Content
Message 7 of 12

Re: Query for Policy Object Id by policy name

Jump to solution

Yes I tried. The table PolicyObjects is protected and not exposed for query.

Thanks

McAfee Employee cdinet
McAfee Employee
Report Inappropriate Content
Message 8 of 12

Re: Query for Policy Object Id by policy name

Jump to solution

Did you try maybe policy find option with a where clause for policy name?

For example, instead of quarantine in this example, put policy name?  What does that result in?

curl -k -u ga:ga https://localhost:8443/remote/policy.find?searchText=quarantine

Was my reply helpful?
If this information was helpful in any way or answered your question, will you please select Accept as Solution in my reply and together we can help other members?

McAfee Employee AdithyanT
McAfee Employee
Report Inappropriate Content
Message 9 of 12

Re: Query for Policy Object Id by policy name

Jump to solution

Hi @jkaipa 

As I confirmed with an expert on the same, I am afraid this is a conscious move to not to expose these tables. We apologize for the inconvenience.

Please do not hesitate to put up a Product Enhancement request if you require certain table exposed, where in we may not directly expose these to API queries but other alternatives can be explored and the decision would lie with product management and Engineering.

I am sure we have not resolved your query, but sincerely hope it clarifies the query here.

Was my reply helpful?
If you find this post useful, Please give it a Kudos! Also, Please don't forget to select "Accept as a solution" if this reply resolves your query!

Thanks and regards,
Adithyan T
jkaipa
Level 9
Report Inappropriate Content
Message 10 of 12

Re: Query for Policy Object Id by policy name

Jump to solution

The only way possible is

1. Use this api to retrieve policies that match the name

https://epohost:8443/remote/policy.find?searchText=McAfee Default&:output=json

2. As the hierarchy is Feature -> TypeName -> Policy Name, now in this step parse the json and filter by "featureName" and "typeName" and "objectName"

3. This would exactly return one record which will have "objectId" which is the "Policy Object Id"

Api should offer such a kind of filtering so that, client of the api dont need to bother about the working.

Thanks to all for your help on this issue.

View solution in original post

More McAfee Tools to Help You

Community Help Hub

    New to the forums or need help finding your way around the forums? There's a whole hub of community resources to help you.

  • Find Forum FAQs
  • Learn How to Earn Badges
  • Ask for Help
Go to Community Help

Join the Community

    Thousands of customers use the McAfee Community for peer-to-peer and expert product support. Enjoy these benefits with a free membership:

  • Get helpful solutions from McAfee experts.
  • Stay connected to product conversations that matter to you.
  • Participate in product groups led by McAfee employees.
Join the Community
Join the Community