The login page provided by Izenda is a good starting point in implementing your
own, custom page. The page includes code which would allow the page to look-up a
login placed in a database table. We will review adding a hard-coded login to the
page and enabling that login in the Global.asax file. To add users and passwords
to the login.aspx page:
Editing Login.aspx
In the Login.aspx file, find the AuthenticateUser() method. There is a commented
code section which would allow looking up a user and password in the database. Add
a user name and password into the AuthenticateUser() method. Let's add the user
bob with password "bob" into the method:
bool AuthenticateUser(string userName, string password, out bool isAdmin)
{
if (userName == "bob" && password == "bob")
{
isAdmin = false;
return true;
}
isAdmin = false;
return false;
}
Unless you are using the database to hold user names and passwords, your AuthenticateUser()
method should now look like this. This code adds "bob" as a user and also sets the
isAdmin property to false. Notice that we return false for any other username or
password entered, and as a precaution, we also set the isAdmin property to false
as well. In the Login.aspx file, find the line "FormsAuthentication.RedirectFromLoginPage(userNameTextbox.Text,
false);" and comment it out to look like:
//FormsAuthentication.RedirectFromLoginPage(userNameTextbox.Text, false);
Add these lines underneath it:
Izenda.AdHoc.AdHocSettings.AdHocConfig.PostLogin();
Response.Redirect("ReportList.aspx");
You now should have:
//FormsAuthentication.RedirectFromLoginPage(userNameTextbox.Text, false);
Izenda.AdHoc.AdHocSettings.AdHocConfig.PostLogin();
Response.Redirect("ReportList.aspx");
These lines call the PostLogin() method and then redirect to the correct page after
its execution.
Editing Global.asax
Now that we have one user, we need to set configuration of Izenda Reports based
upon that user. Open your Global.asax file and find the PostLogin() method. By default,
this method is blank, now add the following code into the PostLogin() method, so
that it looks like this:
public override void PostLogin()
{
if (AdHocSettings.CurrentUserName == "bob")
{
Izenda.AdHoc.AdHocSettings.SqlServerConnectionString = "some connection string";
Izenda.AdHoc.AdHocSettings.VisibleTables = new string[] { "Orders" };
}
}
This code checks for bob as a user, and then sets the connection string and visible
tables for him. We could set other settings here if we want as well. Now we are
going to need to tell Izenda Reports to use a login page. We can do this in two
different ways. *Add the settings AdHocSettings.RequireLogin=true into the ConfigureSettings()
method of the Global.asax OR *Open your Settings.aspx page, click the "Security"
tab, and check the "Require Login" box.
Conclusion
You are now ready to use your login page.