Useful NW IDM Functions

Recently I needed to do two types of lookups for the prototype of a user creation script.  I was able to do both lookups rather easily using the uSelect function.  This is a function that is often overlooked, but one that really lets a NetWeaver IDM developer get the most out of the Identity Store.

First off, I needed to do a lookup against a “blacklist” of illegal ID’s  I was able to create a small table in the Identity Store database, gave it proper rights and then execute the following JavaScript code:

// First -- Check if AlphaPart is in the BlackList, if EvalBlackList > 0 then it's no good
// This means the item was found in the Blacklist
var BlackListQuery = "SELECT COUNT(*) FROM _Blacklist WHERE (BannedWord = " + "'" + AlphaPart +"')";
var EvalBlackList = parseInt(UserFunc.uSelect(BlackListQuery)); 
// if the current AlphaPart is in the Blacklist
if (EvalBlackList != 0){

Basically a query string needed to be constructed and then evaluated by uSelect.  The easiest way to check for a conflict is to use a SELECT COUNT type of query of the “Alphalist” variable against the Blacklist table.  If there is a value greater than 0, we have a conflict.  I then needed to do another query where I had to make sure that the new MSKEYVALUE did not conflict with existing values.  The same technique is used except this time we are going up against a view in the Identity Manager database

// Check if this value exists as an MSKEYVALUE
// NOTE IDENTITY STORE VALUE MUST BE HARD CODED!  NW IDM will not allow IDS Loopup via uGetIDStore outside of action tasks.
var IDSNumb = "1";
var MSKEYQuery = "SELECT COUNT(MSKEY)FROM MXIV_SENTRIES WHERE (IS_ID =" + IDSNumb + ") AND (AttrName = '" + "MSKEYVALUE" + "') AND (SearchValue LIKE '" + NewKey +"')";
var EvalMSKEY = parseInt(UserFunc.uSelect(MSKEYQuery));

This query was a little bit different as it needed some more elements involved.  First off, we need to hard code the Identity Store value.  There seems to be an issue with uGetIDStore if it is used outside of an action task.  I will be following up on this with folks at SAP.

// if the current NewKey is in the Identity Store
if (EvalMSKEY != 0){

Next interesting thing to note is that the query runs off of the MXIV_SENTRIES view. One might think that MXIV_ENTRIES would be the logical place to start, but it links into a lot of other tables, particularly audit tables which would slow up the script to an unacceptable degree.

I hope these techniques are useful to other NW IDM scripters out there.  My thanks to those engineers both in and out of SECUDE Global Consulting who helped out on this.  I’d be interested in seeing other people’s views on this issue and other scripting issues.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s