Skip to content

Commit 63bcb7f

Browse files
Merge pull request #2 from Azure/dev
Merge from Azure:dev
2 parents 3c1b70c + 0cdfa9c commit 63bcb7f

File tree

7 files changed

+298
-16
lines changed

7 files changed

+298
-16
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
@@ -246,6 +246,9 @@
246246
<None Include="ScenarioTests\RoleAssignmentTests.ps1">
247247
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
248248
</None>
249+
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.ActiveDirectoryTests\TestGetADUserWithMail.json">
250+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
251+
</None>
249252
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.ResourceGroupTests\TestNewDeploymentAndProviderRegistration.json">
250253
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
251254
</None>

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,32 @@ public void TestGetADUserWithObjectId()
424424
TestUtilities.GetCurrentMethodName());
425425
}
426426

427+
[Fact]
428+
[Trait(Category.AcceptanceType, Category.CheckIn)]
429+
public void TestGetADUserWithMail()
430+
{
431+
const string scriptMethod = "Test-GetADUserWithMail '{0}'";
432+
User newUser = null;
433+
var controllerAdmin = ResourcesController.NewInstance;
434+
435+
controllerAdmin.RunPsTestWorkflow(
436+
// scriptBuilder
437+
() =>
438+
{
439+
newUser = CreateNewAdUser(controllerAdmin);
440+
return new[] { string.Format(scriptMethod, newUser.UserPrincipalName) };
441+
},
442+
// initialize
443+
null,
444+
// cleanup
445+
() =>
446+
{
447+
DeleteAdUser(controllerAdmin, newUser);
448+
},
449+
TestUtilities.GetCallingClass(),
450+
TestUtilities.GetCurrentMethodName());
451+
}
452+
427453
[Fact]
428454
[Trait(Category.AcceptanceType, Category.CheckIn)]
429455
public void TestGetADUserWithBadObjectId()

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,25 @@ function Test-GetADUserWithObjectId
306306
Assert-NotNull($users[0].UserPrincipalName)
307307
}
308308

