API/CodeSamples/CurrentUserRoles.md
... ...
@@ -0,0 +1,37 @@
1
+#CurrentUserName
2
+
3
+[[_TOC_]]
4
+
5
+##About
6
+
7
+Gets or sets the roles of the current user. This is used to customize security based on roles already established client-side. It can be used in addition to a User ID and Tenant ID.
8
+
9
+In the following example, the user's role(s) are pulled from session. If the role of Power User is within their set of roles, they will be see the modify button but will not be allowed to delete reports.
10
+
11
+##Global.asax (C♯)
12
+
13
+```csharp
14
+//main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig
15
+public class CustomAdHocConfig : Izenda.AdHoc.DatabaseAdHocConfig
16
+{
17
+ // Configure settings
18
+ // Add custom settings after setting the license key and connection string by overriding the ConfigureSettings() method
19
+ public static void InitializeReporting() {
20
+ //Check to see if we've already initialized.
21
+ if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null)
22
+ return;
23
+ AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE";
24
+ //Creates a connection to Microsoft SQL Server
25
+ AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE";
26
+ AdHocSettings.AdHocConfig = new CustomAdHocConfig();
27
+ AdHocSettings.CurrentUserRoles = new string[] {(string)HttpContext.Current.Session["Role"]}; //The relevant setting
28
+
29
+ if (AdHocSettings.CurrentUserRoles.Contains("PowerUser")) //Role level security
30
+ {
31
+ AdHocSettings.ShowModifyButton=true;
32
+ AdHocSettings.AllowDeletingReports=false;
33
+ }
34
+ HttpContext.Current.Session["ReportingInitialized"] = true;
35
+ }
36
+}
37
+```
... ...
\ No newline at end of file