Skip to content

Commit aab8d3b

Browse files
author
j82w
committed
Adding SecurityEnabled to PSADGroup, updating help documents, and only allowing security enabled groups to be set for Azure SQL Server Active Directory Administrator.
1 parent 54a5daa commit aab8d3b

File tree

10 files changed

+526
-241
lines changed

10 files changed

+526
-241
lines changed

src/ResourceManager/Resources/Commands.Resources.Test/Commands.Resources.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@
306306
<None Include="ScenarioTests\RoleDefinitionTests.ps1">
307307
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
308308
</None>
309+
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.ActiveDirectoryTests\TestGetADGroupSecurityEnabled.json">
310+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
311+
</None>
309312
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.ActiveDirectoryTests\TestGetADUserWithMail.json">
310313
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
311314
</None>

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ActiveDirectoryTests.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,32 @@ public void TestGetADGroupWithObjectId()
108108
TestUtilities.GetCurrentMethodName());
109109
}
110110

111+
[Fact]
112+
[Trait(Category.AcceptanceType, Category.CheckIn)]
113+
public void TestGetADGroupSecurityEnabled()
114+
{
115+
const string scriptMethod = "Test-GetADGroupSecurityEnabled '{0}' '{1}'";
116+
Group newGroup = null;
117+
var controllerAdmin = ResourcesController.NewInstance;
118+
119+
controllerAdmin.RunPsTestWorkflow(
120+
// scriptBuilder
121+
() =>
122+
{
123+
newGroup = CreateNewAdGroup(controllerAdmin);
124+
return new[] { string.Format(scriptMethod, newGroup.ObjectId, newGroup.SecurityEnabled) };
125+
},
126+
// initialize
127+
null,
128+
// cleanup
129+
() =>
130+
{
131+
DeleteAdGroup(controllerAdmin, newGroup);
132+
},
133+
TestUtilities.GetCallingClass(),
134+
TestUtilities.GetCurrentMethodName());
135+
}
136+
111137
[Fact]
112138
[Trait(Category.AcceptanceType, Category.CheckIn)]
113139
public void TestGetADGroupWithBadObjectId()

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ActiveDirectoryTests.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,24 @@ function Test-GetADGroupWithObjectId
7878
Assert-NotNull($groups[0].DisplayName)
7979
}
8080

