19
19
using Microsoft . Azure . Commands . Synapse . Common ;
20
20
using Microsoft . Azure . Commands . Synapse . Properties ;
21
21
using Microsoft . Azure . Commands . Synapse . VulnerabilityAssessment . Model ;
22
- using Microsoft . Azure . Graph . RBAC . Version1_6 . ActiveDirectory ;
23
- using Microsoft . Azure . Graph . RBAC . Version1_6 . Models ;
24
22
using Microsoft . Azure . Management . Internal . Resources ;
25
23
using Microsoft . Azure . Management . Internal . Resources . Models ;
26
24
using Microsoft . Azure . Management . Internal . Resources . Utilities . Models ;
30
28
using Microsoft . Azure . Management . Synapse . Models ;
31
29
using Microsoft . Rest ;
32
30
using Microsoft . Rest . Azure ;
33
- using Microsoft . Rest . Azure . OData ;
34
31
using Newtonsoft . Json ;
35
32
using Newtonsoft . Json . Linq ;
36
33
using System ;
51
48
using ErrorResponseException = Microsoft . Azure . Management . Synapse . Models . ErrorResponseException ;
52
49
using Microsoft . Azure . Commands . Synapse . Models . Auditing ;
53
50
using Microsoft . DataTransfer . Gateway . Encryption ;
51
+ using Microsoft . Azure . Commands . Common . MSGraph . Version1_0 ;
52
+ using Microsoft . Azure . Commands . Common . MSGraph . Version1_0 . Applications . Models ;
53
+ using Microsoft . Azure . Commands . Common . MSGraph . Version1_0 . Groups . Models ;
54
+ using Microsoft . Rest . Azure . OData ;
54
55
55
56
namespace Microsoft . Azure . Commands . Synapse . Models
56
57
{
@@ -62,7 +63,7 @@ public class SynapseAnalyticsManagementClient
62
63
private readonly Guid _tenantId ;
63
64
private readonly SynapseManagementClient _synapseManagementClient ;
64
65
private readonly SynapseSqlV3ManagementClient _synapseSqlV3ManagementClient ;
65
- private ActiveDirectoryClient _activeDirectoryClient ;
66
+ private MicrosoftGraphClient _graphClient ;
66
67
private ResourceManagementClient _resourceManagementClient ;
67
68
private StorageManagementClient _storageManagementClient ;
68
69
private MonitorManagementClient _monitorManagementClient ;
@@ -88,20 +89,20 @@ public SynapseAnalyticsManagementClient(IAzureContext context)
88
89
89
90
_monitorManagementClient = SynapseCmdletBase . CreateSynapseClient < MonitorManagementClient > ( context ,
90
91
AzureEnvironment . Endpoint . ResourceManager ) ;
91
- }
92
+ }
92
93
93
- public ActiveDirectoryClient ActiveDirectoryClient
94
+ public MicrosoftGraphClient GraphClient
94
95
{
95
96
get
96
97
{
97
- if ( _activeDirectoryClient == null )
98
- {
99
- _activeDirectoryClient = new ActiveDirectoryClient ( Context ) ;
98
+ if ( _graphClient == null ) {
99
+ _graphClient = AzureSession . Instance . ClientFactory . CreateArmClient < MicrosoftGraphClient > ( Context , AzureEnvironment . ExtendedEndpoint . MicrosoftGraphUrl ) ;
100
+ _graphClient . TenantID = Context . Tenant . Id . ToString ( ) ;
100
101
}
101
- return this . _activeDirectoryClient ;
102
+ return this . _graphClient ;
102
103
}
103
-
104
- set { this . _activeDirectoryClient = value ; }
104
+
105
+ set { this . _graphClient = value ; }
105
106
}
106
107
107
108
public ResourceManagementClient ResourceManagementClient
@@ -422,19 +423,20 @@ private WorkspaceAadAdminInfo GetActiveDirectoryInformation(string displayName,
422
423
Guid tenantId = _tenantId ;
423
424
424
425
// Check for a Azure Active Directory group. Recommended to always use group.
425
- IEnumerable < PSADGroup > groupList = null ;
426
- PSADGroup group = null ;
426
+ IEnumerable < MicrosoftGraphGroup > groupList = null ;
427
427
428
- var filter = new ADObjectFilterOptions ( )
428
+ MicrosoftGraphGroup group = null ;
429
+
430
+ var filter = new MicrosoftObjectFilterOptions ( )
429
431
{
430
432
Id = ( objectId != null && objectId != Guid . Empty ) ? objectId . ToString ( ) : null ,
431
433
SearchString = displayName ,
432
434
Paging = true ,
433
435
} ;
434
436
435
437
// Get a list of groups from Azure Active Directory
436
- groupList = ActiveDirectoryClient . FilterGroups ( filter ) . Where ( gr => string . Equals ( gr . DisplayName , displayName , StringComparison . OrdinalIgnoreCase ) ) ;
437
-
438
+ groupList = GraphClient . FilterGroups ( filter ) . Where ( gr => string . Equals ( gr . DisplayName , displayName , StringComparison . OrdinalIgnoreCase ) ) ;
439
+
438
440
if ( groupList != null && groupList . Count ( ) > 1 )
439
441
{
440
442
// More than one group was found with that display name.
@@ -453,19 +455,19 @@ private WorkspaceAadAdminInfo GetActiveDirectoryInformation(string displayName,
453
455
}
454
456
455
457
// Lookup for serviceprincipals
456
- ODataQuery < ServicePrincipal > odataQueryFilter ;
458
+ ODataQuery < MicrosoftGraphServicePrincipal > odataQueryFilter ;
457
459
458
460
if ( ( objectId != null && objectId != Guid . Empty ) )
459
461
{
460
462
var applicationIdString = objectId . ToString ( ) ;
461
- odataQueryFilter = new Rest . Azure . OData . ODataQuery < ServicePrincipal > ( a => a . AppId == applicationIdString ) ;
463
+ odataQueryFilter = new ODataQuery < MicrosoftGraphServicePrincipal > ( a => a . AppId == applicationIdString ) ;
462
464
}
463
465
else
464
- {
465
- odataQueryFilter = new Rest . Azure . OData . ODataQuery < ServicePrincipal > ( a => a . DisplayName == displayName ) ;
466
+ {
467
+ odataQueryFilter = new ODataQuery < MicrosoftGraphServicePrincipal > ( a => a . DisplayName == displayName ) ;
466
468
}
467
-
468
- var servicePrincipalList = ActiveDirectoryClient . FilterServicePrincipals ( odataQueryFilter ) ;
469
+
470
+ var servicePrincipalList = GraphClient . FilterServicePrincipals ( odataQueryFilter ) ;
469
471
470
472
if ( servicePrincipalList != null && servicePrincipalList . Count ( ) > 1 )
471
473
{
@@ -475,7 +477,7 @@ private WorkspaceAadAdminInfo GetActiveDirectoryInformation(string displayName,
475
477
else if ( servicePrincipalList != null && servicePrincipalList . Count ( ) == 1 )
476
478
{
477
479
// Only one user was found. Get the user display name and object id
478
- PSADServicePrincipal app = servicePrincipalList . First ( ) ;
480
+ MicrosoftGraphServicePrincipal app = servicePrincipalList . FirstOrDefault ( ) ;
479
481
480
482
if ( displayName != null && string . CompareOrdinal ( displayName , app . DisplayName ) != 0 )
481
483
{
@@ -490,7 +492,7 @@ private WorkspaceAadAdminInfo GetActiveDirectoryInformation(string displayName,
490
492
return new WorkspaceAadAdminInfo ( )
491
493
{
492
494
Login = displayName ,
493
- Sid = app . ApplicationId . ToString ( ) ,
495
+ Sid = app . AppId . ToString ( ) ,
494
496
TenantId = tenantId . ToString ( )
495
497
} ;
496
498
}
@@ -506,42 +508,42 @@ private WorkspaceAadAdminInfo GetActiveDirectoryInformation(string displayName,
506
508
}
507
509
508
510
// No group or service principal was found. Check for a user
509
- filter = new ADObjectFilterOptions ( )
511
+ filter = new MicrosoftObjectFilterOptions ( )
510
512
{
511
513
Id = ( objectId != null && objectId != Guid . Empty ) ? objectId . ToString ( ) : null ,
512
514
SearchString = displayName ,
513
515
Paging = true ,
514
516
} ;
515
517
516
518
// Get a list of user from Azure Active Directory
517
- var userList = ActiveDirectoryClient . FilterUsers ( filter ) . Where ( gr => string . Equals ( gr . DisplayName , displayName , StringComparison . OrdinalIgnoreCase ) ) ;
519
+ var userList = GraphClient . FilterUsers ( filter ) . Where ( gr => string . Equals ( gr . DisplayName , displayName , StringComparison . OrdinalIgnoreCase ) ) ;
518
520
519
521
// No user was found. Check if the display name is a UPN
520
522
if ( userList == null || userList . Count ( ) == 0 )
521
523
{
522
524
// Check if the display name is the UPN
523
- filter = new ADObjectFilterOptions ( )
525
+ filter = new MicrosoftObjectFilterOptions ( )
524
526
{
525
527
Id = ( objectId != null && objectId != Guid . Empty ) ? objectId . ToString ( ) : null ,
526
528
UPN = displayName ,
527
529
Paging = true ,
528
530
} ;
529
531
530
- userList = ActiveDirectoryClient . FilterUsers ( filter ) . Where ( gr => string . Equals ( gr . UserPrincipalName , displayName , StringComparison . OrdinalIgnoreCase ) ) ;
532
+ userList = GraphClient . FilterUsers ( filter ) . Where ( gr => string . Equals ( gr . UserPrincipalName , displayName , StringComparison . OrdinalIgnoreCase ) ) ;
531
533
}
532
534
533
535
// No user was found. Check if the display name is a guest user.
534
536
if ( userList == null || userList . Count ( ) == 0 )
535
537
{
536
538
// Check if the display name is the UPN
537
- filter = new ADObjectFilterOptions ( )
539
+ filter = new MicrosoftObjectFilterOptions ( )
538
540
{
539
541
Id = ( objectId != null && objectId != Guid . Empty ) ? objectId . ToString ( ) : null ,
540
542
Mail = displayName ,
541
543
Paging = true ,
542
544
} ;
543
545
544
- userList = ActiveDirectoryClient . FilterUsers ( filter ) ;
546
+ userList = GraphClient . FilterUsers ( filter ) ;
545
547
}
546
548
547
549
// No user was found
0 commit comments