Skip to content

Commit

Permalink
Merge pull request #44 from ogail/dev
Browse files Browse the repository at this point in the history
added filter by mail to get-AzureADUser [3136217]
  • Loading branch information
Hovsep committed Dec 12, 2014
2 parents 4995249 + b62cad9 commit 0cdfa9c
Show file tree
Hide file tree
Showing 6 changed files with 285 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@
<None Include="ScenarioTests\RoleAssignmentTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.ActiveDirectoryTests\TestGetADUserWithMail.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.ResourceGroupTests\TestNewDeploymentAndProviderRegistration.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,32 @@ public void TestGetADUserWithObjectId()
TestUtilities.GetCurrentMethodName());
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetADUserWithMail()
{
const string scriptMethod = "Test-GetADUserWithMail '{0}'";
User newUser = null;
var controllerAdmin = ResourcesController.NewInstance;

controllerAdmin.RunPsTestWorkflow(
// scriptBuilder
() =>
{
newUser = CreateNewAdUser(controllerAdmin);
return new[] { string.Format(scriptMethod, newUser.UserPrincipalName) };
},
// initialize
null,
// cleanup
() =>
{
DeleteAdUser(controllerAdmin, newUser);
},
TestUtilities.GetCallingClass(),
TestUtilities.GetCurrentMethodName());
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetADUserWithBadObjectId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,25 @@ function Test-GetADUserWithObjectId
Assert-NotNull($users[0].UserPrincipalName)
}


<#
.SYNOPSIS
Tests getting Active Directory users by mail.
#>
function Test-GetADUserWithMail
{
param([string]$mail)

# Test
$users = Get-AzureADUser -Mail $mail

# Assert
Assert-AreEqual $users.Count 1
Assert-AreEqual $users[0].Mail $mail
Assert-NotNull($users[0].DisplayName)
Assert-NotNull($users[0].UserPrincipalName)
}

