I am trying to dynamically set the RuntimeUserID and RuntimePassword to a specific
datasource depending upon the user.
I have tried the following:
1. To set the datasource parameters in the onBeforeExecuteEvent of the dataobject
using the set runtimeUserID and setRuntimeUserPassword. This does not work
consitently with multiple users.
CSpRequest request = event.getDBRequest();
CSpDBConnection dcThis = request.getDBConnection();
CSpDataSource dsTest2 = dcThis.getDataSource();
dsTest2.setRuntimeServer(sDBName);
dsTest2.setRuntimeUserID(sUserID);
dsTest2.setRuntimePassword(sPassword);
dcThis.setDataSource(dsTest2 );
request.setDBConnection(dcThis);
2.To set the CSpLogin element in the Hashtable of the CSpUserProfile in the
onBeforeExecuteEvent of the DataObject.
It seems I am missing something because the userID and password are not being used by
the datasource.
{
CSpUserProfile userProfile = CSpider.getUserProfile();
userProfile.setSecurityObjectActivated(false\true);
CSpHashTable chtLogins = userProfile.getDBUserLogin();
if (chtLogins.size() > 0)
{
CSpLogin userLogin = (CSpLogin) chtLogins.get("dsThis");
userLogin.setUserId( sUserID);
userLogin.setPassword(sPassword);
chtLogins.put("dsThis",userLogin);
userProfile.setDBUserLogin(chtLogins);
}
else
{
CSpLogin newUserLogin = new CSpLogin(sUserID,sPassword);
userProfile.addDBUserLogin("dsThis", newUserLogin);
}
CSpider.setUserProfile(userProfile);
}
catch(Exception ex)
{
CSpLog.send(this, CSpLog.ERROR, "Exception in setLoginProfile"
+ ex);
}
Any sugestions would be greatly appreciated!
_________________________________________________________________________
For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
For dire need help, email: [EMAIL PROTECTED]