Issue with Sailpoint IIQ creation Rule

Hi everyone,

I’m working on IdentityIQ version 8.4 and setting up correlation for Active Directory accounts. The idea is to create new identities using the username, first name, and last name.

The identities are getting created correctly, and correlation is working fine with the expected username. But for some reason, the first name and last name aren’t showing up in the identity object.

Here’s the part of the code I’m using:
String firstName = (String) i.getAttribute(“firstname”);
String lastName = (String) i.getAttribute(“lastname”);

identity.setFirstname(firstName);
identity.setLastname(lastName);

Hi @Abhinav_Goel12

Were you able to see the values from below statements?

String firstName = (String) i.getAttribute(“firstname”);
String lastName = (String) i.getAttribute(“lastname”);

If you see the values, you need to save object and commit transactions after setting on Identity. Updated code below

identity.setFirstname(firstName);
identity.setLastname(lastName);

context.saveObject(identity);
context.commitTransaction();
context.decache();

Hi @Abhinav_Goel12

The issue might be because you’re not saving identity object. Add following lines at the end of your code

context.saveObject(identity);
context.commitTransaction();

Also you can verify the same if details are updated on identity or not by printing the identity object in logs.

Hello Harshith,
Thanks for the revert.

I am already saving the object using:

context.saveObject(identity);
context.commitTransaction();

Are you able to print the updated Identity in logs ?

hello @Abhinav_Goel12 could you please share the complete code here?

Hello Santhi,

Below is the xml:

Identity creation rules are used to set attributes on new Identity objects when they are created. New identities may be created during the aggregation of application accounts, or optionally created after pass-through authentication.

if (account.getStringAttribute(“sAMAccountName”).toLowerCase().startsWith(“ch-adm”)) {
String manager = account.getStringAttribute(“manager”);
if (sailpoint.tools.Util.isNotNullOrEmpty(manager)) {
sailpoint.object.QueryOptions qo = new sailpoint.object.QueryOptions();
qo.addFilter(sailpoint.object.Filter.eq(“application.name”, “Active Directory”));
qo.addFilter(sailpoint.object.Filter.ignoreCase(sailpoint.object.Filter.eq(“nativeIdentity”, manager)));
java.util.Iterator itr = context.search(sailpoint.object.Identity.class, qo, “identity”);

    if (itr.hasNext()) {
        sailpoint.object.Identity i = (sailpoint.object.Identity) itr.next();
        if (i != null) {
            String firstName = (String) i.getAttribute("firstname");
            String lastName = (String) i.getAttribute("lastname");

            if (sailpoint.tools.Util.isNotNullOrEmpty(firstName) && sailpoint.tools.Util.isNotNullOrEmpty(lastName)) {
                String formattedName = "(ADM) " + lastName+ ", " + firstName;
                identity.setAttribute("firstname", firstName);                  
                identity.setAttribute("lastname", lastName);
                identity.setName(formattedName);
                identity.setDisplayName(firstName);

                try {
                    identity.setFirstname(firstName);
                    identity.setLastname(lastName);
                } catch (NoSuchMethodError e) {
                    // Method not exist
                }

            } else {
                identity.setName(i.getName());
            }

            identity.setModified(true);
            identity.setType("administrator");
            identity.setAdministrator(i);

            context.startTransaction();
            context.saveObject(identity);
            context.commitTransaction();
        }
    }
    sailpoint.tools.Util.flushIterator(itr);
}

}

Hi @Abhinav_Goel12 ,

java.util.Iterator itr = context.search(sailpoint.object.Identity.class, qo, “identity”); // This returns an Iterator of an Array containing the properties mentioned in third parameter of search and ‘identity’ is also not a valid property for using in search.

As itr.next() returns an Iterator of an Array. so, you cannot retrieve the identity first name and lastname from i.

sailpoint.object.Identity i = (sailpoint.object.Identity) itr.next();

To get the iterator of an identity objects, you need to use:

java.util.Iterator itr = context.search(sailpoint.object.Identity.class, qo);

can you try with below line, instead of what you are using
java.util.Iterator itr = context.search(sailpoint.object.Identity.class, qo,);

Hello Sharad,

