API/CodeSamples/CurrentUserName.md
... ...
@@ -0,0 +1,56 @@
1
+#CurrentUserName
2
+
3
+[[_TOC_]]
4
+
5
+##About
6
+
7
+Gets or sets the name of the current user. This is required for multi-user security.
8
+
9
+##Global.asax (C♯)
10
+
11
+```csharp
12
+//main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig
13
+public class CustomAdHocConfig : Izenda.AdHoc.DatabaseAdHocConfig
14
+{
15
+ // Configure settings
16
+ // Add custom settings after setting the license key and connection string by overriding the ConfigureSettings() method
17
+ public static void InitializeReporting() {
18
+ //Check to see if we've already initialized.
19
+ if (HttpContext.Current.Session == null || HttpContext.Current.Session["ReportingInitialized"] != null)
20
+ return;
21
+ AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE";
22
+ //Creates a connection to Microsoft SQL Server
23
+ AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE";
24
+ AdHocSettings.AdHocConfig = new CustomAdHocConfig();
25
+ HttpContext.Current.Session["ReportingInitialized"] = true;
26
+ }
27
+
28
+ public override void PostLogin() {
29
+ AdHocSettings.CurrentUserName = (String)HttpContext.Current.Session["UserName"];
30
+ }
31
+}
32
+```
33
+
34
+##Global.asax (VB.NET)
35
+
36
+```visualbasic
37
+'main class: inherits DatabaseAdHocConfig or FileSystemAdHocConfig
38
+Public Class CustomAdHocConfig
39
+ Inherits Izenda.AdHoc.DatabaseAdHocConfig
40
+
41
+ Shared Sub InitializeReporting()
42
+ 'Check to see if we've already initialized
43
+ If HttpContext.Current.Session Is Nothing OrElse HttpContext.Current.Session("ReportingInitialized") IsNot Nothing Then
44
+ Return
45
+ 'Initialize System
46
+ AdHocSettings.LicenseKey = "INSERT_LICENSE_KEY_HERE"
47
+ AdHocSettings.SqlServerConnectionString = "INSERT_CONNECTION_STRING_HERE"
48
+ AdHocSettings.AdHocConfig = New CustomAdHocConfig()
49
+ HttpContext.Current.Session("ReortingInitialized") = True
50
+ End Sub
51
+
52
+ Public Overrides Sub ConfigureSettings()
53
+ AdHocSettings.CurrentUserName = HttpContext.Current.Session("UserName").ToString()
54
+ End Sub
55
+End Class
56
+```
... ...
\ No newline at end of file