开发者

PowerBuilder application login

开发者 https://www.devze.com 2023-04-03 06:41 出处:网络
I am using PowerBuilder PFC library to login to the databa开发者_运维百科se. n_cst_appmanager/ pfc_open:

I am using PowerBuilder PFC library to login to the databa开发者_运维百科se.

n_cst_appmanager/ pfc_open:

IF this.of_LogonDlg() > 0 THEN
    Open(w_myapp_frame)
END IF

n_cst_appmanager/ pfc_logon:

SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = False
SQLCA.DBParm = "ConnectString='DSN=mytestdb;UID=" + as_userid + ";PWD=" + as_password + "'"
connect using SQLCA;

Now, once the user is logged in, there are few situations that I will need to connect to another database (for example, to copy some data there), so I would like to connect to the other database automatically, without displaying the login window again, therefore I would need to save the username and password of the user. How can I save it? Do I need to save in the registry? Can you give some example please?

For example, I can get the user id in following way:

s_userid = gnv_app.of_GetUserID()

But I can not get the password. Can someone please help me how i can do it? Thanks a lot.


Actually, now that I'm paying attention to what you need instead of what you asked for <g>, and riffing off of Hugh's answer, why not just copy the transaction object?

n_cst_String lnv_String

ltr_NewConnect.DBMS = SQLCA.DBMS
ltr_NewConnect.AutoCommit = SQLCA.AutoCommit
ltr_NewConnect.DBParm = lnv_String.of_GlobalReplace (SQLCA.DBParm, "mytestdb", "myotherdb")

If I were doing this, I'd code a copy of all the transaction object fields, just in case the means of defining the connection changes.

I'm assuming the other database is the same type of database in order for this to make sense (so that it uses the same type of DBParm), but either way the principle may apply.

Good luck,

Terry.


There's nothing built into PFC and there's nothing automagic in PowerBuilder that will help you with this. Just create an instance variable and a function to access it. Maybe grab the n_cst_LogonAttrib from the Message.PowerObjectParm immediately after the call to of_LogonDlg() and grab the value from there. Or, further extend your n_cst_AppManager.pfc_Logon event. Or extend of_LogonDlg(), and model the capture after the way PFC does the user id.

Note that storing the password anywhere permanent and visible to other processes like the registry would be a security violation that many companies would not allow. Not a direction you want to go.

Good luck,

Terry.


You can parse them out of SQLCA.DBParm.

string ls_userID, ls_password
n_cst_string stringSrv

ls_userID = stringSrv.of_getKeyValue(SQLCA.DBParm, "UID", ";")
ls_password = stringSrv.of_getKeyValue(SQLCA.DBParm, "PWD", ";")

However, a good case can be made for capturing them in the appmanager if you know you will need them.

Having the same login credentials for different databases is a security concern. It's the sort of thing that leads to your company being in the news for the wrong reasons.

0

精彩评论

暂无评论...
验证码 换一张
取 消