| Home | Previous Lesson: Multiple Login Attempts Functionality Next Lesson: Menu Services |
Some times�say you want to invoke your application from another application using that application's login attributes�you may want to logon automatically and skip the logon window. Well, you can implement this functionality easily.
The following example assumes login id and password are sent to this application from the commandline separated by a space.
// Ex: pms.exe loginID1 Password1
// Object: n_cst_pms_appManager
// Event: pfc_open
int li_rc
this.of_Splash(1)
Idle(300)
Yield()
open(w_mdi_frame)
// Check if the userid and password were sent from the command line
IF IsNull (as_commandline) THEN
as_commandline = ""
END IF
// parse and get the userid and password into separate variables.
ls_userid = Trim (inv_string.of_GetToken (as_commandline, " "))
ls_password = Trim (inv_string.of_GetToken (as_commandline, " "))
// do the standard login, if either userid or password is not supplied.
IF ls_userid = "" OR ls_password = "" THEN
li_return = this.of_LogonDlg()
return
END IF
this.of_SetUserID (ls_userid)
li_return = this.Trigger Event pfc_Logon (ls_userid, ls_password)
if li_return <> 0 then
this.of_LogonDlg()
else
if of_IsRegistryAvailable() then
RegistrySet (is_userkey + "\logon", "userid", ls_userid)
else
SetProfileString (is_userinifile, "logon", "userid", ls_userid)
end if
of_SetUserID(ls_userid)
end if
The above code is checking whether userid and password are passed on the commandline or not. If not provided, it is going through the regular login by calling of_LogonDlg(). Otherwise, it is calling the pfc_logon event with the userid and password. If that login is successful, then it is storing the userid in registry/profile that will be used as the default for the next login. If pfc_logon event fails for whatever is the reason, we are again going through the standard PFC login.
On a final note on this topic, when you deploy, make sure to deploy registry settings. It is your responsibility to provide an interface to allow the user to change settings such as connecting to various production boxes, etc.
| Home | Previous Lesson: Multiple Login Attempts Functionality Next Lesson: Menu Services |