9
9
using System . ServiceModel . Description ;
10
10
using Microsoft . PowerPlatform . Dataverse . Client . Model ;
11
11
using Microsoft . PowerPlatform . Dataverse . Client . Auth ;
12
+ using Microsoft . Extensions . Logging ;
12
13
13
14
namespace Microsoft . PowerPlatform . Dataverse . Client
14
15
{
15
16
/// <summary>
16
- /// Stores Parsed connection info from the use of a CDS connection string.
17
- /// This is only populated when the CDS Connection string object is used, this is read only.
17
+ /// Stores Parsed connection info from the use of a CDS connection string.
18
+ /// This is only populated when the CDS Connection string object is used, this is read only.
18
19
/// </summary>
19
20
internal class DataverseConnectionStringProcessor
20
21
{
@@ -120,7 +121,7 @@ internal string Password
120
121
internal string CertThumbprint { get ; set ; }
121
122
122
123
/// <summary>
123
- /// if set to true, then the org URI should be used directly.
124
+ /// if set to true, then the org URI should be used directly.
124
125
/// </summary>
125
126
internal bool SkipDiscovery { get ; set ; }
126
127
@@ -188,20 +189,20 @@ public string TokenCacheStorePath
188
189
}
189
190
190
191
/// <summary>
191
- /// When true, specifies a unique instance of the connection should be created.
192
+ /// When true, specifies a unique instance of the connection should be created.
192
193
/// </summary>
193
194
public bool UseUniqueConnectionInstance { get ; internal set ; }
194
195
195
196
/// <summary>
196
- /// When set to true and oAuth Mode ( not Cert ) attempts to run the login using the current user identity.
197
+ /// When set to true and oAuth Mode ( not Cert ) attempts to run the login using the current user identity.
197
198
/// </summary>
198
199
public bool UseCurrentUser { get ; set ; }
199
200
200
201
public DataverseConnectionStringProcessor ( )
201
202
{
202
203
}
203
204
204
- private DataverseConnectionStringProcessor ( IDictionary < string , string > connection )
205
+ private DataverseConnectionStringProcessor ( IDictionary < string , string > connection , ILogger logger )
205
206
: this (
206
207
connection . FirstNotNullOrEmpty ( ConnectionStringConstants . ServiceUri ) ,
207
208
connection . FirstNotNullOrEmpty ( ConnectionStringConstants . UserName ) ,
@@ -218,12 +219,13 @@ private DataverseConnectionStringProcessor(IDictionary<string, string> connectio
218
219
connection . FirstNotNullOrEmpty ( ConnectionStringConstants . CertThumbprint ) ,
219
220
connection . FirstNotNullOrEmpty ( ConnectionStringConstants . SkipDiscovery ) ,
220
221
connection . FirstNotNullOrEmpty ( ConnectionStringConstants . IntegratedSecurity ) ,
221
- connection . FirstNotNullOrEmpty ( ConnectionStringConstants . ClientSecret )
222
+ connection . FirstNotNullOrEmpty ( ConnectionStringConstants . ClientSecret ) ,
223
+ logger
222
224
)
223
225
{
224
226
}
225
227
private DataverseConnectionStringProcessor ( string serviceUri , string userName , string password , string domain , string homeRealmUri , string authType , string requireNewInstance , string clientId , string redirectUri ,
226
- string tokenCacheStorePath , string loginPrompt , string certStoreName , string certThumbprint , string skipDiscovery , string IntegratedSecurity , string clientSecret )
228
+ string tokenCacheStorePath , string loginPrompt , string certStoreName , string certThumbprint , string skipDiscovery , string IntegratedSecurity , string clientSecret , ILogger logger )
227
229
{
228
230
DataverseTraceLogger logEntry = new DataverseTraceLogger ( ) ;
229
231
Uri _serviceuriName , _realmUri ;
@@ -232,7 +234,7 @@ private DataverseConnectionStringProcessor(string serviceUri, string userName, s
232
234
if ( bool . TryParse ( skipDiscovery , out tempbool ) )
233
235
SkipDiscovery = tempbool ;
234
236
else
235
- SkipDiscovery = true ; // changed to change defaulting behavior of skip discovery.
237
+ SkipDiscovery = true ; // changed to change defaulting behavior of skip discovery.
236
238
237
239
238
240
ServiceUri = GetValidUri ( serviceUri , out _serviceuriName ) ? _serviceuriName : null ;
@@ -247,16 +249,16 @@ private DataverseConnectionStringProcessor(string serviceUri, string userName, s
247
249
CertStoreName = certStoreName ;
248
250
CertThumbprint = certThumbprint ;
249
251
250
- // Check to see if use current user is configured.
252
+ // Check to see if use current user is configured.
251
253
bool _IntegratedSecurity = false ;
252
254
if ( ! string . IsNullOrEmpty ( IntegratedSecurity ) )
253
255
bool . TryParse ( IntegratedSecurity , out _IntegratedSecurity ) ;
254
256
255
- bool useUniqueConnection = true ; // Set default to true to follow the old behavior.
257
+ bool useUniqueConnection = true ; // Set default to true to follow the old behavior.
256
258
if ( ! string . IsNullOrEmpty ( requireNewInstance ) )
257
259
bool . TryParse ( requireNewInstance , out useUniqueConnection ) ;
258
260
UseUniqueConnectionInstance = useUniqueConnection ;
259
-
261
+
260
262
//UserIdentifier = !string.IsNullOrWhiteSpace(UserId) ? new UserIdentifier(UserId, UserIdentifierType.OptionalDisplayableId) : null;
261
263
262
264
AuthenticationType authenticationType ;
@@ -322,7 +324,7 @@ private bool GetValidUri(string uriSource, out Uri validUriResult)
322
324
/// <param name="serviceUri"></param>
323
325
private void SetOrgnameAndOnlineRegion ( Uri serviceUri )
324
326
{
325
- // uses publicaly exposed connection parser to parse
327
+ // uses publicaly exposed connection parser to parse
326
328
string orgRegion = string . Empty ;
327
329
string orgName = string . Empty ;
328
330
bool isOnPrem = false ;
@@ -334,13 +336,14 @@ private void SetOrgnameAndOnlineRegion(Uri serviceUri)
334
336
335
337
336
338
/// <summary>
337
- /// Parse the connection sting
339
+ /// Parse the connection sting
338
340
/// </summary>
339
341
/// <param name="connectionString"></param>
342
+ /// <param name="logger">Logging provider <see cref="ILogger"/></param>
340
343
/// <returns></returns>
341
- public static DataverseConnectionStringProcessor Parse ( string connectionString )
344
+ public static DataverseConnectionStringProcessor Parse ( string connectionString , ILogger logger = null )
342
345
{
343
- return new DataverseConnectionStringProcessor ( connectionString . ToDictionary ( ) ) ;
346
+ return new DataverseConnectionStringProcessor ( connectionString . ToDictionary ( ) , logger ) ;
344
347
}
345
348
346
349
}
0 commit comments