How can I filter Identity object based on firstname,lastname,email or id

Which IIQ version are you inquiring about?

Version 8.3

Share all details related to your problem, including any error messages you may have received.

I am new in sailpoint, I want identity object based on search filter firstname,lastname,email or id. Please help on this via rule.

Hi @amanKsingh,

Could you tell us more about your requirement?
Do you want list of Identities and their attributes listed out in a report?

Hello,

The most effective way to begin comprehending IdentityIQ object models and beanshell would be to refer to the Beanshell Developer’s Guide:

https://community.sailpoint.com/t5/Technical-White-Papers/BeanShell-Developer-s-Guide-for-IdentityIQ/ta-p/74365

For specific information on querying, please review:
https://community.sailpoint.com/t5/Technical-White-Papers/BSDG-5-Querying-IdentityIQ-Objects/ta-p/73135

You can use simple QueryOptions to do that - in this case you have to build filter which is relevant for you and you can get objects.

To get objects you can either use getObjects then you will get exact list of objects (it might be not effective from performance poinf of view. Or you can use search to get iterator to the result set (this is much more performance effective).

import sailpoint.object.QueryOptions;
import sailpoint.object.Identity;

QueryOptions qo = new QueryOptions();
Filter f1 = Filter.eq("firstname", YOUR_FIRST_NAME);
Filter f2 = Filter.eq("lastname", YOUR_LAST_NAME);
Filter f3 = Filter.eq("email", YOUR_EMAIL);

qo.add(Filter.and(f1,f2,f3));

List ids = context.getObjects(Identity.class,qo);

Iterator it = context.search(Identity.class,qo);

To get Identity knowing it’s name or id you can just use context.getObjectByName(Identity.class,NAME); or context.getObjectById(Identity.class,ID).

You may use the below sample code snippet as given below. Also you can customize it depending upon your use case.

Filter on Individual attribute

		QueryOptions qo = new QueryOptions();
		qo.addFilter(Filter.eq("firstname", "Ram"));
		
		List<Identity> identityList=context.getObjects(Identity.class,qo);
		
		QueryOptions qo = new QueryOptions();
		qo.addFilter(Filter.eq("lastname", "Singh"));
		
		List<Identity> identityList=context.getObjects(Identity.class,qo);
		
		

Combined Filter

		Filter combinedFil=Filter.and(Filter.eq("firstname", "Ram"),Filter.eq("lastname", "Singh"));
		QueryOptions qo = new QueryOptions();
		qo.addFilter(combinedFil);
		
		List<Identity> identityList=context.getObjects(Identity.class,qo);

@kjakubiak,Can you please help me like during using filter it gives all value as filtered name but i want only those filtered value having prefix.

// Filter.like("FirstName", "%" + searchTerm + "%"),      
		
	  QueryOptions qo = new QueryOptions();
    Filter f1 = Filter.eq("name", SearchValue);
    Filter f2 = Filter.like("firstname", SearchValue);
    Filter f3 = Filter.like("lastname", SearchValue);
    Filter f4 = Filter.eq("email", SearchValue);

    qo.add(Filter.or(f1,f2,f3,f4));
   
     
      List&lt;Identity> identities = context.getObjects(Identity.class, qo);

It gives value firstname and lastname as attached screenshot name(aman) is in middle and last.
but i want filtered value as prefix only.

you can use match mode in your filter for pre-fix searches

Filter.like("lastname", "searchvalue", Filter.MatchMode.START)
1 Like

Please check the filter API, you can use Filter.MatchMode which can query against, start, end or anywhere.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.