ralfonse
(Rudolf Alfonse)
October 27, 2023, 10:42am
1
Hello
I am trying to update accounts using the WS Connector. My end point requires me to send in an account identifier in the request url. I am thinking I need to look up the link in iiq and get the identifier. I am stuck getting the identity to do the look up. What is a way to get the identity in the webService connector before operation rule?
iamnithesh
(Nithesh Rao)
October 27, 2023, 10:45am
2
Rudolf Alfonse:
account identifier
Is this the attribute that is marked as âIdentity Attributeâ in Account Schema? In such case, you can use accountRequest.getNativeIdentity()
ralfonse
(Rudolf Alfonse)
October 27, 2023, 10:50am
3
Hi Nitesh
The attribute is on the account schema, it is labeled as id. I tried it and it wasnât able to find accountRequest
Attempt to resolve method: getNativeIdentity() on undefined variable or class name: accountRequest
iamnithesh
(Nithesh Rao)
October 27, 2023, 10:54am
4
Can you please share the Java code?
You might not have the same name âaccountRequestâ
ralfonse
(Rudolf Alfonse)
October 27, 2023, 10:56am
5
Sure
Here is the full rule with various attempts in it.
import connector.common.JsonUtil;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import sailpoint.object.Identity;
import sailpoint.object.Link;
import sailpoint.object.Application;
import java.util.Iterator;
import sailpoint.object.QueryOptions;
import sailpoint.api.IdentityService;
log.error("xxx Starting before operation rule");
IdentityService ids = new IdentityService(context);
log.error("xxx here is the ids " + ids);
log.error("xxx " + accountRequest.getNativeIdentity());
//#####
for (int i = 0 ; i < this.variables.length ; i++) {
String varName = this.variables[i];
Object varValue = null;
try {
if ("transient".equals(varName)) {
varValue = "[reserved word]";
} else {
varValue = eval(varName);
}
} catch (Exception ex) {
varValue = "[eval exception]";
}
String varClass = "void";
if ((void != varValue) && (null != varValue)) {
varClass = varValue.getClass().getSimpleName();
}
if (void == varValue) {
log.error("XXX: " + varName + " = void");
} else if (null == varValue) {
log.error("XXX: " + varName + " = null");
} else {
log.error("xxx: " + varName + ": " + varClass + " = " + varValue);
}
}
//#####
//while (it.hasNext()) {
//this prints out every identity we have, not good
// Identity id = (Identity) it.next();:0
//log.error("xxx here is identity " + id);
//}
//app = context.getObjectByName(Application.class, "Cority");
//List links = ids.getLinks(identity,app);
//for (String item : links) {
//log.error("xxx item " + item);
// }
//List linkList = identityService.getLinks(identity);
//Application EIDS_NG = context.getObjectByName(Application.class, "EIDS_NG");
//Link myLink=identity.getLink(EIDS_NG);
//if(myLink!=null) {
//log.error("xxx here is my link " + myLink);
//} else {
//log.error("xxx i did not get a link");
//}
Map body = requestEndPoint.getBody();
log.error("xxx map body value is : "+body);
String jsonBody = (String) body.get("jsonBody");
log.error("xxx jsonBody value is : "+jsonBody);
Map jsonMap = JsonUtil.toMap(jsonBody);
log.error("xxx jsonMap value is:"+jsonMap);
//possible npe here
//Application Cority = context.getObjectByName(Application.class, "Cority");
//Identity identity;
// log.error("xxx identity name value is:" + identity.getName());
// Link myLink=identity.getLink(Cority);
// corityId=myLink.getAttribute("id");
// log.error("xxx corityId value is: " + corityId);
// get the base url and build the token URL
String fullUrl = requestEndPoint.getFullUrl();
//requestEndPoint.setFullUrl(fullUrl);
log.error("xxx fullUrl value is:" + fullUrl);
// String tokenPath = "/Passwordvault/Api/Auth/CyberArk/Logon";
// String tokenUrl = contextUrl + tokenPath;
log.error("Ending before operation rule");
Remold
(Remold Krol)
October 27, 2023, 10:58am
6
It is possible to search for the Account Link and get the âidâ attribute.
For instance put the following in your Before Operation Rule:
String id = "";
Link l = (Link) context.getUniqueObject(Link.class, Filter.and(Filter.eq("application.name", "ApplicationName"),Filter.eq("identity", accountRequest.getNativeIdentity())));
if (l != null) {
id = (String) l.getAttribute("id");
}
Here you need to change ApplicationName
to the name of your application.
The variable id
contains the id off the account.
â Remold
iamnithesh
(Nithesh Rao)
October 27, 2023, 11:06am
7
Sorry but I am not able to understand what are you trying to do in this rule. I was expecting reference to a ProvisioningPlan and associated AccountRequest
ralfonse
(Rudolf Alfonse)
October 27, 2023, 11:09am
8
Hi Remold
I am getting a similar error
Attempt to resolve method: getNativeIdentity() on undefined variable or class name: accountRequest
String id = "";
Link l = (Link) context.getUniqueObject(Link.class, Filter.and(Filter.eq("application.name", "Cority"),Filter.eq("identity", accountRequest.getNativeIdentity())));
if (l != null) {
id = (String) l.getAttribute("id");
log.error("xxx got the id " + id);
}
ralfonse
(Rudolf Alfonse)
October 27, 2023, 11:12am
9
Rudolf Alfonse:
String id = "";
Link l = (Link) context.getUniqueObject(Link.class, Filter.and(Filter.eq("application.name", "Cority"),Filter.eq("identity", accountRequest.getNativeIdentity())));
if (l != null) {
id = (String) l.getAttribute("id");
log.error("xxx got the id " + id);
}
The user already has an account and this is an update. For example this application is set as a target when the lastName attribute is updated.
In the rule Iâm hoping I can grab some data from the existing link and add it to the url so that the change to the lastName can be sent.
iamnithesh
(Nithesh Rao)
October 27, 2023, 11:24am
10
I suppose this will be the âBefore Ruleâ for an âUpdate Accountâ Connector operation in your WSC type Application configuration. In that case provisioningPlan object is injected into your rule by IIQ, and you can get the accountRequest using this
List accountRequests = provisioningPlan.getAccountRequests();
Iterate through accountRequests to get the accountRequest object
Most likely there will be only one object in accountRequests and you should be able to break from the loop right after first run.
ralfonse
(Rudolf Alfonse)
October 27, 2023, 1:20pm
11
Rudolf Alfonse:
getAttribute
Thank you! I can get the native identity doing it this way.
I am adding this here just in case it helps anyone else.
List accountRequestsList = provisioningPlan.getAccountRequests();
if (accountRequestsList != null @and !accountRequestsList.isEmpty()) {
for (item : accountRequestsList) {
log.error("xxx item : " + item);
log.error("xxx item operation: " + item.getOperation().toString());
log.error("xxx item native: " + item.getNativeIdentity());
List attrReqList = item.getAttributeRequests();
if (attrReqList != null @and !attrReqList.isEmpty()) {
//iterate through attribute request list
for (AttributeRequest attr : attrReqList) {
log.error("xxx attr.getValue() class: " + attr.getValue().getClass().getSimpleName());
if (attr.getValue().getClass().getSimpleName().contains("String")) {
log.error("xxx value " + attr.getValue());
}
}
}
}
}else {
log.error("xxx empty request");
}
1 Like
Remold
(Remold Krol)
October 29, 2023, 5:44pm
12
@ralfonse A simple check to see if you have a String or a List attribute (from the AttributeRequest) you can use something like:
Object value = attr.getValue();
if (value instanceof String)) {
log.error("xxx value " + value);
}
if (value instanceof List)) {
log.error("xxx value " + value.get(0));
}
No need to check if the List isEmpty, as value is NULL, String or List (size = 0,1, n).
â Remold
PS happy to see your issue has been solved
ralfonse
(Rudolf Alfonse)
November 1, 2023, 10:15am
13
Great, Thanks for the tip!
system
(system)
Closed
December 31, 2023, 10:16am
14
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.