
The following code snippet enables the SybaseCT Access Module to use external login authentication. It has a Database Callback class, UserSybDatabaseCallbackImp, which only redefines the producer method produceConnCallback() to create a new instance of the Connection Callback class, UserSybConnCallbackImp.
The Connection Callback class, UserSybConnCallbackImp, only redefines the preConnect() callback method to clear the username and password and set various login authentication properties.
This example does not provide an instance of the connection callback class in the method RWDBDatabase::connection(), as it is created from the connCallback() producer method in UserSybDatabaseCallbackImp class.
/////////////////////////////////////////////////////////////////////
//
// UserSybConnCallbackImp
//
/////////////////////////////////////////////////////////////////////
class UserSybConnCallbackImp : public RWDBConnCallbackImp {
public:
// Callbacks
virtual void preConnect();
};
void
UserSybConnCallbackImp::preConnect()
{
RWDBSybCtLibSystemHandle* sybCtSysH =
(RWDBSybCtLibSystemHandle*)systemHandle();
CS_CONNECTION* cs_conn = sybCtSysH->csconn();
// Clear username and password
ct_con_props(cs_conn, CS_CLEAR, CS_USERNAME,
NULL, CS_UNUSED, (CS_INT *)NULL);
ct_con_props(cs_conn, CS_CLEAR, CS_PASSWORD,
NULL, CS_UNUSED, (CS_INT *)NULL);
// Apply security services
CS_BOOL boolval = CS_TRUE;
ct_con_props(cs_conn, CS_SET, CS_SEC_NETWORKAUTH,
&boolval, CS_UNUSED, NULL);
ct_con_props(cs_conn, CS_SET, CS_SEC_MUTUALAUTH,
&boolval, CS_UNUSED, NULL);
ct_con_props(cs_conn, CS_SET, CS_SEC_CONFIDENTIALITY,
&boolval, CS_UNUSED, NULL);
ct_con_props(cs_conn, CS_SET, CS_SEC_INTEGRITY,
&boolval, CS_UNUSED, NULL);
ct_con_props(cs_conn, CS_SET, CS_SEC_DETECTREPLAY,
&boolval, CS_UNUSED, NULL);
ct_con_props(cs_conn, CS_SET, CS_SEC_DETECTSEQ,
&boolval, CS_UNUSED, NULL);
}
/////////////////////////////////////////////////////////////////////
//
// UserSybDatabaseCallbackImp
//
/////////////////////////////////////////////////////////////////////
class UserSybDatabaseCallbackImp : public RWDBDatabaseCallbackImp {
public:
// Connection callback producer
virtual RWDBConnCallback produceConnCallback();
};
RWDBConnCallback
UserSybDatabaseCallbackImp::produceConnCallback()
{
return RWDBCONNCALLBACK(UserSybConnCallbackImp);
}
/////////////////////////////////////////////////////////////////////
//
// main
//
/////////////////////////////////////////////////////////////////////
int main()
{
RWDBDatabase db = RWDBManager::database(
"ctl8015d.dll", "server", "", "", "",
RWDBDATABASECALLBACK(UserSybDatabaseCallbackImp));
RWDBConnection conn = db.connection();
return 0;
}
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.