Searching for UID with Filter

I’m trying to search about a specific UID in a application using Filter. Where’s the error? Some documentation or tip to get the correct name to filtering?

QueryOptions qo = new QueryOptions();
  String uid = "kalia.horn";
  qo.add(Filter.and(
    Filter.eq("links.application.name","Enterprise Directory"),
    Filter.eq("attribute.uid",uid)
  )

Hello,

Are you trying to do a QueryOptions for Link.class objects?

You can try the following, let me know if this help:

QueryOptions qo = new QueryOptions();
  String uid = "kalia.horn";
  qo.add(Filter.and(
    Filter.eq("application.name","Enterprise Directory"),
    Filter.eq("nativeIdentity",uid)
  )

Regards,

Mathieu G

Hey Mathieu. Thank for you reply.

I tried your possible solution but it doesn’t work. When I use this code:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule created="1686797398156" id="7f00000188bc17178188bcf5b08c0585" language="beanshell" modified="1687351472297" name="Search UID">
  <Source>
  import sailpoint.object.*;
  import sailpoint.api.SailPointContext;
  import javax.naming.directory.DirContext;
  import sailpoint.tools.ldap.LDAPUtil;
  import javax.naming.directory.InitialDirContext;

  QueryOptions qo = new QueryOptions();
  String uid = "emma.kennedy"; //"emma.kennedy"
  qo.add(Filter.and(
Filter.eq("links.application.name","Enterprise Directory")  
  )

        );

  List<Identity> links = context.getObjects(Identity.class, qo);
	return links;
  </Source>
</Rule>

Returns all Identity from this Application, but I want a specific Identity using uid contained in name attribute.

Regards,

L Filipe

It’s a bit unclear from your post and this response where exactly you’re looking for this value. If you’re looking for an identity whose identity name is some value, then you can just use `context.getObjectByName(Identity.class, nameValue)` to look that up. If you’re looking for the identity that has a link whose native identity (the app-side identifier for the account) is a value, then you can do a search on the Link class with a filter on the nativeIdentity value, and then call getIdentity() on the Link to get to the Identity.

If you’re trying to search for links on an app-specific attribute (i.e. not native identity or display name), you’d need to turn that into a searchable extended attribute on the Link class; otherwise you won’t be able to use it in a filter.

Thanks.

I’m trying to get an Identity Object from Application using Filter & QueryOptions.

Ok I got it  @lfmilhomem

This should work. Let me know.

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Rule created="1686797398156" id="7f00000188bc17178188bcf5b08c0585" language="beanshell" modified="1687351472297" name="Search UID">
  <Source>
  import sailpoint.object.*;
  import sailpoint.api.SailPointContext;
  import javax.naming.directory.DirContext;
  import sailpoint.tools.ldap.LDAPUtil;
  import javax.naming.directory.InitialDirContext;

  QueryOptions qo = new QueryOptions();
  String uid = "emma.kennedy"; //"emma.kennedy"
  qo.add(Filter.and(
Filter.eq("links.application.name","Enterprise Directory"),  
Filter.eq("links.nativeIdentity",uid),  
  ));

  List<Identity> links = context.getObjects(Identity.class, qo);
	return links;
  </Source>
</Rule>

Regards,

Mathieu G

Now it works as I wanted it to.

Thanks, Mathieu.

I am happy to help! :slightly_smiling_face:

Regards,

Mathieu G