Skip to content

Commit 1f17434

Browse files
committed
RoleAssignment fixes
1 parent 6caf154 commit 1f17434

File tree

10 files changed

+86
-218
lines changed

10 files changed

+86
-218
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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/ActiveDirectoryClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// you may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
77
// http://www.apache.org/licenses/LICENSE-2.0
8-
// Unless required by applicable law or agreed to in writing, softwareF
8+
// Unless required by applicable law or agreed to in writing, software
99
// distributed under the License is distributed on an "AS IS" BASIS,
1010
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111
// See the License for the specific language governing permissions and

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,14 @@ 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

3735
public const string ScopeWithSignInName = "ScopeWithSignInNameParameterSet";
@@ -40,19 +38,13 @@ internal static class ParameterSet
4038

4139
public const string ResourceGroup = "ResourceGroupParameterSet";
4240

43-
public const string ResourceGroupWithMail = "ResourceGroupWithMailParameterSet";
44-
45-
public const string ResourceGroupWithUPN = "ResourceGroupWithUPNParameterSet";
46-
4741
public const string ResourceGroupWithSPN = "ResourceGroupWithSPNParameterSet";
4842

4943
public const string ResourceGroupWithObjectId = "ResourceGroupWithObjectIdParameterSet";
5044

51-
public const string Resource = "ResourceParameterSet";
52-
53-
public const string ResourceWithMail = "ResourceWithMailParameterSet";
45+
public const string ResourceGroupWithSignInName = "ResourceGroupWithSignInNameParameterSet";
5446

55-
public const string ResourceWithUPN = "ResourceWithUPNParameterSet";
47+
public const string Resource = "ResourceParameterSet";
5648

5749
public const string ResourceWithSPN = "ResourceWithSPNParameterSet";
5850

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ public static IEnumerable<PSRoleAssignment> ToPSRoleAssignments(this IEnumerable
6767
{
6868
psAssignments.Add(new PSRoleAssignment()
6969
{
70-
RoleAssignmentId = assignment.Name.ToString(),
70+
RoleAssignmentId = assignment.Id,
7171
DisplayName = adObject.DisplayName,
72-
RoleDefinitionId = roleDefinition.Id, //*****check
72+
RoleDefinitionId = roleDefinition.Id.GuidFromFullyQualifiedId(),
7373
RoleDefinitionName = roleDefinition.Name,
7474
Scope = assignment.Properties.Scope,
7575
SignInName = ((PSADUser)adObject).SignInName,
@@ -81,9 +81,9 @@ public static IEnumerable<PSRoleAssignment> ToPSRoleAssignments(this IEnumerable
8181
{
8282
psAssignments.Add(new PSRoleAssignment()
8383
{
84-
RoleAssignmentId = assignment.Name.ToString(),
84+
RoleAssignmentId = assignment.Id,
8585
DisplayName = adObject.DisplayName,
86-
RoleDefinitionId = roleDefinition.Id, //*****check
86+
RoleDefinitionId = roleDefinition.Id.GuidFromFullyQualifiedId(),
8787
RoleDefinitionName = roleDefinition.Name,
8888
Scope = assignment.Properties.Scope,
8989
ObjectId = adObject.Id,
@@ -94,9 +94,9 @@ public static IEnumerable<PSRoleAssignment> ToPSRoleAssignments(this IEnumerable
9494
{
9595
psAssignments.Add(new PSRoleAssignment()
9696
{
97-
RoleAssignmentId = assignment.Name.ToString(),
97+
RoleAssignmentId = assignment.Id,
9898
DisplayName = adObject.DisplayName,
99-
RoleDefinitionId = roleDefinition.Id, //*****check
99+
RoleDefinitionId = roleDefinition.Id.GuidFromFullyQualifiedId(),
100100
RoleDefinitionName = roleDefinition.Name,
101101
Scope = assignment.Properties.Scope,
102102
ObjectId = adObject.Id,
@@ -107,9 +107,9 @@ public static IEnumerable<PSRoleAssignment> ToPSRoleAssignments(this IEnumerable
107107
{
108108
psAssignments.Add(new PSRoleAssignment()
109109
{
110-
RoleAssignmentId = assignment.Name.ToString(),
110+
RoleAssignmentId = assignment.Id,
111111
DisplayName = adObject.DisplayName,
112-
RoleDefinitionId = roleDefinition.Id, //*****check
112+
RoleDefinitionId = roleDefinition.Id.GuidFromFullyQualifiedId(),
113113
RoleDefinitionName = roleDefinition.Name,
114114
Scope = assignment.Properties.Scope,
115115
ObjectId = adObject.Id,
@@ -129,8 +129,13 @@ public static PSRoleAssignment ToPSRoleAssignment(this ClassicAdministrator clas
129129
RoleDefinitionName = classicAdministrator.Properties.Role,
130130
DisplayName = classicAdministrator.Properties.EmailAddress,
131131
Scope = "/subscriptions/" + currentSubscriptionId,
132-
Actions = new List<string>() {"*"}
132+
ObjectType = "User"
133133
};
134134
}
135+
136+
private static string GuidFromFullyQualifiedId(this string Id)
137+
{
138+
return Id.TrimEnd('/').Substring(Id.LastIndexOf('/') + 1);
139+
}
135140
}
136141
}

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

Lines changed: 0 additions & 22 deletions
This file was deleted.

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

Lines changed: 0 additions & 22 deletions
This file was deleted.

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

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)