Sreekumar,
I believe that it is because you have not yet CONNECTED to the database via
SQLCA at the point that you are trying to initialize security.
Some examples tell you to put the security code in the pfc_open event, but
that only works if you are connecting to the database in that event... And
of course, even then, you need your security code after the connect is
successful.
The example in the PB Help says: "Establish a transaction object for the
security database. This example assumes an itr_sec instance variable of
type n_tr on n_cst_appmanager: itr_sec = CREATE n_tr CONNECT using
itr_sec;"
But of course that is if you choose to have your security access through a
separate transaction... And that leaves out a lot of details of other
stuff you need to do if you go that route.
In many of the apps that I have worked with, we did not connect in the
pfc_open event, and we simply used SQLCA... Below is some sample code of
how we put our code in the pfc_logon event instead.
Good Luck, and let us know if this is or is not your problem.
Have fun,
~Sharon
--
Sharon Weinstrom Buntz | mailto:[EMAIL PROTECTED]
Cheat Sheet for PFC/PB Help | http://www.pfccheatsheet.com/
In our PFE's pfc_logon:
////////////////////////////////////////////////////////////////////////////
// NOTE: Ancestor is extended!!
//
//////////////////////////////////////////////////////////////////////////<snip
of of_SetError stuff>
SQLCA.of_SetUser (as_userid, as_password)
// Sreekumar - here is where we are connecting to the database
IF SQLCA.of_Connect() >= 0 then
<snip of error of_SetPredefinedSource(SQLCA)>
RETURN 1
ELSE
<snip of handling error on connect>
RETURN -1
END IF
In each of our app's pfc_logon:
//////////////////////////////////////////////////////////////////////////
//
// NOTE: Ancestor is overridden!!
//
//////////////////////////////////////////////////////////////////////////
int li_rc
li_rc = Super::EVENT pfc_logon(as_userid, as_password)
IF li_rc <> 1 THEN RETURN li_rc // If ancestor fails, bail out
this.of_SetSecurity (TRUE)
li_rc=this.inv_security.of_InitSecurity (SQLCA, "<app>", as_userid,
"<grp>")
...
gnv_app.inv_security.of_SetSecurity(gnv_app.of_getframe())
RETURN 1
[EMAIL PROTECTED] wrote:
>
> Hi all.
> I am trying to use the PFC Security module; however I am unable to
> initialise security.
> gnv_App.inv_security.of_initSecurity(SQLCA, iapp_object.appname,
> of_getUserId(), "default")
> returns -1
> isvalid(gnv_App.inv_security) returns true ; SQLCA has been set to be n_tr ;
>
> iapp_object.appname correctly returns the name of the current app which is
> also present in the security_apps table;
> of_getUserId correctly returns the name of the current user (present in
> security_users); a
> "default" user is also present in security_apps.
>
> What could be going wrong?
>
> Thanx for any help.
> Sreekumar
> [EMAIL PROTECTED] HOSTED BY IIGG, INC. FOR HELP WITH LIST SERVE COMMANDS, ADDRESS
> A MESSAGE TO [EMAIL PROTECTED] WITH THE FOLLOWING MESSAGE: help pfcsig
> SEND ALL OTHER INQUIRES TO [EMAIL PROTECTED]