October 13, 2011
Iron Speed Designer V6.2 and later
Frequently it is useful to store information about the logged in user for subsequent use in your application. For example, you might maintain an “audit table” to track who logged into your application and when. Such information is conveniently stored in session variables and can be useful while creating an audit trail.
Follow these steps to access the User Name and Password of a signed-in user from within the Sign In control.
Step 1: In Iron Speed Designer, create an application using a database table, such as the Orders table in the Northwind database.
Step 2: Enable application security using the Application Security Wizard in Iron Speed Designer. Select “Grant Access only to signed-in users”.
Step 3: Add the following code to the SignIn_Control class, located in:
Security\SignIn.aspx.cs (.vb)
C#:
using System;
public SignIn()
{
this.Initialize();
this.Init += new EventHandler(SignIn_Init);
}
private void SignIn_Init(object sender, System.EventArgs e)
{
this.LoginSucceeded += SignIn_ LoginSucceeded;
}
private void SignIn_ LoginSucceeded(object sender,System.EventArgs e)
{
string myUserName = this.UserName.Text;
string myPassword = this.Password.Text;
//
// Now you can use UserName and Password
// You can add more code customization
//
}
Visual Basic .NET:
Security\SignIn.aspx.vb
Protected Sub Page_LoginSucceeded1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoginSucceeded
'Access UserName and Password
Dim myUserName As String = Me.UserName.Text
Dim myPassword As String = Me.Password.Text
'Now you can use UserName and Password
'You can add more code customization
End Sub
You also can handle LogEvent which is fired before and after login and logout and has arguments which have information about the user ID, user name and ability to cancel event.
See Customizing Application Security for details.
Step 4: Build and run your application.
Customizing Application Security
Implementing Custom User Authentication
Example: Overriding Security at the Page Level
Example: Programmatically Accessing the Currently Logged-in User
Example: Access User Name and Password from Sign In Control
Example: Allow Only Active Users to Login
Example: Encrypting Passwords Before Saving to the Database
Example: Restrict Login after Incorrect Password Used