Integration/Security-Basics.md
... ...
@@ -0,0 +1,78 @@
1
+#Section 3 - Security Basics
2
+
3
+[[_TOC_]]
4
+
5
+##Introduction
6
+
7
+The following example shows a basic example of security utilizing a combination of AdHocSettings.
8
+
9
+##Code Sample
10
+
11
+```csharp
12
+[Serializable]
13
+ public class CustomAdHocConfig : DatabaseAdHocConfig
14
+ {
15
+ public static void InitializeReporting()
16
+ {
17
+ if (AdHocContext.Initialized) {
18
+ return;
19
+ }
20
+
21
+ //Your Licence Key
22
+ AdHocSettings.LicenseKey = "Enter Key";
23
+ //Datasource of the DB where the Data sources are stored
24
+ AdHocSettings.SqlServerConnectionString = @"DBconnectionString;";
25
+
26
+ AdHocSettings.AdHocConfig = new CustomAdHocConfig();
27
+ AdHocSettings.GenerateThumbnails = true;
28
+ AdHocSettings.ShowSimpleModeViewer = true;
29
+ AdHocSettings.IdentifiersRegex = "^.*[iI][Dd]$";
30
+ AdHocSettings.TabsCssUrl = "/Resources/css/tabs.css";
31
+ AdHocSettings.ReportCssUrl = "../Resources/css/Report.css";
32
+ AdHocSettings.ShowBetweenDateCalendar = true;
33
+ AdHocSettings.ReportViewer = "ReportViewer";
34
+ AdHocSettings.InstantReport = "InstantReport";
35
+ AdHocSettings.ReportDesignerUrl = "ReportDesigner";
36
+ AdHocSettings.ReportList = "ReportList";
37
+ AdHocSettings.SettingsPageUrl = "Settings";
38
+ AdHocSettings.ParentSettingsUrl = "Settings";
39
+ AdHocSettings.ResponseServer = "rs.aspx";
40
+ AdHocSettings.ReportsPath = Path.Combine(HttpContext.Current.Server.MapPath("~/"), "Reports");
41
+ AdHocSettings.ChartingEngine = ChartingEngine.HtmlChart;
42
+ AdHocSettings.ShowModifiedReportMessage = false;
43
+ AdHocSettings.DashboardViewer = "Dash";
44
+ AdHocSettings.DashboardDesignerUrl = "Dash";
45
+ AdHocSettings.DashboardDateSliderMode = DashboardDateSliderMode.None;
46
+ AdHocSettings.ShowJoinDropDown = true;
47
+ AdHocSettings.InstantReport = "InstantReportNew";
48
+ //EOPDF uses a DLL that converts HTML
49
+ //AdHocSettings.PdfPrintMode = PdfMode.EOPDF;
50
+ //PhantomJS PDF uses an EXE on the web server that produces the export
51
+ AdHocSettings.PdfPrintMode = PdfMode.PhantomJs;
52
+ //Asserts that the AdhocSettings.CurrentUserName is not null or the default value
53
+ //If it is an unaccepted value, the user will be navigated to the specified login page
54
+ AdHocSettings.RequireLogin = true;
55
+ //Specifies the login page
56
+ AdHocSettings.LoginUrl = "yourLoginPage.aspx";
57
+
58
+ //the default mode for AdHocSettings.CurrentUserIsAdmin is set to TRUE
59
+ //You must set it to FALSE for share-with values to take effect
60
+ AdHocSettings.CurrentUserIsAdmin = false;
61
+
62
+ //Get username from session value that was set on Log-in page
63
+ AdHocSettings.CurrentUserName = HttpContext.Current.Session["UserName"];
64
+
65
+ //Set which datasources the user can view
66
+ //In this case we are pulling all tables, views and procedures
67
+ DataSet ds = AdHocContext.Driver.GetDataSet(AdHocContext.Driver.CreateCommand("select * from sys.objects where type in ('U','P','V')"));
68
+ string[] shownTables = new string[ds.Tables[0].Rows.Count];
69
+ for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
70
+ shownTables[i] = ds.Tables[0].Rows[i][0].ToString();
71
+
72
+ AdHocSettings.VisibleDataSources = shownTables;
73
+
74
+ AdHocContext.Initialized = true;
75
+ }
76
+
77
+}
78
+```
... ...
\ No newline at end of file