Skip to content

Commit 94c195d

Browse files
committed
Version 5.1.0 (.NET 4.7.2)
[ENHANCEMENT] Support for HEAD request added [ENHANCEMENT] ADO for AD/SQL connection added
1 parent 5b5ea56 commit 94c195d

34 files changed

+2850
-41
lines changed

rls/API.Library.dll

8.5 KB
Binary file not shown.

rls/API.Library.dll.config

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@
111111
<!-- ADO - Bulk Copy BatchSize in rows (below 5000 to avoid Table locking) -->
112112
<add key="API_ADO_BULKCOPY_BATCHSIZE" value="4999" />
113113

114+
<!-- ADO - Database Connection Type [SQL, AD] -->
115+
<add key="API_ADO_DB_CONNECTION_TYPE" value="SQL" />
116+
<!-- ADO - Database Connection active directory domain -->
117+
<add key="API_ADO_DB_AD_DOMAIN" value="" />
118+
<!-- ADO - Database Connection username -->
119+
<add key="API_ADO_DB_AD_CONNECTION_USERNAME" value="" />
120+
<!-- ADO - Database Connection password -->
121+
<add key="API_ADO_DB_AD_CONNECTION_PASSWORD" value="" />
122+
114123
<!--
115124
**********************************************************************
116125
API - MemCacheD
@@ -154,6 +163,8 @@
154163
<add name="defaultConnection" connectionString="Server=;Initial Catalog=;User ID=;Password=;Persist Security Info=False;Column Encryption Setting=enabled;" />
155164
</connectionStrings>
156165

166+
167+
157168
<!--
158169
**********************************************************************
159170
CACHE - MemCacheD
@@ -305,6 +316,10 @@
305316
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
306317
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
307318
</dependentAssembly>
319+
<dependentAssembly>
320+
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
321+
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
322+
</dependentAssembly>
308323
</assemblyBinding>
309324
</runtime>
310325

rls/API.Library.pdb

26 KB
Binary file not shown.

src/API.Library.sln

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.25420.1
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31729.503
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API.Library", "API.Library\API.Library.csproj", "{706831F3-53F4-4A41-A028-632DD787B790}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
11+
Dev|Any CPU = Dev|Any CPU
12+
Live|Any CPU = Live|Any CPU
1113
Release|Any CPU = Release|Any CPU
14+
TD|Any CPU = TD|Any CPU
1215
EndGlobalSection
1316
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1417
{706831F3-53F4-4A41-A028-632DD787B790}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1518
{706831F3-53F4-4A41-A028-632DD787B790}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{706831F3-53F4-4A41-A028-632DD787B790}.Dev|Any CPU.ActiveCfg = Dev|Any CPU
20+
{706831F3-53F4-4A41-A028-632DD787B790}.Dev|Any CPU.Build.0 = Dev|Any CPU
21+
{706831F3-53F4-4A41-A028-632DD787B790}.Live|Any CPU.ActiveCfg = Live|Any CPU
22+
{706831F3-53F4-4A41-A028-632DD787B790}.Live|Any CPU.Build.0 = Live|Any CPU
1623
{706831F3-53F4-4A41-A028-632DD787B790}.Release|Any CPU.ActiveCfg = Release|Any CPU
1724
{706831F3-53F4-4A41-A028-632DD787B790}.Release|Any CPU.Build.0 = Release|Any CPU
25+
{706831F3-53F4-4A41-A028-632DD787B790}.TD|Any CPU.ActiveCfg = TD|Any CPU
26+
{706831F3-53F4-4A41-A028-632DD787B790}.TD|Any CPU.Build.0 = TD|Any CPU
1827
EndGlobalSection
1928
GlobalSection(SolutionProperties) = preSolution
2029
HideSolutionNode = FALSE
2130
EndGlobalSection
31+
GlobalSection(ExtensibilityGlobals) = postSolution
32+
SolutionGuid = {C633644D-71C0-4CF2-95D0-F6C367931EB3}
33+
EndGlobalSection
2234
EndGlobal

src/API.Library/API.Library.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@
218218
<Private>True</Private>
219219
<Private>True</Private>
220220
</Reference>
221-
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
222-
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
221+
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
222+
<HintPath>..\..\..\..\5.2.0\server\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
223223
</Reference>
224224
<Reference Include="System.Runtime.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
225225
<HintPath>..\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll</HintPath>
@@ -284,11 +284,15 @@
284284
<ItemGroup>
285285
<Compile Include="Entities\ActiveDirectory.cs" />
286286
<Compile Include="Entities\API.Common.cs" />
287+
<Compile Include="Entities\API.HEAD.cs" />
287288
<Compile Include="Entities\API.Map.cs" />
288289
<Compile Include="Entities\API.JSONRPC.cs" />
289290
<Compile Include="Entities\API.Static.cs" />
290291
<Compile Include="Entities\API.RESTful.cs" />
291292
<Compile Include="Entities\Firebase.cs" />
293+
<Compile Include="Entities\Impersonization.cs" />
294+
<Compile Include="Entities\IRequest.cs" />
295+
<Compile Include="Entities\IResponseOutput.cs" />
292296
<Compile Include="Entities\Log.cs" />
293297
<Compile Include="Entities\MemCacheD.cs" />
294298
<Compile Include="Entities\eMail\eMail.cs" />

