Skip to content

Commit 467889a

Browse files
committed
Merge pull request Azure#109 from Azure/dev
.
2 parents 3970450 + 5d7c796 commit 467889a

32 files changed

+244
-335
lines changed

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/ComputeNodeUserTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function Test-UpdateComputeNodeUser
4949
{
5050
param([string]$accountName, [string]$poolId, [string]$computeNodeId, [string]$userName)
5151

52-
$context = Get-AzureRMBatchAccountKeys -Name $accountName
52+
$context = Get-AzureRmBatchAccountKeys -Name $accountName
5353

5454
# Basically just validating that we can set the parameters and execute the cmdlet without error.
5555
# If a Get user API is added, we can validate that the properties were actually updated.

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/JobScheduleTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ function Test-UpdateJobSchedule
336336
{
337337
param([string]$accountName, [string]$jobScheduleId)
338338

339-
$context = Get-AzureRMBatchAccountKeys -Name $accountName
339+
$context = Get-AzureRmBatchAccountKeys -Name $accountName
340340

341341
$jobSchedule = Get-AzureBatchJobSchedule_ST $jobScheduleId -BatchContext $context
342342

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/JobTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ function Test-UpdateJob
333333
{
334334
param([string]$accountName, [string]$jobId)
335335

336-
$context = Get-AzureRMBatchAccountKeys -Name $accountName
336+
$context = Get-AzureRmBatchAccountKeys -Name $accountName
337337

338338
# Create the job with an auto pool
339339
$poolSpec = New-Object Microsoft.Azure.Commands.Batch.Models.PSPoolSpecification

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/PoolTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function Test-UpdatePool
172172
{
173173
param([string]$accountName, [string]$poolId)
174174

175-
$context = Get-AzureRMBatchAccountKeys -Name $accountName
175+
$context = Get-AzureRmBatchAccountKeys -Name $accountName
176176

177177
$pool = Get-AzureBatchPool_ST $poolId -BatchContext $context
178178

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/TaskTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function Test-UpdateTask
183183
{
184184
param([string]$accountName, [string]$jobId, [string]$taskId)
185185

186-
$context = Get-AzureRMBatchAccountKeys -Name $accountName
186+
$context = Get-AzureRmBatchAccountKeys -Name $accountName
187187

188188
$task = Get-AzureBatchTask_ST $jobId $taskId -BatchContext $context
189189

src/ResourceManager/AzureBatch/Commands.Batch/Accounts/GetBatchAccountCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace Microsoft.Azure.Commands.Batch
2020
{
21-
[Cmdlet(VerbsCommon.Get, Constants.AzureRMBatchAccount), OutputType(typeof(BatchAccountContext))]
21+
[Cmdlet(VerbsCommon.Get, Constants.AzureRmBatchAccount), OutputType(typeof(BatchAccountContext))]
2222
public class GetBatchAccountCommand : BatchCmdletBase
2323
{
2424
[Alias("Name")]

src/ResourceManager/AzureBatch/Commands.Batch/Accounts/GetBatchAccountKeysCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
namespace Microsoft.Azure.Commands.Batch
1919
{
20-
[Cmdlet(VerbsCommon.Get, Constants.AzureRMBatchAccountKeys), OutputType(typeof(BatchAccountContext))]
20+
[Cmdlet(VerbsCommon.Get, Constants.AzureRmBatchAccountKeys), OutputType(typeof(BatchAccountContext))]
2121
public class GetBatchAccountKeysCommand : BatchCmdletBase
2222
{
2323
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true,

src/ResourceManager/AzureBatch/Commands.Batch/Accounts/NewBatchAccountCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace Microsoft.Azure.Commands.Batch
2020
{
21-
[Cmdlet(VerbsCommon.New, Constants.AzureRMBatchAccount), OutputType(typeof(BatchAccountContext))]
21+
[Cmdlet(VerbsCommon.New, Constants.AzureRmBatchAccount), OutputType(typeof(BatchAccountContext))]
2222
public class NewBatchAccountCommand : BatchCmdletBase
2323
{
2424
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true,

src/ResourceManager/AzureBatch/Commands.Batch/Accounts/NewBatchAccountKeyCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace Microsoft.Azure.Commands.Batch
2020
{
21-
[Cmdlet(VerbsCommon.New, Constants.AzureRMBatchAccountKey), OutputType(typeof(BatchAccountContext))]
21+
[Cmdlet(VerbsCommon.New, Constants.AzureRmBatchAccountKey), OutputType(typeof(BatchAccountContext))]
2222
public class RegenBatchAccountKeyCommand : BatchCmdletBase
2323
{
2424
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true,

src/ResourceManager/AzureBatch/Commands.Batch/Accounts/RemoveBatchAccountCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace Microsoft.Azure.Commands.Batch
2020
{
21-
[Cmdlet(VerbsCommon.Remove, Constants.AzureRMBatchAccount)]
21+
[Cmdlet(VerbsCommon.Remove, Constants.AzureRmBatchAccount)]
2222
public class RemoveBatchAccountCommand : BatchCmdletBase
2323
{
2424
private static string mamlCall = "RemoveAccount";

src/ResourceManager/AzureBatch/Commands.Batch/Accounts/SetBatchAccountCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace Microsoft.Azure.Commands.Batch
2020
{
21-
[Cmdlet(VerbsCommon.Set, Constants.AzureRMBatchAccount), OutputType(typeof(BatchAccountContext))]
21+
[Cmdlet(VerbsCommon.Set, Constants.AzureRmBatchAccount), OutputType(typeof(BatchAccountContext))]
2222
public class SetBatchAccountCommand : BatchCmdletBase
2323
{
2424
[Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true,

src/ResourceManager/AzureBatch/Commands.Batch/Utils/Constants.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public class Constants
1919
public const int DefaultMaxCount = 1000;
2020

2121
// ARM cmdlet nouns
22-
public const string AzureRMBatchAccount = "AzureRmBatchAccount";
23-
public const string AzureRMBatchAccountKey = "AzureRmBatchAccountKey";
24-
public const string AzureRMBatchAccountKeys = "AzureRmBatchAccountKeys";
22+
public const string AzureRmBatchAccount = "AzureRmBatchAccount";
23+
public const string AzureRmBatchAccountKey = "AzureRmBatchAccountKey";
24+
public const string AzureRmBatchAccountKeys = "AzureRmBatchAccountKeys";
2525

2626
// Batch Service cmdlet nouns
2727
public const string AzureBatchPool = "AzureBatchPool";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
</Reference>
6363
<Reference Include="Microsoft.Azure.Graph.RBAC">
6464
<SpecificVersion>False</SpecificVersion>
65-
<HintPath>..\..\..\packages\Microsoft.Azure.Graph.RBAC.1.7.0-preview\lib\net40\Microsoft.Azure.Graph.RBAC.dll</HintPath>
65+
<HintPath>..\..\..\packages\Microsoft.Azure.Graph.RBAC.1.7.1-preview\lib\net40\Microsoft.Azure.Graph.RBAC.dll</HintPath>
6666
</Reference>
6767
<Reference Include="Microsoft.Azure.Insights">
6868
<HintPath>..\..\..\packages\Microsoft.Azure.Insights.0.7.7-preview\lib\net45\Microsoft.Azure.Insights.dll</HintPath>

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
</Reference>
6767
<Reference Include="Microsoft.Azure.Graph.RBAC">
6868
<SpecificVersion>False</SpecificVersion>
69-
<HintPath>..\..\..\packages\Microsoft.Azure.Graph.RBAC.1.7.0-preview\lib\net40\Microsoft.Azure.Graph.RBAC.dll</HintPath>
69+
<HintPath>..\..\..\packages\Microsoft.Azure.Graph.RBAC.1.7.1-preview\lib\net40\Microsoft.Azure.Graph.RBAC.dll</HintPath>
7070
</Reference>
7171
<Reference Include="Microsoft.Azure.Management.Authorization">
7272
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
@@ -165,9 +165,6 @@
165165
<Compile Include="Models.Authorization\FilterRoleAssignmentsOptions.cs" />
166166
<Compile Include="Models.ActiveDirectory\ActiveDirectoryClient.cs" />
167167
<Compile Include="Models.Authorization\AuthorizationClientExtensions.cs" />
168-
<Compile Include="Models.Authorization\PSGroupRoleAssignment.cs" />
169-
<Compile Include="Models.Authorization\PSServiceRoleAssignment.cs" />
170-
<Compile Include="Models.Authorization\PSUserRoleAssignment.cs" />
171168
<Compile Include="Models.Authorization\PSRoleAssignment.cs" />
172169
<Compile Include="Models.Authorization\PSRoleDefinition.cs" />
173170
<Compile Include="Models.Authorization\PSPermission.cs" />

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class ADObjectFilterOptions
1919
{
2020
public string SearchString { get; set; }
2121

22+
public string SignInName { get; set; }
23+
2224
public string Mail { get; set; }
2325

2426
public string UPN { get; set; }
@@ -48,6 +50,8 @@ public string ActiveFilter
4850
return SPN;
4951
else if (!string.IsNullOrEmpty(Mail))
5052
return Mail;
53+
else if (!string.IsNullOrEmpty(SignInName))
54+
return SignInName;
5155
else if (!string.IsNullOrEmpty(SearchString))
5256
return SearchString;
5357
else

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public PSADObject GetADObject(ADObjectFilterOptions options)
4747

4848
Debug.Assert(options != null);
4949

50-
if (IsSet(options.Mail, options.UPN, options.Id))
50+
if (IsSet(options.SignInName, options.Mail, options.UPN, options.Id))
5151
{
5252
result = FilterUsers(options).FirstOrDefault();
5353
}
@@ -163,11 +163,11 @@ public List<PSADUser> FilterUsers(ADObjectFilterOptions options)
163163
users.Add(user.ToPSADUser());
164164
}
165165
}
166-
else if (!string.IsNullOrEmpty(options.Mail))
166+
else if (!string.IsNullOrEmpty(options.Mail) || !string.IsNullOrEmpty(options.SignInName))
167167
{
168168
try
169169
{
170-
user = GraphClient.User.GetBySignInName(options.Mail).Users.FirstOrDefault();
170+
user = GraphClient.User.GetBySignInName(Normalize(options.Mail) ?? Normalize(options.SignInName)).Users.FirstOrDefault();
171171
}
172172
catch { /* The user does not exist, ignore the exception. */ }
173173

@@ -225,6 +225,14 @@ public List<PSADObject> ListUserGroups(string principal)
225225
return result;
226226
}
227227

228+
public List<PSADObject> GetObjectsByObjectId(List<string> objectIds)
229+
{
230+
List<PSADObject> result = new List<PSADObject>();
231+
var adObjects = GraphClient.Objects.GetObjectsByObjectIds(new GetObjectsParameters { Ids = objectIds }).AADObject;
232+
result.AddRange(adObjects.Select(o => o.ToPSADObject()));
233+
return result;
234+
}
235+
228236
public List<PSADGroup> FilterGroups(ADObjectFilterOptions options)
229237
{
230238
List<PSADGroup> groups = new List<PSADGroup>();

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public static PSADObject ToPSADObject(this AADObject obj)
5151
Id = new Guid(obj.ObjectId),
5252
Type = obj.ObjectType,
5353
UserPrincipalName = obj.UserPrincipalName,
54+
SignInName = obj.SignInName,
5455
Mail = obj.Mail
5556
};
5657
}
@@ -66,6 +67,16 @@ public static PSADObject ToPSADObject(this AADObject obj)
6667
};
6768

6869
}
70+
else if (obj.ObjectType == typeof(ServicePrincipal).Name)
71+
{
72+
return new PSADServicePrincipal()
73+
{
74+
DisplayName = obj.DisplayName,
75+
Id = new Guid(obj.ObjectId),
76+
Type = obj.ObjectType,
77+
ServicePrincipalName = obj.ServicePrincipalNames.FirstOrDefault()
78+
};
79+
}
6980
else
7081
{
7182
return new PSADObject()
@@ -93,7 +104,8 @@ public static PSADUser ToPSADUser(this User user)
93104
DisplayName = user.DisplayName,
94105
Id = new Guid(user.ObjectId),
95106
UserPrincipalName = user.UserPrincipalName,
96-
Mail = user.SignInName
107+
Mail = user.SignInName,
108+
SignInName = user.SignInName
97109
};
98110
}
99111

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ public class PSADUser : PSADObject
1919
public string UserPrincipalName { get; set; }
2020

2121
public string Mail { get; set; }
22+
23+
public string SignInName { get; set; }
2224
}
2325
}

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,34 @@ internal static class ParameterSet
2222

2323
public const string SPN = "SPNParameterSet";
2424

25+
public const string SignInName = "SignInNameParameterSet";
26+
2527
public const string SearchString = "SearchStringParameterSet";
2628

2729
public const string ObjectId = "ObjectIdParameterSet";
2830

2931
public const string Scope = "ScopeParameterSet";
3032

31-
public const string ScopeWithMail = "ScopeWithMailParameterSet";
32-
33-
public const string ScopeWithUPN = "ScopeWithUPNParameterSet";
34-
3533
public const string ScopeWithSPN = "ScopeWithSPNParameterSet";
3634

35+
public const string ScopeWithSignInName = "ScopeWithSignInNameParameterSet";
36+
3737
public const string ScopeWithObjectId = "ScopeWithObjectIdParameterSet";
3838

3939
public const string ResourceGroup = "ResourceGroupParameterSet";
4040

41-
public const string ResourceGroupWithMail = "ResourceGroupWithMailParameterSet";
42-
43-
public const string ResourceGroupWithUPN = "ResourceGroupWithUPNParameterSet";
44-
4541
public const string ResourceGroupWithSPN = "ResourceGroupWithSPNParameterSet";
4642

4743
public const string ResourceGroupWithObjectId = "ResourceGroupWithObjectIdParameterSet";
4844

49-
public const string Resource = "ResourceParameterSet";
50-
51-
public const string ResourceWithMail = "ResourceWithMailParameterSet";
45+
public const string ResourceGroupWithSignInName = "ResourceGroupWithSignInNameParameterSet";
5246

53-
public const string ResourceWithUPN = "ResourceWithUPNParameterSet";
47+
public const string Resource = "ResourceParameterSet";
5448

5549
public const string ResourceWithSPN = "ResourceWithSPNParameterSet";
5650

51+
public const string ResourceWithSignInName = "ResourceWithSignInNameParameterSet";
52+
5753
public const string ResourceWithObjectId = "ResourceWithObjectIdParameterSet";
5854

5955
public const string ApplicationWithoutCredential = "ApplicationWithoutCredentialParameterSet";

src/ResourceManager/Resources/Commands.Resources/Models.Authorization/AuthorizationClient.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public PSRoleDefinition GetRoleDefinition(string roleId)
6868

6969
/// <summary>
7070
/// Filters the existing role Definitions.
71+
/// If name is not provided, all role definitions are fetched.
7172
/// </summary>
7273
/// <param name="name">The role name</param>
7374
/// <returns>The matched role Definitions</returns>
@@ -122,7 +123,11 @@ public PSRoleAssignment CreateRoleAssignment(FilterRoleAssignmentsOptions parame
122123
};
123124

124125
AuthorizationManagementClient.RoleAssignments.Create(parameters.Scope, roleAssignmentId, createParameters);
125-
return AuthorizationManagementClient.RoleAssignments.Get(parameters.Scope, roleAssignmentId).RoleAssignment.ToPSRoleAssignment(this, ActiveDirectoryClient);
126+
127+
RoleAssignment assignment = AuthorizationManagementClient.RoleAssignments.Get(parameters.Scope, roleAssignmentId).RoleAssignment;
128+
IEnumerable<RoleAssignment> assignments = new List<RoleAssignment>() { assignment };
129+
130+
return assignments.ToPSRoleAssignments(this, ActiveDirectoryClient).FirstOrDefault();
126131
}
127132

128133
/// <summary>
@@ -159,9 +164,10 @@ public List<PSRoleAssignment> FilterRoleAssignments(FilterRoleAssignmentsOptions
159164
{
160165
parameters.PrincipalId = string.IsNullOrEmpty(options.ADObjectFilter.Id) ? adObject.Id : Guid.Parse(options.ADObjectFilter.Id);
161166
}
162-
167+
163168
result.AddRange(AuthorizationManagementClient.RoleAssignments.List(parameters)
164-
.RoleAssignments.Select(r => r.ToPSRoleAssignment(this, ActiveDirectoryClient, options.ExcludeAssignmentsForDeletedPrincipals)).Where(r => r != null));
169+
.RoleAssignments.ToPSRoleAssignments(this, ActiveDirectoryClient, options.ExcludeAssignmentsForDeletedPrincipals));
170+
165171

166172
// Filter out by scope
167173
if (!string.IsNullOrEmpty(options.Scope))
@@ -173,13 +179,14 @@ public List<PSRoleAssignment> FilterRoleAssignments(FilterRoleAssignmentsOptions
173179
{
174180
// Filter by scope and above directly
175181
parameters.AtScope = true;
182+
176183
result.AddRange(AuthorizationManagementClient.RoleAssignments.ListForScope(options.Scope, parameters)
177-
.RoleAssignments.Select(r => r.ToPSRoleAssignment(this, ActiveDirectoryClient, options.ExcludeAssignmentsForDeletedPrincipals)).Where(r => r != null));
184+
.RoleAssignments.ToPSRoleAssignments(this, ActiveDirectoryClient, options.ExcludeAssignmentsForDeletedPrincipals));
178185
}
179186
else
180187
{
181188
result.AddRange(AuthorizationManagementClient.RoleAssignments.List(parameters)
182-
.RoleAssignments.Select(r => r.ToPSRoleAssignment(this, ActiveDirectoryClient, options.ExcludeAssignmentsForDeletedPrincipals)).Where(r => r != null));
189+
.RoleAssignments.ToPSRoleAssignments(this, ActiveDirectoryClient, options.ExcludeAssignmentsForDeletedPrincipals));
183190
}
184191

185192
if (!string.IsNullOrEmpty(options.RoleDefinition))
@@ -204,7 +211,8 @@ public List<PSRoleAssignment> FilterRoleAssignments(FilterRoleAssignmentsOptions
204211
var userObject = adObject as PSADUser;
205212
classicAdministratorsAssignments = classicAdministratorsAssignments.Where(c =>
206213
c.DisplayName.Equals(userObject.UserPrincipalName, StringComparison.OrdinalIgnoreCase) ||
207-
c.DisplayName.Equals(userObject.Mail, StringComparison.OrdinalIgnoreCase)).ToList();
214+
c.DisplayName.Equals(userObject.Mail, StringComparison.OrdinalIgnoreCase) ||
215+
c.DisplayName.Equals(userObject.SignInName, StringComparison.OrdinalIgnoreCase)).ToList();
208216
}
209217

210218
result.AddRange(classicAdministratorsAssignments);

0 commit comments

Comments
 (0)