<#
.SYNOPSIS
Tests getting Active Directory users.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
{
"Entries": [
{
"RequestUri": "/1449d5b7-8a83-47db-ae4c-9b03e888bad0/users?api-version=1.42-previewInternal",
"EncodedRequestUri": "LzE0NDlkNWI3LThhODMtNDdkYi1hZTRjLTliMDNlODg4YmFkMC91c2Vycz9hcGktdmVyc2lvbj0xLjQyLXByZXZpZXdJbnRlcm5hbA==",
"RequestMethod": "POST",
"RequestBody": "{\r\n \"userPrincipalName\": \"[email protected]\",\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}",
"RequestHeaders": {
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"269"
],
"User-Agent": [
"Microsoft.Azure.Graph.RBAC.GraphRbacManagementClient/1.0.0.0"
]
},
"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\": \"[email protected]\",\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\": \"[email protected]\",\r\n \"userState\": null,\r\n \"userStateChangedOn\": null,\r\n \"userType\": \"Member\"\r\n}",
"ResponseHeaders": {
"Content-Length": [
"1955"
],
"Content-Type": [
"application/json; odata=minimalmetadata; streaming=true; charset=utf-8"
],
"Expires": [
"-1"
],
"Pragma": [
"no-cache"
],
"ocp-aad-diagnostics-server-name": [
"VbwAPpHBrDNXWFpR18OzHh/NfNdUKGwRD1NUkhGV+bc="
],
"request-id": [
"515f205d-bfa4-43d9-8e8c-0efcc12628e5"
],
"client-request-id": [
"ee413c51-7f45-4f90-9ea2-9fe81a052b35"
],
"x-ms-gateway-rewrite": [
"false"
],
"x-ms-dirapi-data-contract-version": [
"1.42-previewInternal"
],
"ocp-aad-session-key": [
"7pQeXZlxkCDyFVMe9qlvVNcY1zjLI89KWuj5wy4_7s_J8zs7sTod6U8rZqUcKE7Vckag9APQpW7mjnS3_SlRN4cMrAQtIMeVsdhGmcREH3BF5GF7ITYtkVDqOMw56FczqCcGeLyKhHEcK_k_5n_NmA.hMGeoesuXuqu5sM0QGtrgvAc2dPtLGyJ8bDadv01RoM"
],
"X-Content-Type-Options": [
"nosniff"
],
"DataServiceVersion": [
"3.0;"
],
"Strict-Transport-Security": [
"max-age=15724800; includeSubDomains"
],
"Cache-Control": [
"no-cache"
],
"Location": [
"https://graph.windows.net/1449d5b7-8a83-47db-ae4c-9b03e888bad0/directoryObjects/624fb7e1-f0e9-4bd0-94e4-6be174330d7a/Microsoft.WindowsAzure.ActiveDirectory.User"
],
"Server": [
"Microsoft-IIS/8.5"
],
"X-AspNet-Version": [
"4.0.30319"
],
"X-Powered-By": [
"ASP.NET",
"ASP.NET"
],
"Date": [
"Fri, 12 Dec 2014 19:50:12 GMT"
]
},
"StatusCode": 201
},
{
"RequestUri": "/1449d5b7-8a83-47db-ae4c-9b03e888bad0/users?$filter=signInName%20eq%20'aduser6859%40rbactest.onmicrosoft.com'&api-version=1.42-previewInternal",
"EncodedRequestUri": "LzE0NDlkNWI3LThhODMtNDdkYi1hZTRjLTliMDNlODg4YmFkMC91c2Vycz8kZmlsdGVyPXNpZ25Jbk5hbWUlMjBlcSUyMCdhZHVzZXI2ODU5JTQwcmJhY3Rlc3Qub25taWNyb3NvZnQuY29tJyZhcGktdmVyc2lvbj0xLjQyLXByZXZpZXdJbnRlcm5hbA==",
"RequestMethod": "GET",
"RequestBody": "",
"RequestHeaders": {
"User-Agent": [
"Microsoft.Azure.Graph.RBAC.GraphRbacManagementClient/1.0.0.0"
]
},
"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\": \"[email protected]\",\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\": \"[email protected]\",\r\n \"userState\": null,\r\n \"userStateChangedOn\": null,\r\n \"userType\": \"Member\"\r\n }\r\n ]\r\n}",
"ResponseHeaders": {
"Content-Length": [
"1958"
],
"Content-Type": [
"application/json; odata=minimalmetadata; streaming=true; charset=utf-8"
],
"Expires": [
"-1"
],
"Pragma": [
"no-cache"
],
"ocp-aad-diagnostics-server-name": [
"VbwAPpHBrDNXWFpR18OzHh/NfNdUKGwRD1NUkhGV+bc="
],
"request-id": [
"b0d0b4b3-4455-46fc-81ee-53152a0302c3"
],
"client-request-id": [
"5009830e-a05a-495f-80d6-6505e91eca79"
],
"x-ms-gateway-rewrite": [
"false"
],
"x-ms-dirapi-data-contract-version": [
"1.42-previewInternal"
],
"ocp-aad-session-key": [
"2KTRY1wJ6jc3C2KvLU-HPLXlHPSSLnwVl6erB6dGxlcUiieIf8wHyqtlMhR7MAPzV7ZO1OB2QWbCqgSZ4QlMITokGSuJDLf8upMI0ZS6bgP7U23x0paEGaN_Xq_VB8FnMLBNWydY3yJ5pdGaEDKp2A.moFqgqvaMEXVR4QXDiWPbSaEvBsMDyvyKU7SI3fKyMc"
],
"X-Content-Type-Options": [
"nosniff"
],
"DataServiceVersion": [
"3.0;"
],
"Strict-Transport-Security": [
"max-age=15724800; includeSubDomains"
],
"Cache-Control": [
"no-cache"
],
"Server": [
"Microsoft-IIS/8.5"
],
"X-AspNet-Version": [
"4.0.30319"
],
"X-Powered-By": [
"ASP.NET",
"ASP.NET"
],
"Date": [
"Fri, 12 Dec 2014 19:50:14 GMT"
]
},
"StatusCode": 200
},
{
"RequestUri": "/1449d5b7-8a83-47db-ae4c-9b03e888bad0/users/624fb7e1-f0e9-4bd0-94e4-6be174330d7a?api-version=1.42-previewInternal",
"EncodedRequestUri": "LzE0NDlkNWI3LThhODMtNDdkYi1hZTRjLTliMDNlODg4YmFkMC91c2Vycy82MjRmYjdlMS1mMGU5LTRiZDAtOTRlNC02YmUxNzQzMzBkN2E/YXBpLXZlcnNpb249MS40Mi1wcmV2aWV3SW50ZXJuYWw=",
"RequestMethod": "DELETE",
"RequestBody": "",
"RequestHeaders": {
"User-Agent": [
"Microsoft.Azure.Graph.RBAC.GraphRbacManagementClient/1.0.0.0"
]
},
"ResponseBody": "",
"ResponseHeaders": {
"Expires": [
"-1"
],
"Pragma": [
"no-cache"
],
"ocp-aad-diagnostics-server-name": [
"VbwAPpHBrDNXWFpR18OzHh/NfNdUKGwRD1NUkhGV+bc="
],
"request-id": [
"136e45ca-4a69-44e9-8cd2-4371aef57868"
],
"client-request-id": [
"1da1480a-638f-47d8-b6f2-8ed4e6980027"
],
"x-ms-gateway-rewrite": [
"false"
],
"x-ms-dirapi-data-contract-version": [
"1.42-previewInternal"
],
"ocp-aad-session-key": [
"HolbQidtxArNqvDuekS9inE2xJViCAJ8wwVq-HOxPCIEEaeXhvkcqJOuuzATNwpX7g6ECj5TTIYM4IQtJMfR4hO9hySjQXS-yVwR4UBwHvliCqYkLFql_BdMnxmpSs6Txd8CvUByIHz-J_xdPTy6Kw.S_dVfFzvVrqJMiERTrn-T8-h8eTXiBM2RgDogdfVEFc"
],
"X-Content-Type-Options": [
"nosniff"
],
"DataServiceVersion": [
"1.0;"
],
"Strict-Transport-Security": [
"max-age=15724800; includeSubDomains"
],
"Cache-Control": [
"no-cache"
],
"Server": [
"Microsoft-IIS/8.5"
],
"X-AspNet-Version": [
"4.0.30319"
],
"X-Powered-By": [
"ASP.NET",
"ASP.NET"
],
"Date": [
"Fri, 12 Dec 2014 19:50:16 GMT"
]
},
"StatusCode": 204
}
],
"Names": {
"CreateNewAdUser": [
"aduser6859",
"adpass3999"
]
},
"Variables": {
"SubscriptionId": "3ca49042-782a-4cc9-89b5-ee1b487fe115",
"TenantId": "1449d5b7-8a83-47db-ae4c-9b03e888bad0",
"Domain": "rbactest.onmicrosoft.com"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,20 @@ public class GetAzureADUserCommand : ActiveDirectoryBaseCmdlet
[Alias("UPN")]
public string UserPrincipalName { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.Mail,
HelpMessage = "The user mail.")]
[ValidateNotNullOrEmpty]
public string Mail { get; set; }

public override void ExecuteCmdlet()
{
ADObjectFilterOptions options = new ADObjectFilterOptions
{
SearchString = SearchString,
UPN = UserPrincipalName,
Id = ObjectId == Guid.Empty ? null : ObjectId.ToString(),
Paging = true
Paging = true,
Mail = Mail
};

do
Expand Down
4 changes: 2 additions & 2 deletions src/ResourceManager/Sql/Commands.Sql.Test/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Hydra.HttpRecorder" version="1.0.5406.28672-prerelease" targetFramework="net45" />
<package id="Hydra.SpecTestSupport" version="1.0.5406.28672-prerelease" targetFramework="net45" />
<package id="Hydra.HttpRecorder" version="1.0.5417.13285-prerelease" targetFramework="net45" />
<package id="Hydra.SpecTestSupport" version="1.0.5417.13285-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Gallery" version="2.2.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.7.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Sql" version="0.14.3-prerelease" targetFramework="net45" />
Expand Down

0 comments on commit 0cdfa9c

Please sign in to comment.