Dialog Box for User Sign-in
IN THIS PAGE
Description
The following Xdialog script was submitted by Tom Henkel, Senior Systems Analyst Bergen County Board of Social Services. This sample is part of the code used to control access to a large (300+ user) network of Alpha Anywhere users.
Dialog Box Code
************* Dialog Box for User Sign-in *****************
******* Dialog Box Code *********
userid = ""
passwd = ""
f = file.open(aa.bcbss.path+"\bcbss\bergen2.bmp",FILE_RO_SHARED)
UI_BITMAP_LOAD( "BCBSS",F.READB(10000000) )
f.close()
rslt = ui_dlg_box(aa.bcbss.agency+" - Security",<<%dlg%
{frame=1,1}
{region}
{sp=20}{image=BCBSS};
{sp=3} Welcome to the {text=38aa.bcbss.agency};
{lf};
Before proceeding, You Must Enter YOUR User-ID and Password
{lf};
{endregion};
{lf};
{frame=1,1:Please Sign In}
{region}
{lf};
{sp=10} Enter User-ID: |[10.6userid] ;
{lf};
{sp=10} Enter Password: |[%p%10.6passwd] ;
{lf};
{tab};
{endregion};
{lf};
{frame=1,1}
{region3}
{sp=10} <10&OK ?.not.(userid="")> {sp=4} <10&Exit>
{endregion3}
%dlg%, <<%b%
IF a_dlg_button = "&Exit"
'get out
A5.close()
END IF
%b%)Code to Test the Validity of User ID and Password
************* Code to test validity of user-id and password ***************
dim tbl_secure as P
TBL_SECURE = table.open("secure2.dbf")
TBL_SECURE.index_primary_put("User")
recno = TBL_SECURE.fetch_find( UT(userid) )
IF recno < 1
ui_msg_box(aa.bcbss.agency + " - Security Error", "Invalid User Code Entered",16)
userid=" "
passwd=" "
trys = trys + 1
IF trys < 4 THEN
goto tryagain
ELSE
ui_msg_box(aa.bcbss.agency + " - Security Error", "Too many tries, Application Closing")
A5.Close()
END IF
ELSE
trys = 0
if tbl_secure.active = "X" THEN
ui_msg_box(aa.bcbss.agency + " - Security Error","This User - " + tbl_secure.User+ " - is already signed onto the System",16)
userid=" "
passwd=" "
trys = trys + 1
IF trys < 4 THEN
goto tryagain
ELSE
ui_msg_box(aa.bcbss.agency + " - Security Error", "Too many tries, Application Closing")
A5.Close()
END IF
ELSE
IF trim( upper(PASSWD) ) <> trim( upper(tbl_secure.passwd) )
ui_msg_box(aa.bcbss.agency+" - Security Error", "Invalid PASSWORD Entered ",16)
userid=" "
passwd=" "
trys= trys + 1
IF trys < 4
goto tryagain
ELSE
ui_msg_box(aa.bcbss.agency + " - Security Error", "Too many tries, Application Closing")
A5.close()
END IF
ELSE
IF tbl_secure.mode_get()> 0 THEN
GOTO BYPASS1
ELSE
TBL_SECURE.change_begin()
tbl_secure.active = "X"
tbl_secure.activetime = time()
TBL_SECURE.change_end(.T.)
END IFCode to Force the User to Change Password
*********** Code to force user to change password using another xdialog box ******
BYPASS1:
trys = 0
IF DATE()>=ADDMONTHS(tbl_secure.PWDDATE,2) THEN
looper2:
rslt1 = ui_dlg_box(aa.bcbss.agency+" - Security",<<%dlg%
{frame=1,1}
{region}
{sp=3} Your Current Password Has Expired;
{lf};
You Must Enter a NEW Password and VERIFY it. {sp=5}
{lf};
{endregion};
{lf};
{frame=1,1:Please Enter your New Password}
{region}
{lf};
{sp=10} Enter Password: |[%p%10.6pwd1] ;
{lf};
{sp=7} Re-Enter Password: |[%p%10.6pwd2] ;
{lf};
{tab};
{endregion};
{lf};
{frame=1,1}
{region3}
{sp=10} <10&OK> {sp=4} <10&Exit>
{endregion3}
%dlg%, <<%b%
IF a_dlg_button = "&Exit"
'get out
A5.close()
END IF
%b%)Code to test if the New Password Just Changed.
***************** Code to test new password just Changed ********************
'Now test that passwords were entered
IF PWD1 = "" .or. PWD1 = "******" THEN
ui_msg_box("ERROR on PASSWORD", "You MUST enter SOMETHING...")
trys = trys + 1
IF trys < 4
pwd1 = ""
pwd2 = ""
GOTO looper2
ELSE
ui_msg_box(aa.bcbss.agency + " - Security Error", "Too many tries, Application Closing")
A5.close()
END IF
END IF
IF PWD2 = "" .or. PWD2 = "******" THEN
ui_msg_box("ERROR on Re-Enter of Password","You MUST enter SOMETHING...")
trys = trys + 1
IF trys < 4
pwd1 = ""
pwd2 = ""
GOTO looper2
ELSE
ui_msg_box(aa.bcbss.agency+" - Security Error", "Too many tries, Application Closing")
A5.close()
END IF
END IF
IF PWD1 <> PWD2 THEN
ui_msg_box("PASSWORD ERROR", "New Passwords Do NOT Match... Re-enter",16)
trys = trys + 1
IF trys < 4
pwd1 = ""
pwd2 = ""
GOTO looper2
ELSE
ui_msg_box(aa.bcbss.agency+" - Security Error","Too many tries, Application Closing")
A5.close()
END IF
ELSE
IF trim(PWD1) = trim(passwd) THEN
ui_msg_box("PASSWORD", "NEW Password cannot match OLD Password... Try Again",16)
trys = trys + 1
IF trys < 4
pwd1 = ""
pwd2 = ""
GOTO looper2
ELSE
ui_msg_box(aa.bcbss.agency + " - Security Error","Too many tries, Application Closing")
A5.close()
END IF
END IF
TBL_SECURE.change_begin()
tbl_secure.passwd = PWD1
tbl_secure.pwddate = date()
TBL_SECURE.change_end(.T.)
ui_msg_box("PASSWORD","Password Changed Successfully",16)
END IF
ELSE
END IF
END IF
END IF
'define global variable for access
access = tbl_secure.access
level = tbl_secure.type
'define super-global variable for access
aa.bcbss.access = tbl_secure.access
aa.bcbss.level = tbl_secure.type
aa.bcbss.agency = agency
a5.show()