81+
<#
82+
.SYNOPSIS
83+
Tests getting Active Directory group with security enabled .
84+
#>
85+
function Test-GetADGroupSecurityEnabled
86+
{
87+
param([string]$objectId, [string]$securityEnabled)
88+
89+
# Test
90+
$groups = Get-AzureADGroup -ObjectId $objectId
91+
92+
# Assert
93+
Assert-AreEqual $groups.Count 1
94+
Assert-AreEqual $groups[0].Id $objectId
95+
Assert-AreEqual $groups[0].SecurityEnabled $securityEnabled
96+
Assert-NotNull($groups[0].DisplayName)
97+
}
98+
8199
<#
82100
.SYNOPSIS
83101
Tests getting Active Directory groups.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/73bf5eac-7be2-4c8c-b3eb-9cc4aa201100/groups?api-version=1.42-previewInternal",
5+
"EncodedRequestUri": "LzczYmY1ZWFjLTdiZTItNGM4Yy1iM2ViLTljYzRhYTIwMTEwMC9ncm91cHM/YXBpLXZlcnNpb249MS40Mi1wcmV2aWV3SW50ZXJuYWw=",
6+
"RequestMethod": "POST",
7+
"RequestBody": "{\r\n \"displayName\": \"adgroup6035\",\r\n \"mailEnabled\": false,\r\n \"mailNickname\": \"adgroupmail8751\",\r\n \"securityEnabled\": true\r\n}",
8+
"RequestHeaders": {
9+
"Content-Type": [
10+
"application/json; charset=utf-8"
11+
],
12+
"Content-Length": [
13+
"127"
14+
],
15+
"User-Agent": [
16+
"Microsoft.Azure.Graph.RBAC.GraphRbacManagementClient/1.0.0.0"
17+
]
18+
},
19+
"ResponseBody": "{\r\n \"odata.metadata\": \"https://graph.ppe.windows.net/73bf5eac-7be2-4c8c-b3eb-9cc4aa201100/$metadata#directoryObjects/Microsoft.WindowsAzure.ActiveDirectory.Group/@Element\",\r\n \"odata.type\": \"Microsoft.WindowsAzure.ActiveDirectory.Group\",\r\n \"objectType\": \"Group\",\r\n \"objectId\": \"0b7e4247-de60-405c-9c04-6cc9721539a1\",\r\n \"softDeletionTimestamp\": null,\r\n \"appMetadata\": null,\r\n \"exchangeResources\": [],\r\n \"description\": null,\r\n \"dirSyncEnabled\": null,\r\n \"displayName\": \"adgroup6035\",\r\n \"groupType\": null,\r\n \"isPublic\": null,\r\n \"lastDirSyncTime\": null,\r\n \"licenseAssignment\": [],\r\n \"mail\": null,\r\n \"mailNickname\": \"adgroupmail8751\",\r\n \"mailEnabled\": false,\r\n \"onPremiseSecurityIdentifier\": null,\r\n \"provisioningErrors\": [],\r\n \"proxyAddresses\": [],\r\n \"securityEnabled\": true,\r\n \"sharepointResources\": []\r\n}",
20+
"ResponseHeaders": {
21+
"Content-Length": [
22+
"710"
23+
],
24+
"Content-Type": [
25+
"application/json; odata=minimalmetadata; streaming=true; charset=utf-8"
26+
],
27+
"Expires": [
28+
"-1"
29+
],
30+
"Pragma": [
31+
"no-cache"
32+
],
33+
"ocp-aad-diagnostics-server-name": [
34+
"p26FZwHhWTf12W1XQXK+GyAVGWe+soGFePh6Rq4qHrI="
35+
],
36+
"request-id": [
37+
"3a6f6342-c8fa-4e0a-95f1-684e1804c4b0"
38+
],
39+
"client-request-id": [
40+
"9663327c-670b-4f78-9eca-0aa9ee4e4c1a"
41+
],
42+
"x-ms-gateway-rewrite": [
43+
"false"
44+
],
45+
"x-ms-dirapi-data-contract-version": [
46+
"1.42-previewInternal"
47+
],
48+
"ocp-aad-session-key": [
49+
"CxL0SUxsw4WnJVmlwroRNjovfpfYLZPQIunngNXUsC6mZOmMq1-YKykQNSBVLb2fzsD7k7DAlVXzQ2Ui5pGs1aDPLo7FC6muKk1Ghbi2V7ub9RICbzNAK1a08grMzvXX94Q2JPOpxwGmfaDhBmbPDg.6RPP7LGnF2_VC2CkQQEtp8zagjFfcy386N5GtNaSbcY"
50+
],
51+
"X-Content-Type-Options": [
52+
"nosniff"
53+
],
54+
"DataServiceVersion": [
55+
"3.0;"
56+
],
57+
"Strict-Transport-Security": [
58+
"max-age=31536000; includeSubDomains"
59+
],
60+
"Access-Control-Allow-Origin": [
61+
"*"
62+
],
63+
"Cache-Control": [
64+
"no-cache"
65+
],
66+
"Location": [
67+
"https://graph.ppe.windows.net/73bf5eac-7be2-4c8c-b3eb-9cc4aa201100/directoryObjects/0b7e4247-de60-405c-9c04-6cc9721539a1/Microsoft.WindowsAzure.ActiveDirectory.Group"
68+
],
69+
"Server": [
70+
"Microsoft-IIS/8.5"
71+
],
72+
"X-AspNet-Version": [
73+
"4.0.30319"
74+
],
75+
"X-Powered-By": [
76+
"ASP.NET",
77+
"ASP.NET"
78+
],
79+
"Date": [
80+
"Tue, 18 Aug 2015 16:56:03 GMT"
81+
]
82+
},
83+
"StatusCode": 201
84+
},
85+
{
86+
"RequestUri": "/73bf5eac-7be2-4c8c-b3eb-9cc4aa201100/groups/0b7e4247-de60-405c-9c04-6cc9721539a1?api-version=1.42-previewInternal",
87+
"EncodedRequestUri": "LzczYmY1ZWFjLTdiZTItNGM4Yy1iM2ViLTljYzRhYTIwMTEwMC9ncm91cHMvMGI3ZTQyNDctZGU2MC00MDVjLTljMDQtNmNjOTcyMTUzOWExP2FwaS12ZXJzaW9uPTEuNDItcHJldmlld0ludGVybmFs",
88+
"RequestMethod": "GET",
89+
"RequestBody": "",
90+
"RequestHeaders": {
91+
"User-Agent": [
92+
"Microsoft.Azure.Graph.RBAC.GraphRbacManagementClient/1.0.0.0"
93+
]
94+
},
95+
"ResponseBody": "{\r\n \"odata.metadata\": \"https://graph.ppe.windows.net/73bf5eac-7be2-4c8c-b3eb-9cc4aa201100/$metadata#directoryObjects/Microsoft.WindowsAzure.ActiveDirectory.Group/@Element\",\r\n \"odata.type\": \"Microsoft.WindowsAzure.ActiveDirectory.Group\",\r\n \"objectType\": \"Group\",\r\n \"objectId\": \"0b7e4247-de60-405c-9c04-6cc9721539a1\",\r\n \"softDeletionTimestamp\": null,\r\n \"appMetadata\": null,\r\n \"exchangeResources\": [],\r\n \"description\": null,\r\n \"dirSyncEnabled\": null,\r\n \"displayName\": \"adgroup6035\",\r\n \"groupType\": null,\r\n \"isPublic\": null,\r\n \"lastDirSyncTime\": null,\r\n \"licenseAssignment\": [],\r\n \"mail\": null,\r\n \"mailNickname\": \"adgroupmail8751\",\r\n \"mailEnabled\": false,\r\n \"onPremiseSecurityIdentifier\": null,\r\n \"provisioningErrors\": [],\r\n \"proxyAddresses\": [],\r\n \"securityEnabled\": true,\r\n \"sharepointResources\": []\r\n}",
96+
"ResponseHeaders": {
97+
"Content-Length": [
98+
"710"
99+
],
100+
"Content-Type": [
101+
"application/json; odata=minimalmetadata; streaming=true; charset=utf-8"
102+
],
103+
"Expires": [
104+
"-1"
105+
],
106+
"Pragma": [
107+
"no-cache"
108+
],
109+
"ocp-aad-diagnostics-server-name": [
110+
"vhYgA4yOUvjGnawHsDLVJznXNq0HF1intYYZGiD8RqA="
111+
],
112+
"request-id": [
113+
"fcfc812f-4c75-4050-a26d-13319ea6a584"
114+
],
115+
"client-request-id": [
116+
"e2cbd040-d98a-489a-9ce9-d2256e485035"
117+
],
118+
"x-ms-gateway-rewrite": [
119+
"false"
120+
],
121+
"x-ms-dirapi-data-contract-version": [
122+
"1.42-previewInternal"
123+
],
124+
"ocp-aad-session-key": [
125+
"cDC4lcRcPV6FLoN7Gd_FKWd7XvI78lkKeJxpz9UibQmAqFRy5vBuc_PpkyW-yB-BuWl033MW-AQ-i6rWNItLO92wDzEd2t-hFwl7VWswVo-fAwkZ5H4CiGTePIOpE1GpE6j2vkhEYI7MLOshQnayfg.k9Tz72L20M2yv4kgOIEDIPaY0qfEHdBsM33mTfekIMo"
126+
],
127+
"X-Content-Type-Options": [
128+
"nosniff"
129+
],
130+
"DataServiceVersion": [
131+
"3.0;"
132+
],
133+
"Strict-Transport-Security": [
134+
"max-age=31536000; includeSubDomains"
135+
],
136+
"Access-Control-Allow-Origin": [
137+
"*"
138+
],
139+
"Cache-Control": [
140+
"no-cache"
141+
],
142+
"Server": [
143+
"Microsoft-IIS/8.5"
144+
],
145+
"X-AspNet-Version": [
146+
"4.0.30319"
147+
],
148+
"X-Powered-By": [
149+
"ASP.NET",
150+
"ASP.NET"
151+
],
152+
"Date": [
153+
"Tue, 18 Aug 2015 16:56:03 GMT"
154+
]
155+
},
156+
"StatusCode": 200
157+
},
158+
{
159+
"RequestUri": "/73bf5eac-7be2-4c8c-b3eb-9cc4aa201100/groups/0b7e4247-de60-405c-9c04-6cc9721539a1?api-version=1.42-previewInternal",
160+
"EncodedRequestUri": "LzczYmY1ZWFjLTdiZTItNGM4Yy1iM2ViLTljYzRhYTIwMTEwMC9ncm91cHMvMGI3ZTQyNDctZGU2MC00MDVjLTljMDQtNmNjOTcyMTUzOWExP2FwaS12ZXJzaW9uPTEuNDItcHJldmlld0ludGVybmFs",
161+
"RequestMethod": "DELETE",
162+
"RequestBody": "",
163+
"RequestHeaders": {
164+
"User-Agent": [
165+
"Microsoft.Azure.Graph.RBAC.GraphRbacManagementClient/1.0.0.0"
166+
]
167+
},
168+
"ResponseBody": "",
169+
"ResponseHeaders": {
170+
"Expires": [
171+
"-1"
172+
],
173+
"Pragma": [
174+
"no-cache"
175+
],
176+
"ocp-aad-diagnostics-server-name": [
177+
"p26FZwHhWTf12W1XQXK+GyAVGWe+soGFePh6Rq4qHrI="
178+
],
179+
"request-id": [
180+
"5d694c7d-a5b3-4598-9a2e-13ec7647d942"
181+
],
182+
"client-request-id": [
183+
"89e4709f-c962-42bf-b703-df5180ec3cf2"
184+
],
185+
"x-ms-gateway-rewrite": [
186+
"false"
187+
],
188+
"x-ms-dirapi-data-contract-version": [
189+
"1.42-previewInternal"
190+
],
191+
"ocp-aad-session-key": [
192+
"U2xkwifbpzW18YgrT01D0Z0Jb7sN55yzRIkX3Ok355EEVR1Yehs4jYQL_t5I-WyXYQQAGsEasX5GDadld9N8TljR-gJH2Z98wXMZ4mCqaLNAtxwuoN8Fqv1njzKiEazRobH2UuaBsRgQLqIB2Oxl5Q.99_JDq-Z8uaz1-CCXjpdINoQYBRW_HUwqjn4M3snDTE"
193+
],
194+
"X-Content-Type-Options": [
195+
"nosniff"
196+
],
197+
"DataServiceVersion": [
198+
"1.0;"
199+
],
200+
"Strict-Transport-Security": [
201+
"max-age=31536000; includeSubDomains"
202+
],
203+
"Access-Control-Allow-Origin": [
204+
"*"
205+
],
206+
"Cache-Control": [
207+
"no-cache"
208+
],
209+
"Server": [
210+
"Microsoft-IIS/8.5"
211+
],
212+
"X-AspNet-Version": [
213+
"4.0.30319"
214+
],
215+
"X-Powered-By": [
216+
"ASP.NET",
217+
"ASP.NET"
218+
],
219+
"Date": [
220+
"Tue, 18 Aug 2015 16:56:03 GMT"
221+
]
222+
},
223+
"StatusCode": 204
224+
}
225+
],
226+
"Names": {
227+
"CreateNewAdGroup": [
228+
"adgroup6035",
229+
"adgroupmail8751"
230+
]
231+
},
232+
"Variables": {
233+
"SubscriptionId": "83ff500d-38ad-4a36-a26b-f500be74b250",
234+
"TenantId": "73bf5eac-7be2-4c8c-b3eb-9cc4aa201100",
235+
"Domain": "aztestorg067.ccsctp.net"
236+
}
237+
}