I have tried the approach suggested by you :
java.util.Iterator itr = context.search(sailpoint.object.Identity.class, qo);

but somehow it’s still not working. Below is the update code :

if (account.getStringAttribute(“sAMAccountName”).toLowerCase().startsWith(“ch-adm”)) {
String manager = account.getStringAttribute(“manager”);
if (sailpoint.tools.Util.isNotNullOrEmpty(manager)) {
sailpoint.object.QueryOptions qo = new sailpoint.object.QueryOptions();
qo.addFilter(sailpoint.object.Filter.eq(“application.name”, “Active Directory”));
qo.addFilter(sailpoint.object.Filter.ignoreCase(sailpoint.object.Filter.eq(“nativeIdentity”, manager)));
java.util.Iterator itr = context.search(sailpoint.object.Identity.class, qo);

    if (itr.hasNext()) {
        sailpoint.object.Identity i = (sailpoint.object.Identity) itr.next();
        if (i != null) {
            String firstName = (String) i.getAttribute("firstname");
            String lastName = (String) i.getAttribute("lastname");

            if (sailpoint.tools.Util.isNotNullOrEmpty(firstName) && sailpoint.tools.Util.isNotNullOrEmpty(lastName)) {
                String formattedName = "(ADM) " + lastName+ ", " + firstName;
                identity.setAttribute("firstname", firstName);									
                identity.setAttribute("lastname", lastName);
                identity.setName(formattedName);
                identity.setDisplayName(firstName);

                try {
                    identity.setFirstname(firstName);
                    identity.setLastname(lastName);
                } catch (NoSuchMethodError e) {
                    // Method not exist
                }

            } else {
                identity.setName(i.getName());
            }

            identity.setModified(true);
            identity.setType("administrator");
            identity.setAdministrator(i);

            context.startTransaction();
            context.saveObject(identity);
            context.commitTransaction();
        }
    }
    sailpoint.tools.Util.flushIterator(itr);
}

}

can you try adding log statement before and after and check if identity is object is getting updated in rule or not, and also if it is entering in if statements or not.

Hello Sharad,
I am able to resolve the issue by updating the query to search for link object instead :

context.search(sailpoint.object.Link.class, qo);Below is the updated code: String sAMAccountName = account.getStringAttribute(“sAMAccountName”);if (sAMAccountName != null && sAMAccountName.toLowerCase().startsWith(“ch-adm”)) {
String manager = account.getStringAttribute("manager");

if (sailpoint.tools.Util.isNotNullOrEmpty(manager)) {
    sailpoint.object.QueryOptions qo = new sailpoint.object.QueryOptions();
    qo.addFilter(sailpoint.object.Filter.eq("application.name", "Active Directory"));
    qo.addFilter(sailpoint.object.Filter.ignoreCase(sailpoint.object.Filter.eq("nativeIdentity", manager)));

    java.util.Iterator itr = context.search(sailpoint.object.Link.class, qo);

    if (itr.hasNext()) {
        sailpoint.object.Link link = (sailpoint.object.Link) itr.next();
        sailpoint.object.Identity i = link.getIdentity();

        if (i != null) {
            String firstName = (String) i.getAttribute("firstname");
            String lastName = (String) i.getAttribute("lastname");

            if (sailpoint.tools.Util.isNotNullOrEmpty(firstName) && sailpoint.tools.Util.isNotNullOrEmpty(lastName)) {
                String formattedName = "(ADM) " + lastName + ", " + firstName;

                identity.setAttribute("firstname", firstName);
                identity.setAttribute("lastname", lastName);
                identity.setName(formattedName);
               // identity.setDisplayName(firstName);

                try {
                    identity.setFirstname(firstName);
                    identity.setLastname(lastName);
                } catch (NoSuchMethodError e) {
                }
            } else {
                identity.setName(i.getName());
            }

            identity.setType("administrator");
            identity.setAdministrator(i);

            context.startTransaction();
            context.saveObject(identity);
            context.commitTransaction();
        }
    }

    sailpoint.tools.Util.flushIterator(itr);
}
}

But somehow this is working in Stg environment but not in production. Fname and Lname attributes are not getting updated.

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