Discussion:
LDAP connector in passive to update an entry
(too old to reply)
a***@gmail.com
2020-03-05 14:24:09 UTC
Permalink
So I have the script and a passive lookup LDAP connector to get a selected attribute in LDAP back to the Data Flow:
var dn = "cn=pwdpolicy,cn=ibmpolicies";
var LDAPFilter = new Packages.com.ibm.di.server.SearchCriteria();
LDAPFilter.replaceCriteria("$dn", dn);

try{
var policyState = LDAPConnector.getConnector().findEntry(LDAPFilter).getString("ibm-PwdPolicy");
task.logmsg(" ibm-PwdPolicy : " + policyState);
} catch (error){
task.logmsg("Error during LDAP lookup for DN:" );
}

I am trying to get the syntax correct to call another passive LDAP connector in Update to update a single attribute on the same entry. The set of items , so far, has not been correct. This must have been done a few times before. Anyone care to share? Thanks
Eddie Hartman
2020-03-05 19:43:29 UTC
Permalink
Post by a***@gmail.com
var dn = "cn=pwdpolicy,cn=ibmpolicies";
var LDAPFilter = new Packages.com.ibm.di.server.SearchCriteria();
LDAPFilter.replaceCriteria("$dn", dn);
try{
var policyState = LDAPConnector.getConnector().findEntry(LDAPFilter).getString("ibm-PwdPolicy");
task.logmsg(" ibm-PwdPolicy : " + policyState);
} catch (error){
task.logmsg("Error during LDAP lookup for DN:" );
}
I am trying to get the syntax correct to call another passive LDAP connector in Update to update a single attribute on the same entry. The set of items , so far, has not been correct. This must have been done a few times before. Anyone care to share? Thanks
You're getting close. Try this:

var dn = "cn=pwdpolicy,cn=ibmpolicies";

// You don't need a SearchCriteria for a lookup, but here is the simplified
// code to make one for use with, for example, deleteEntry() or modEntry()
var LDAPFilter = system.newSearchCriteria();
LDAPFilter.addCriteria("$dn", LDAPFilter.EXACT, dn);

try{
// We use the convenient version of findEntry
var entry = LDAPConnector.connector.findEntry("dn", dn);
if (entry != null) {
var policyState = entry.getString("ibm-PwdPolicy");
task.logmsg(" ibm-PwdPolicy : " + policyState);
} else {
task.logmsg(" No policy found for: " + dn);
}
} catch (error){
// And let's add the error itself to the message
task.logmsg("Error during LDAP lookup for DN: " + error);
}

I often set a variable in the After Initialize Hook of my Passive Connector. That way my code is not dependent on the name of the AL component:

// thisConnector references the Connector whose Hook we are in
ldap = thisConnector.connector;

Hope this helps!
/Eddie

Loading...