309+
310+
<#
311+
.SYNOPSIS
312+
Tests getting Active Directory users by mail.
313+
#>
314+
function Test-GetADUserWithMail
315+
{
316+
param([string]$mail)
317+
318+
# Test
319+
$users = Get-AzureADUser -Mail $mail
320+
321+
# Assert
322+
Assert-AreEqual $users.Count 1
323+
Assert-AreEqual $users[0].Mail $mail
324+
Assert-NotNull($users[0].DisplayName)
325+
Assert-NotNull($users[0].UserPrincipalName)
326+
}
327+
309328
<#
310329
.SYNOPSIS
311330
Tests getting Active Directory users.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/1449d5b7-8a83-47db-ae4c-9b03e888bad0/users?api-version=1.42-previewInternal",
5+
"EncodedRequestUri": "LzE0NDlkNWI3LThhODMtNDdkYi1hZTRjLTliMDNlODg4YmFkMC91c2Vycz9hcGktdmVyc2lvbj0xLjQyLXByZXZpZXdJbnRlcm5hbA==",
6+
"RequestMethod": "POST",
7+
"RequestBody": "{\r\n \"userPrincipalName\": \"aduser6859@rbactest.onmicrosoft.com\",\r\n \"accountEnabled\": true,\r\n \"displayName\": \"aduser6859\",\r\n \"mailNickname\": \"aduser6859test\",\r\n \"passwordProfile\": {\r\n \"password\": \"adpass39990#$\",\r\n \"forceChangePasswordNextLogin\": false\r\n }\r\n}",
8+
"RequestHeaders": {
9+
"Content-Type": [
10+
"application/json; charset=utf-8"
11+
],
12+
"Content-Length": [
13+
"269"
14+
],
15+
"User-Agent": [
16+
"Microsoft.Azure.Graph.RBAC.GraphRbacManagementClient/1.0.0.0"
17+
]
18+
},
19+
"ResponseBody": "{\r\n \"odata.metadata\": \"https://graph.windows.net/1449d5b7-8a83-47db-ae4c-9b03e888bad0/$metadata#directoryObjects/Microsoft.WindowsAzure.ActiveDirectory.User/@Element\",\r\n \"odata.type\": \"Microsoft.WindowsAzure.ActiveDirectory.User\",\r\n \"objectType\": \"User\",\r\n \"objectId\": \"624fb7e1-f0e9-4bd0-94e4-6be174330d7a\",\r\n \"softDeletionTimestamp\": null,\r\n \"acceptedAs\": null,\r\n \"acceptedOn\": null,\r\n \"accountEnabled\": true,\r\n \"alternativeSecurityIds\": [],\r\n \"appMetadata\": null,\r\n \"assignedLicenses\": [],\r\n \"assignedPlans\": [],\r\n \"city\": null,\r\n \"country\": null,\r\n \"creationType\": null,\r\n \"department\": null,\r\n \"dirSyncEnabled\": null,\r\n \"displayName\": \"aduser6859\",\r\n \"extensionAttribute1\": null,\r\n \"extensionAttribute2\": null,\r\n \"extensionAttribute3\": null,\r\n \"extensionAttribute4\": null,\r\n \"extensionAttribute5\": null,\r\n \"extensionAttribute6\": null,\r\n \"extensionAttribute7\": null,\r\n \"extensionAttribute8\": null,\r\n \"extensionAttribute9\": null,\r\n \"extensionAttribute10\": null,\r\n \"extensionAttribute11\": null,\r\n \"extensionAttribute12\": null,\r\n \"extensionAttribute13\": null,\r\n \"extensionAttribute14\": null,\r\n \"extensionAttribute15\": null,\r\n \"facsimileTelephoneNumber\": null,\r\n \"givenName\": null,\r\n \"immutableId\": null,\r\n \"invitedOn\": null,\r\n \"inviteReplyUrl\": [],\r\n \"inviteResources\": [],\r\n \"inviteTicket\": [],\r\n \"isCompromised\": null,\r\n \"jobTitle\": null,\r\n \"jrnlAddress\": null,\r\n \"lastDirSyncTime\": null,\r\n \"logonIdentifiers\": [],\r\n \"mail\": null,\r\n \"mailNickname\": \"aduser6859test\",\r\n \"mobile\": null,\r\n \"netId\": \"1003BFFD8CE8F616\",\r\n \"onPremiseSecurityIdentifier\": null,\r\n \"otherMails\": [],\r\n \"passwordPolicies\": null,\r\n \"passwordProfile\": null,\r\n \"physicalDeliveryOfficeName\": null,\r\n \"postalCode\": null,\r\n \"preferredLanguage\": null,\r\n \"primarySMTPAddress\": null,\r\n \"provisionedPlans\": [],\r\n \"provisioningErrors\": [],\r\n \"proxyAddresses\": [],\r\n \"searchableDeviceKey\": [],\r\n \"selfServePasswordResetData\": null,\r\n \"signInName\": \"aduser6859@rbactest.onmicrosoft.com\",\r\n \"sipProxyAddress\": null,\r\n \"smtpAddresses\": [],\r\n \"state\": null,\r\n \"streetAddress\": null,\r\n \"surname\": null,\r\n \"telephoneNumber\": null,\r\n \"usageLocation\": null,\r\n \"userPrincipalName\": \"aduser6859@rbactest.onmicrosoft.com\",\r\n \"userState\": null,\r\n \"userStateChangedOn\": null,\r\n \"userType\": \"Member\"\r\n}",
20+
"ResponseHeaders": {
21+
"Content-Length": [
22+
"1955"
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+
"VbwAPpHBrDNXWFpR18OzHh/NfNdUKGwRD1NUkhGV+bc="
35+
],
36+
"request-id": [
37+
"515f205d-bfa4-43d9-8e8c-0efcc12628e5"
38+
],
39+
"client-request-id": [
40+
"ee413c51-7f45-4f90-9ea2-9fe81a052b35"
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+
"7pQeXZlxkCDyFVMe9qlvVNcY1zjLI89KWuj5wy4_7s_J8zs7sTod6U8rZqUcKE7Vckag9APQpW7mjnS3_SlRN4cMrAQtIMeVsdhGmcREH3BF5GF7ITYtkVDqOMw56FczqCcGeLyKhHEcK_k_5n_NmA.hMGeoesuXuqu5sM0QGtrgvAc2dPtLGyJ8bDadv01RoM"
50+
],
51+
"X-Content-Type-Options": [
52+
"nosniff"
53+
],
54+
"DataServiceVersion": [
55+
"3.0;"
56+
],
57+
"Strict-Transport-Security": [
58+
"max-age=15724800; includeSubDomains"
59+
],
60+
"Cache-Control": [
61+
"no-cache"
62+
],
63+
"Location": [
64+
"https://graph.windows.net/1449d5b7-8a83-47db-ae4c-9b03e888bad0/directoryObjects/624fb7e1-f0e9-4bd0-94e4-6be174330d7a/Microsoft.WindowsAzure.ActiveDirectory.User"
65+
],
66+
"Server": [
67+
"Microsoft-IIS/8.5"
68+
],
69+
"X-AspNet-Version": [
70+
"4.0.30319"
71+
],
72+
"X-Powered-By": [
73+
"ASP.NET",
74+
"ASP.NET"
75+
],
76+
"Date": [
77+
"Fri, 12 Dec 2014 19:50:12 GMT"
78+
]
79+
},
80+
"StatusCode": 201
81+
},
82+
{
83+
"RequestUri": "/1449d5b7-8a83-47db-ae4c-9b03e888bad0/users?$filter=signInName%20eq%20'aduser6859%40rbactest.onmicrosoft.com'&api-version=1.42-previewInternal",
84+
"EncodedRequestUri": "LzE0NDlkNWI3LThhODMtNDdkYi1hZTRjLTliMDNlODg4YmFkMC91c2Vycz8kZmlsdGVyPXNpZ25Jbk5hbWUlMjBlcSUyMCdhZHVzZXI2ODU5JTQwcmJhY3Rlc3Qub25taWNyb3NvZnQuY29tJyZhcGktdmVyc2lvbj0xLjQyLXByZXZpZXdJbnRlcm5hbA==",
85+
"RequestMethod": "GET",
86+
"RequestBody": "",
87+
"RequestHeaders": {
88+
"User-Agent": [
89+
"Microsoft.Azure.Graph.RBAC.GraphRbacManagementClient/1.0.0.0"
90+
]
91+
},
92+
"ResponseBody": "{\r\n \"odata.metadata\": \"https://graph.windows.net/1449d5b7-8a83-47db-ae4c-9b03e888bad0/$metadata#directoryObjects/Microsoft.WindowsAzure.ActiveDirectory.User\",\r\n \"value\": [\r\n {\r\n \"odata.type\": \"Microsoft.WindowsAzure.ActiveDirectory.User\",\r\n \"objectType\": \"User\",\r\n \"objectId\": \"624fb7e1-f0e9-4bd0-94e4-6be174330d7a\",\r\n \"softDeletionTimestamp\": null,\r\n \"acceptedAs\": null,\r\n \"acceptedOn\": null,\r\n \"accountEnabled\": true,\r\n \"alternativeSecurityIds\": [],\r\n \"appMetadata\": null,\r\n \"assignedLicenses\": [],\r\n \"assignedPlans\": [],\r\n \"city\": null,\r\n \"country\": null,\r\n \"creationType\": null,\r\n \"department\": null,\r\n \"dirSyncEnabled\": null,\r\n \"displayName\": \"aduser6859\",\r\n \"extensionAttribute1\": null,\r\n \"extensionAttribute2\": null,\r\n \"extensionAttribute3\": null,\r\n \"extensionAttribute4\": null,\r\n \"extensionAttribute5\": null,\r\n \"extensionAttribute6\": null,\r\n \"extensionAttribute7\": null,\r\n \"extensionAttribute8\": null,\r\n \"extensionAttribute9\": null,\r\n \"extensionAttribute10\": null,\r\n \"extensionAttribute11\": null,\r\n \"extensionAttribute12\": null,\r\n \"extensionAttribute13\": null,\r\n \"extensionAttribute14\": null,\r\n \"extensionAttribute15\": null,\r\n \"facsimileTelephoneNumber\": null,\r\n \"givenName\": null,\r\n \"immutableId\": null,\r\n \"invitedOn\": null,\r\n \"inviteReplyUrl\": [],\r\n \"inviteResources\": [],\r\n \"inviteTicket\": [],\r\n \"isCompromised\": null,\r\n \"jobTitle\": null,\r\n \"jrnlAddress\": null,\r\n \"lastDirSyncTime\": null,\r\n \"logonIdentifiers\": [],\r\n \"mail\": null,\r\n \"mailNickname\": \"aduser6859test\",\r\n \"mobile\": null,\r\n \"netId\": \"1003BFFD8CE8F616\",\r\n \"onPremiseSecurityIdentifier\": null,\r\n \"otherMails\": [],\r\n \"passwordPolicies\": null,\r\n \"passwordProfile\": null,\r\n \"physicalDeliveryOfficeName\": null,\r\n \"postalCode\": null,\r\n \"preferredLanguage\": null,\r\n \"primarySMTPAddress\": null,\r\n \"provisionedPlans\": [],\r\n \"provisioningErrors\": [],\r\n \"proxyAddresses\": [],\r\n \"searchableDeviceKey\": [],\r\n \"selfServePasswordResetData\": null,\r\n \"signInName\": \"aduser6859@rbactest.onmicrosoft.com\",\r\n \"sipProxyAddress\": null,\r\n \"smtpAddresses\": [],\r\n \"state\": null,\r\n \"streetAddress\": null,\r\n \"surname\": null,\r\n \"telephoneNumber\": null,\r\n \"usageLocation\": null,\r\n \"userPrincipalName\": \"aduser6859@rbactest.onmicrosoft.com\",\r\n \"userState\": null,\r\n \"userStateChangedOn\": null,\r\n \"userType\": \"Member\"\r\n }\r\n ]\r\n}",
93+
"ResponseHeaders": {
94+
"Content-Length": [
95+
"1958"
96+
],
97+
"Content-Type": [
98+
"application/json; odata=minimalmetadata; streaming=true; charset=utf-8"
99+
],
100+
"Expires": [
101+
"-1"
102+
],
103+
"Pragma": [
104+
"no-cache"
105+
],
106+
"ocp-aad-diagnostics-server-name": [
107+
"VbwAPpHBrDNXWFpR18OzHh/NfNdUKGwRD1NUkhGV+bc="
108+
],
109+
"request-id": [
110+
"b0d0b4b3-4455-46fc-81ee-53152a0302c3"
111+
],
112+
"client-request-id": [
113+
"5009830e-a05a-495f-80d6-6505e91eca79"
114+
],
115+
"x-ms-gateway-rewrite": [
116+
"false"
117+
],
118+
"x-ms-dirapi-data-contract-version": [
119+
"1.42-previewInternal"
120+
],
121+
"ocp-aad-session-key": [
122+
"2KTRY1wJ6jc3C2KvLU-HPLXlHPSSLnwVl6erB6dGxlcUiieIf8wHyqtlMhR7MAPzV7ZO1OB2QWbCqgSZ4QlMITokGSuJDLf8upMI0ZS6bgP7U23x0paEGaN_Xq_VB8FnMLBNWydY3yJ5pdGaEDKp2A.moFqgqvaMEXVR4QXDiWPbSaEvBsMDyvyKU7SI3fKyMc"
123+
],
124+
"X-Content-Type-Options": [
125+
"nosniff"
126+
],
127+
"DataServiceVersion": [
128+
"3.0;"
129+
],
130+
"Strict-Transport-Security": [
131+
"max-age=15724800; includeSubDomains"
132+
],
133+
"Cache-Control": [
134+
"no-cache"
135+
],
136+
"Server": [
137+
"Microsoft-IIS/8.5"
138+
],
139+
"X-AspNet-Version": [
140+
"4.0.30319"
141+
],
142+
"X-Powered-By": [
143+
"ASP.NET",
144+
"ASP.NET"
145+
],
146+
"Date": [
147+
"Fri, 12 Dec 2014 19:50:14 GMT"
148+
]
149+
},
150+
"StatusCode": 200
151+
},
152+
{
153+
"RequestUri": "/1449d5b7-8a83-47db-ae4c-9b03e888bad0/users/624fb7e1-f0e9-4bd0-94e4-6be174330d7a?api-version=1.42-previewInternal",
154+
"EncodedRequestUri": "LzE0NDlkNWI3LThhODMtNDdkYi1hZTRjLTliMDNlODg4YmFkMC91c2Vycy82MjRmYjdlMS1mMGU5LTRiZDAtOTRlNC02YmUxNzQzMzBkN2E/YXBpLXZlcnNpb249MS40Mi1wcmV2aWV3SW50ZXJuYWw=",
155+
"RequestMethod": "DELETE",
156+
"RequestBody": "",
157+
"RequestHeaders": {
158+
"User-Agent": [
159+
"Microsoft.Azure.Graph.RBAC.GraphRbacManagementClient/1.0.0.0"
160+
]
161+
},
162+
"ResponseBody": "",
163+
"ResponseHeaders": {
164+
"Expires": [
165+
"-1"
166+
],
167+
"Pragma": [
168+
"no-cache"
169+
],
170+
"ocp-aad-diagnostics-server-name": [
171+
"VbwAPpHBrDNXWFpR18OzHh/NfNdUKGwRD1NUkhGV+bc="
172+
],
173+
"request-id": [
174+
"136e45ca-4a69-44e9-8cd2-4371aef57868"
175+
],
176+
"client-request-id": [
177+
"1da1480a-638f-47d8-b6f2-8ed4e6980027"
178+
],
179+
"x-ms-gateway-rewrite": [
180+
"false"
181+
],
182+
"x-ms-dirapi-data-contract-version": [
183+
"1.42-previewInternal"
184+
],
185+
"ocp-aad-session-key": [
186+
"HolbQidtxArNqvDuekS9inE2xJViCAJ8wwVq-HOxPCIEEaeXhvkcqJOuuzATNwpX7g6ECj5TTIYM4IQtJMfR4hO9hySjQXS-yVwR4UBwHvliCqYkLFql_BdMnxmpSs6Txd8CvUByIHz-J_xdPTy6Kw.S_dVfFzvVrqJMiERTrn-T8-h8eTXiBM2RgDogdfVEFc"
187+
],
188+
"X-Content-Type-Options": [
189+
"nosniff"
190+
],
191+
"DataServiceVersion": [
192+
"1.0;"
193+
],
194+
"Strict-Transport-Security": [
195+
"max-age=15724800; includeSubDomains"
196+
],
197+
"Cache-Control": [
198+
"no-cache"
199+
],
200+
"Server": [
201+
"Microsoft-IIS/8.5"
202+
],
203+
"X-AspNet-Version": [
204+
"4.0.30319"
205+
],
206+
"X-Powered-By": [
207+
"ASP.NET",
208+
"ASP.NET"
209+
],
210+
"Date": [
211+
"Fri, 12 Dec 2014 19:50:16 GMT"
212+
]
213+
},
214+
"StatusCode": 204
215+
}
216+
],
217+
"Names": {
218+
"CreateNewAdUser": [
219+
"aduser6859",
220+
"adpass3999"
221+
]
222+
},
223+
"Variables": {
224+
"SubscriptionId": "3ca49042-782a-4cc9-89b5-ee1b487fe115",
225+
"TenantId": "1449d5b7-8a83-47db-ae4c-9b03e888bad0",
226+
"Domain": "rbactest.onmicrosoft.com"
227+
}
228+
}

