// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // Event: UE_Login // // Arguments: None // // Returns: Integer ( 1 - Success , -1 - Failure ) // // Description: This script takes the environment entered and reads up the transaction // object information for that environment from the appropriate ini file. // Using that information along with the logid and logpass entered, it // THEN logs into the database. // // //======================================================================================== // // Copyright © 2001 - 2010 Dynamic Group. All Rights Reserved. // Any distribution of this source code by other than the // Dynamic Group is prohibited. // //======================================================================================== // Revision History: ( Ref.ID = defect id or enhancement id ) // RH# Ref.ID Date Who What // --- ------ ----------- ----- ----------------------------- // #1 11-Oct-2001 SBHoo Initial Version // #2 19-Feb-2002 KOH Version Control // #3 21-Jun-2002 KOH RegisterKey Control // #4 11-Dec-2006 SBHoo Get DB User and Password from registry // Login ID should consider application user , // not DB user // #5 07-Jul-2007 Caine Enable back version control. // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // String ls_environment , ls_tmpstring , ls_messagetext , ls_dbparm, ls_password, ls_login_reg, ls_login_reg_dec, & ls_password_reg, ls_password_reg_dec, ls_enterlogpass_enc Integer li_pos1 , li_pos2 , li_cnt n_cst_encryption lnv_encrypt SetPointer(HourGlass!) dw_1.AcceptText() // get the selected environment ls_environment = dw_1.GetItemString(1, "enterenvironment") // If no environment available THEN stay on login screen IF NOT Len(ls_environment) > 0 THEN dw_1.SetFocus() RETURN -1 END IF // add the keyword profile in front of environment ls_environment = "Profile " + ls_environment gnv_app.is_password = dw_1.GetItemString(1, "EnterLogPass") gnv_app.is_userid = dw_1.GetItemString(1, "EnterLogID") //Caine - 2-Apr-2007 - Get UserID and Password from Registry RegistryGet("HKEY_LOCAL_MACHINE\SOFTWARE\Dynamic Group\FBPOS", "LOGIN", RegString!, ls_login_reg) RegistryGet("HKEY_LOCAL_MACHINE\SOFTWARE\Dynamic Group\FBPOS", "PASSWORD", RegString!, ls_password_reg) lnv_encrypt = CREATE n_cst_encryption ls_login_reg_dec = lnv_encrypt.Uf_Decrypt(ls_login_reg) ls_password_reg_dec = lnv_encrypt.Uf_Decrypt(ls_password_reg) //Encrypt the password. Because the application use is encrypted in database. IF NOT IsNull(gnv_app.is_password) AND gnv_app.is_password <> "" THEN ls_enterlogpass_enc = lnv_encrypt.Uf_Encrypt(gnv_app.is_password) END IF DESTROY lnv_encrypt // //Caine - 2-Apr-2007 //IF Lower(gnv_app.is_userid) = "sa" THEN // SQLCA.userid = gnv_app.is_userid // SQLCA.dbpass = gnv_app.is_password //ELSE // //Encrypt the password. Because the application use is encrypted in database. // IF NOT IsNull(gnv_app.is_password) AND gnv_app.is_password <> "" THEN // lnv_encrypt = CREATE n_cst_encryption // gnv_app.is_password = lnv_encrypt.Uf_Encrypt(gnv_app.is_password) // DESTROY lnv_encrypt // END IF //END IF SQLCA.userid = ls_login_reg_dec IF gnv_app.is_userid = ls_login_reg_dec THEN SQLCA.dbpass = gnv_app.is_password ELSE SQLCA.dbpass = ls_password_reg_dec END IF // // ** Key Control Expiry,Version... ** //#3 // No need to have this control //IF st_demo.text <> "" THEN // ln_ncode = CREATE n_cst_n_code // ls_key = ProfileString(gnv_app.is_inifile, "Application", "RegisterKey", "") // IF ln_ncode.uf_chk_key(ls_key, This.st_version.Text) = FALSE THEN // SetProfileString(gnv_app.is_inifile, "Application", & // "RegisterKey", "gyvyjsiindN)7NESKvYnmK5mm17") // dw_1.SetFocus() // RETURN -1 // END IF // DESTROY ln_ncode //#3 //END IF // load the transaction object with values from the ini file and // from the login window SQLCA.DBMS = ProfileString(gnv_app.is_inifile, ls_environment, "DBMS", "") SQLCA.Database = ProfileString(gnv_app.is_inifile, ls_environment, "Database", "") SQLCA.ServerName = ProfileString(gnv_app.is_inifile, ls_environment, "ServerName", "") SQLCA.Lock = ProfileString(gnv_app.is_inifile, ls_environment, "Lock", "") ls_dbparm = ProfileString(gnv_app.is_inifile, ls_environment, "DBParm", "") li_pos1 = Pos(ls_dbparm, "UID=") IF li_pos1 = 0 THEN MessageBox("Invalid INI Entry", "Invalid DBPARM setting in " + gnv_app.is_inifile + " file, please contact your system support.") RETURN -1 END IF li_pos2 = Pos(ls_dbparm, ";", li_pos1) IF li_pos2 = 0 THEN li_pos2 = Pos(ls_dbparm, "'", li_pos1) END IF IF li_pos2 = 0 THEN MessageBox("Invalid INI Entry", "Invalid DBPARM setting in " + gnv_app.is_inifile + " file, please contact your system support.") RETURN -1 END IF ls_dbparm = Replace(ls_dbparm, li_pos1 + 4, li_pos2 - (li_pos1 + 4), SQLCA.userid) li_pos1 = Pos(ls_dbparm, "PWD=") IF li_pos1 = 0 THEN MessageBox("Invalid INI Entry", "Invalid DBPARM setting in " + gnv_app.is_inifile + " file, please contact your system support.") RETURN -1 END IF li_pos2 = Pos(ls_dbparm, ";", li_pos1) IF li_pos2 = 0 THEN li_pos2 = Pos(ls_dbparm, "'", li_pos1) END IF IF li_pos2 = 0 THEN MessageBox("Invalid INI Entry", "Invalid DBPARM setting in " + gnv_app.is_inifile + " file, please contact your system support.") RETURN -1 END IF IF NOT (IsNull(SQLCA.dbpass) OR Trim(SQLCA.dbpass) = "") THEN ls_dbparm = Replace(ls_dbparm, li_pos1 + 4, li_pos2 - (li_pos1 + 4), SQLCA.dbpass) END IF SQLCA.DBParm = ls_dbparm ls_tmpstring = Lower(ProfileString(gnv_app.is_inifile, ls_environment, "AutoCommit", "")) IF ls_tmpstring = "1" OR ls_tmpstring = "yes" OR ls_tmpstring = "true" THEN SQLCA.AutoCommit = TRUE ELSE SQLCA.AutoCommit = FALSE END IF // *********************************************************************** // Disconnect any previous connections and clear the current user. // *********************************************************************** DISCONNECT USING SQLCA; // *********************************************************************** // If the login was unsuccessful, inform us why the connect failed. // *********************************************************************** CONNECT USING SQLCA; IF SQLCA.SQLDBCode = -103 THEN MessageBox("Login Error", "Invalid Login ID or Password", StopSign!) dw_1.SetFocus() RETURN -1 ELSEIF SQLCA.SQLDBCode <> 0 THEN MessageBox("Login Error" , "Unabled to connect to database" , StopSign!) dw_1.SetFocus() RETURN -1 END IF //#2 - Version Control //ID#5 Start IF NOT uf_version_control(This.st_version.Text) THEN dw_1.SetFocus() RETURN -1 END IF //ID#5 End //Caine - 2-Apr-2007 //IF Lower(gnv_app.is_userid) <> "sa" THEN IF Lower(gnv_app.is_userid) <> Lower(ls_login_reg_dec) THEN // // Check whether login user is valid //Caine - 2-Apr-2007 //IF gnv_app.Uf_Verify_Login(gnv_app.is_userid , gnv_app.is_password) <> 1 THEN IF gnv_app.Uf_Verify_Login(gnv_app.is_userid , ls_enterlogpass_enc) <> 1 THEN // MessageBox("Login Error", "Invalid Login ID or Password", StopSign!) dw_1.SetFocus() RETURN -1 END IF // Check User Account whether has been expired. IF gnv_app.Uf_Is_ActiveUser(gnv_app.is_userid) = FALSE THEN MessageBox("Access Denied" , "Your account has been inactive.") dw_1.SetFocus() RETURN -1 END IF //ELSE // IF Lower(gnv_app.is_userid) <> "sa" THEN END IF // Set the current user gnv_app.is_dsn = dw_1.GetItemString(1, "enterenvironment") // save the login info for use as defaults on next login SetProfileString(gnv_app.is_inifile, "Application", "DefaultLogID", dw_1.GetItemString(1, "enterlogid")) SetProfileString(gnv_app.is_inifile, "Application", "DefaultEnvironment", dw_1.GetItemString(1, "enterenvironment")) CloseWithReturn(This, 1) RETURN 1