Tutorials/CodeSamples/Login-Sample.md
... ...
@@ -10,6 +10,10 @@ This is a simple authentication function you can place in your Login page (Login
10 10
11 11
Normally, logins should be pulled from the database, active directory, or whatever system your organization uses for storing user info. We also support using your company's existing login page in place of our example login page. If nothing is available, here is a simple method to provide basic authentication. Also included is the callback function used by **btnLogin**'s "OnClick" property.
12 12
13
+In the global, you will need to define:
14
+
15
+AdHocSettings.SharedWithValues = new string[] { "Administrator", "Regular User" };
16
+
13 17
```csharp
14 18
Bool AuthenticateUser(string userName, string password, out bool isAdmin)
15 19
{
... ...
@@ -39,21 +43,21 @@ Bool AuthenticateUser(string userName, string password, out bool isAdmin)
39 43
void btnLogin_Click(object sender, EventArgs args)
40 44
{
41 45
loginValidator.IsValid = true;
42
- bool isAdmin;
43
- if (AuthenticateUser(userNameTextbox.Text, userPassword.Value, out isAdmin)) {
44
- AdHocSettings.CurrentUserName = userNameTextbox.Text;
45
- if (isAdmin)
46
- AdHocSettings.CurrentUserRoles = new string[] { "Admin" };
47
- else
48
- AdHocSettings.CurrentUserRoles = new string[] { "RegularUser" };
49
- global_asax.CustomAdHocConfig.InitializeReporting();
50
- Page.Title = "Izenda - " + Izenda.AdHoc.AdHocSettings.CurrentUserName;
51
- Response.Redirect("ReportList.aspx");
52
- //FormsAuthentication.RedirectFromLoginPage(userNameTextbox.Text, false);
53
- return;
54
- }
55
- else
56
- loginValidator.IsValid = false;
46
+bool isAdmin;
47
+if (AuthenticateUser(userNameTextbox.Text, userPassword.Value, out isAdmin)) {
48
+ Izenda.AdHoc.AdHocSettings.CurrentUserName = userNameTextbox.Text;
49
+ if (isAdmin)
50
+ {
51
+ Izenda.AdHoc.AdHocSettings.CurrentUserIsAdmin = true;
52
+ Izenda.AdHoc.AdHocSettings.CurrentUserRoles = new string[] { "Administrator" };
53
+ }
54
+ else
55
+ Izenda.AdHoc.AdHocSettings.CurrentUserRoles = new string[] { "Regular User" };
56
+ global_asax.CustomAdHocConfig.InitializeReporting();
57
+ FormsAuthentication.RedirectFromLoginPage(userNameTextbox.Text, false);
58
+ return;
59
+}
60
+loginValidator.IsValid = false;
57 61
}
58 62
```
59 63