Hello all
I am trying to develop a custom connector in connector xpress that is used to connect to a sql database and retrieve values from a table.
The table consists of three columns (username, rolename and appl). The appl column can have three values (new, Groups and Claims). Depending on the appl value the account is created for a different application. So, for my use case the appl value is set by default to Groups (all other accounts should be ignored). I created a doLookup function that runs instead of LOOKUP as follows:
importPackage(java.io)
importClass(java.lang.System)
importClass(java.util.Arrays)
importClass(java.sql.Connection)
importClass(java.sql.Statement)
importClass(java.sql.ResultSet)
importClass(Packages.com.ca.jcs.Connector)
importClass(Packages.com.ca.jcs.ConnectionManager)
importClass(Packages.javax.sql.DataSource)
importClass(Packages.com.ca.jcs.processor.script.ScriptStyleOpProxyHandler)
importClass(Packages.javax.naming.directory.BasicAttributes)
// ------------------------------------------------
function doLookupAccount( objInfo, returningAttrs)
{
if (connector.logger.isDebugEnabled())
connector.logger.debug("Do LOOKUP Operation From OPBINDINGS " + objInfo.getName() + " - returningAttrs=" + Arrays.toString(returningAttrs));
var attrs = new BasicAttributes(true);
var connMgr;
var sqlSrvConnection;
try {
connMgr = connector.getConnectionManager();
sqlSrvConnection = connMgr.borrowConnection();
var statement = sqlSrvConnection.createStatement();
var query = "select * from roleusersdb where appl= 'Groups' and username ='" + objInfo.getName() + "'";
var results = statement.executeQuery(query);
var accountID;
var rolename;
var appl;
if (results.next()) {
accountID = results.getString("username").trim();
rolename = results.getString("rolename").trim();
appl = results.getString("appl").trim();
}
attrs.put("username", accountID);
attrs.put("rolename", rolename);
attrs.put("appl", appl);
} catch(x) {
throw x;
} finally {
connMgr.returnConnection(sqlSrvConnection);
}
return attrs;
}
My issue with this code is when i run the explore. Basically if an account has appl = Groups the account is fetched correctly, but if appl /= Groups the account is fetched again with rolename and appl equals to undefined. I don't want these accounts to be fetched in IAM when using this connector.
Any ideas ?
Thank you
Gerasimos