src/ResourceManager/Resources/Commands.Resources/ActiveDirectory/GetAzureADUserCommand.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,20 @@ public class GetAzureADUserCommand : ActiveDirectoryBaseCmdlet
4444
[Alias("UPN")]
4545
public string UserPrincipalName { get; set; }
4646

47+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.Mail,
48+
HelpMessage = "The user mail.")]
49+
[ValidateNotNullOrEmpty]
50+
public string Mail { get; set; }
51+
4752
public override void ExecuteCmdlet()
4853
{
4954
ADObjectFilterOptions options = new ADObjectFilterOptions
5055
{
5156
SearchString = SearchString,
5257
UPN = UserPrincipalName,
5358
Id = ObjectId == Guid.Empty ? null : ObjectId.ToString(),
54-
Paging = true
59+
Paging = true,
60+
Mail = Mail
5561
};
5662

5763
do

src/ResourceManager/Sql/Commands.Sql.Test/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Hydra.HttpRecorder" version="1.0.5406.28672-prerelease" targetFramework="net45" />
4-
<package id="Hydra.SpecTestSupport" version="1.0.5406.28672-prerelease" targetFramework="net45" />
3+
<package id="Hydra.HttpRecorder" version="1.0.5417.13285-prerelease" targetFramework="net45" />
4+
<package id="Hydra.SpecTestSupport" version="1.0.5417.13285-prerelease" targetFramework="net45" />
55
<package id="Microsoft.Azure.Gallery" version="2.2.1-preview" targetFramework="net45" />
66
<package id="Microsoft.Azure.Management.Resources" version="2.7.1-preview" targetFramework="net45" />
77
<package id="Microsoft.Azure.Management.Sql" version="0.14.3-prerelease" targetFramework="net45" />

0 commit comments

Comments
 (0)