src/API.Library/App.config

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@
111111
<!-- ADO - Bulk Copy BatchSize in rows (below 5000 to avoid Table locking) -->
112112
<add key="API_ADO_BULKCOPY_BATCHSIZE" value="4999" />
113113

114+
<!-- ADO - Database Connection Type [SQL, AD] -->
115+
<add key="API_ADO_DB_CONNECTION_TYPE" value="SQL" />
116+
<!-- ADO - Database Connection active directory domain -->
117+
<add key="API_ADO_DB_AD_DOMAIN" value="" />
118+
<!-- ADO - Database Connection username -->
119+
<add key="API_ADO_DB_AD_CONNECTION_USERNAME" value="" />
120+
<!-- ADO - Database Connection password -->
121+
<add key="API_ADO_DB_AD_CONNECTION_PASSWORD" value="" />
122+
114123
<!--
115124
**********************************************************************
116125
API - MemCacheD
@@ -154,6 +163,8 @@
154163
<add name="defaultConnection" connectionString="Server=;Initial Catalog=;User ID=;Password=;Persist Security Info=False;Column Encryption Setting=enabled;" />
155164
</connectionStrings>
156165

166+
167+
157168
<!--
158169
**********************************************************************
159170
CACHE - MemCacheD
@@ -305,6 +316,10 @@
305316
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
306317
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
307318
</dependentAssembly>
319+
<dependentAssembly>
320+
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
321+
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
322+
</dependentAssembly>
308323
</assemblyBinding>
309324
</runtime>
310325

src/API.Library/Entities/ADO.cs

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,13 @@ public void OpenConnection(string connectionName)
123123
return;
124124
}
125125

126+
//check what type of DB connection is to be made
127+
string connectionType = ConfigurationManager.AppSettings["API_ADO_DB_CONNECTION_TYPE"];
128+
126129
// Get the Connection String form the associated Name
127130
string connectionString = ConfigurationManager.ConnectionStrings[connectionName].ConnectionString;
128131

132+
129133
Log.Instance.Info("SQL Server Connection Name: " + connectionName);
130134
Log.Instance.Info("SQL Server Connection String: ********"); // Hide connectionString from logs
131135

@@ -135,9 +139,42 @@ public void OpenConnection(string connectionName)
135139
return;
136140
}
137141

138-
// Open a connection
139-
connection = new SqlConnection(connectionString);
140-
connection.Open();
142+
if (connectionType.Equals("AD"))
143+
{
144+
//need to impersonate as the AD user when creating the connection
145+
146+
var execUsername = ConfigurationManager.AppSettings["API_ADO_DB_AD_CONNECTION_USERNAME"];
147+
var execPassword = ConfigurationManager.AppSettings["API_ADO_DB_AD_CONNECTION_PASSWORD"];
148+
var executeDomain = ConfigurationManager.AppSettings["API_ADO_DB_AD_DOMAIN"];
149+
150+
151+
if (Impersonization.impersonateValidUser(execUsername, executeDomain, execPassword))
152+
{
153+
connection = new SqlConnection(connectionString);
154+
connection.Open();
155+
Impersonization.undoImpersonation();
156+
}
157+
else
158+
{
159+
Log.Instance.Fatal("Error connection to database");
160+
throw new Exception("Error connection to database");
161+
}
162+
163+
164+
165+
}
166+
else if (connectionType.Equals("SQL"))
167+
{
168+
// Open a connection
169+
connection = new SqlConnection(connectionString);
170+
connection.Open();
171+
}
172+
else
173+
{
174+
Log.Instance.Fatal("Database Connection Type not supported");
175+
throw new Exception("Database Connection Type not supported");
176+
}
177+
141178
}
142179
catch (Exception e)
143180
{
@@ -788,7 +825,7 @@ public class ADO_readerOutput
788825
/// <summary>
789826
/// Flag to indicate if any data exists
790827
/// </summary>
791-
public bool hasData { get; internal set; }
828+
public bool hasData { get; set; }
792829

793830
/// <summary>
794831
/// Size of the output in Bytes
@@ -808,7 +845,7 @@ public class ADO_readerOutput
808845
/// <summary>
809846
/// Data output
810847
/// </summary>
811-
public List<dynamic> data { get; internal set; }
848+
public List<dynamic> data { get; set; }
812849

813850
#endregion
814851

src/API.Library/Entities/API.Common.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public class Common
129129
// IIS Anonymous Authentication enabled
130130
NetworkIdentity = null;
131131
NetworkUsername = null;
132+
Log.Instance.Info("User.Identity not authenticated");
132133
}
133134

134135
Log.Instance.Info("Network Identity: " + NetworkIdentity);

0 commit comments

Comments
 (0)