SecureLogin Scripting Techniques
Novell Cool Solutions: Feature
Reader Rating
from 1 ratings
|
Digg This -
Slashdot This
Posted: 5 May 2005 |
Note: This article is based on BrainShare TUT248.
About SecureLogin Scripting
SecureLogin automatically logs a user in to an application. A SecureLogin script can be used to define the Login dialog for an application, including the insertion of the user ID and password. Scripting determines the rules behind what to type in, where and when. Basically, it provides a set of logical commands for putting the ID and Password into an application.
Here's the basic script scenario:
- First, the script looks for an application.
- When the application starts, it looks for a login page.
- The script must pass the ID and Password into the application's login page.
- Title
- Text
- Username
- Password
- OK
- Cancel
Figure 1 - Login Screen dialog
Basic Scripting Techniques
Using the WinSSO Window Finder tool we can see the following:
- Title - Log in
- Username - Ctrl 1001
- Password - Ctrl 1002
- OK - Ctrl #1
- Cancel - Ctrl #2
- Window Class - #32770
A sample script for the log in dialog would be as follows:
Dialog
Class "#32770"
Title "Log in"
Ctrl #1
Ctrl #2
EndDialog
Now we have identified the screen we need to insert the username, insert the password, and click OK. We already know the Field identifiers for Username, Password and OK, so the script would be expanded with:
Type $Username #1001
Type $Password #1002
Click #1
Note that the "$" symbol indicates that the value is stored within eDirectory.
More Scripting Techniques
Each NSL script should contain a number of standard sections:
- Win32
- Emulator
- Web
- Java
Each section should contain the following elements:
- Script Header
- Login Dialog
- Change Password Dialog
- Password Expiration
- Log In Failure
- Login success - mostly in Terminal Emulation
- Other Message Detection
1. Script Header
At the start of each script, include a header such as this one:
############################################# # # Application : # # Application Description : # # Initial Script created on : # by : # ############################################# # # Modification Log # # Modified By - Date (yyyymmdd) - Description # # e.g. David Guest - 20040302 - Initial Script Creation # #############################################
2. Login Dialog
The script needs to respond to the Login Dialog by detecting Login Screen, completing the details, and submitting them. For example:
#Begin Login In Dialog Recognition and response Dialog Class "#32770" Title "Log in" EndDialog Setprompt "Username:" Type $Username #1001 Setprompt "Password:" Type $Password #1002 SetPrompt ?Please enter credentials for Application? Click #1
3. Change Password
Change Passwords must be managed in the script. Here is an sample Change Password section:
Dialog Class "#32770" Title "Change Password" EndDialog Type "$Username" #1015\ Type "$password" #1004 ChangePassword ?NewPassword Type ?NewPassword #1005 Type ?NewPassword #1006 Click #1 Set $Password ?NewPassword
Figure 2 - Change Password dialog
4. Password Expiry
If the application supports password expiry, there are two typical approaches: a single Message Box with Old Password, New Password, and Confirmation; or Dual Message Boxes (Old Password and New Password) and the Confirmation. The script routine to change the password should be similar to the change password section. Remember each Dialog must be handled separately.
5. Login Failure
What happens if the login attempt fails? An error dialog appears, and then control passes either to the original window, with no update, or a new login window. Each must be handled differently. For example:
Dialog
Class ?#32770?
Title ?Logon Failure?
EndDialog
DisplayVariables ?Your login attempt has failed. Please confirm your Username and Password.? $Username $Password
Click #2
Type -Raw $Username
Type -Raw \T
Type -Raw $Password
Type -Raw \N
To catch repeated failures, make sure that the script does not loop. Determine how many attempts the user should be allowed, count the failures, and keep the user informed. Eventually the application should be closed after repeated login failures. For example:
Dialog
Class ?#32770?
Title ?Logon Failure?
EndDialog
Increment ?FailCount
If ?FailCount lt 3
DisplayVariables ?Your logon attempt has failed. Please confirm
your Username and Password.? $Username $Password
Click #2
Else
MessageBox ?The Username and password are still incorrect.
Please contact the help desk for more details.?
KillApp ?AppTester.exe?
EndScript
EndIf
6. Login Success
Tracking login success is used extensively with Terminal Emulation, including Generic or Advanced Emulators. Once you detect when the user has succesfully logged in, you can reset counters and break out of Repeat/EndRepeat loops.
7. Detecting Other Messages
The other types of messages that the script may need to detect include:- Application Messages
- Foreign Language
- Future Password Expiry
- Advisory Technical Messages
- Standard Information Dialog
For example:
Dialog
Class ?#32770?
Title ?Information?
EndDialog
ReadText #65535 ?Message
If ?Message eq ?Welcome to the application?
Click #1
EndIf
If ?Your password will expire in? -In ?Message
Click #2
Endif
If ?The system is going down for maintenance in 5 minutes?
MessageBox ?Watch out the system is going down very soon?
EndIf
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com