src/ResourceManager/Resources/Commands.Resources/Models.ActiveDirectory/ActiveDirectoryClientExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public static PSADObject ToPSADObject(this AADObject obj)
6060
{
6161
DisplayName = obj.DisplayName,
6262
Type = obj.ObjectType,
63-
Id = new Guid(obj.ObjectId)/*,
63+
Id = new Guid(obj.ObjectId),
64+
SecurityEnabled = obj.SecurityEnabled/*,
6465
Mail = group.Mail*/
6566
};
6667

@@ -101,7 +102,8 @@ public static PSADGroup ToPSADGroup(this Group group)
101102
return new PSADGroup()
102103
{
103104
DisplayName = group.DisplayName,
104-
Id = new Guid(group.ObjectId)/*,
105+
Id = new Guid(group.ObjectId),
106+
SecurityEnabled = group.SecurityEnabled/*,
105107
Mail = group.Mail*/
106108
};
107109
}

src/ResourceManager/Resources/Commands.Resources/Models.ActiveDirectory/PSADGroup.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ namespace Microsoft.Azure.Commands.Resources.Models.ActiveDirectory
1717
public class PSADGroup : PSADObject
1818
{
1919
public string Mail { get; set; }
20+
21+
public bool? SecurityEnabled { get; set; }
2022
}
2123
}

0 commit comments

Comments
 (0)