Skip to content

Commit e590c75

Browse files
authored
Merge pull request #6008 from cormacpayne/resources-improvements
Resources improvements
2 parents 5919291 + f743f2f commit e590c75

File tree

173 files changed

+93040
-27789
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+93040
-27789
lines changed

src/Common/Commands.Common.Graph.RBAC/ActiveDirectory/ActiveDirectoryBaseCmdlet.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ private void HandleException(Exception exception)
7474
throw exception;
7575
}
7676
}
77-
77+
7878

7979
private Exception ParseResponse(GraphErrorException graphEx) {
8080
int exceptionMessageIndex = graphEx.Response.Content.IndexOf("\"value\":", StringComparison.CurrentCultureIgnoreCase);
81-
if (exceptionMessageIndex > 0)
81+
if (exceptionMessageIndex > 0)
8282
{
8383
string substring = graphEx.Response.Content.Substring(exceptionMessageIndex+9);
8484
// the start index is added 9, so as to remove the delimiter \"value\":\

src/Common/Commands.Common.Graph.RBAC/ActiveDirectory/ActiveDirectoryClient.cs

Lines changed: 211 additions & 176 deletions
Large diffs are not rendered by default.

src/Common/Commands.Common.Graph.RBAC/ActiveDirectory/ActiveDirectoryClientExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public static PSADObject ToPSADObject(this AADObject obj)
5959
DisplayName = obj.DisplayName,
6060
Type = obj.ObjectType,
6161
Id = new Guid(obj.ObjectId),
62-
SecurityEnabled = obj.SecurityEnabled
62+
SecurityEnabled = obj.SecurityEnabled,
63+
MailNickname = obj.Mail
6364
};
6465

6566
}
@@ -111,7 +112,8 @@ public static PSADGroup ToPSADGroup(this ADGroup group)
111112
DisplayName = group.DisplayName,
112113
Id = new Guid(group.ObjectId),
113114
SecurityEnabled = group.SecurityEnabled,
114-
Type = group.ObjectType
115+
Type = group.ObjectType,
116+
MailNickname = group.Mail
115117
};
116118
}
117119

src/Common/Commands.Common.Graph.RBAC/ActiveDirectory/PSADCredential.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ public class PSADCredential
2424

2525
public string KeyId { get; set; }
2626

27-
public string Type { get; set; }
27+
public string Type { get; set; }
2828
}
2929
}

src/Common/Commands.Common.Graph.RBAC/ActiveDirectory/PSADGroup.cs

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

src/Common/Commands.Common.Graph.RBAC/ActiveDirectory/ParameterSet.cs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public static class ParameterSet
2020

2121
public const string UPN = "UPNParameterSet";
2222

23+
public const string UPNOrObjectId = "UPNOrObjectIdParameterSet";
24+
2325
public const string SPN = "SPNParameterSet";
2426

2527
public const string SignInName = "SignInNameParameterSet";
@@ -28,6 +30,10 @@ public static class ParameterSet
2830

2931
public const string ObjectId = "ObjectIdParameterSet";
3032

33+
public const string GroupObject = "GroupObjectParameterSet";
34+
35+
public const string ServicePrincipalObject = "ServicePrincipalObjectParameterSet";
36+
3137
public const string Scope = "ScopeParameterSet";
3238

3339
public const string ScopeWithSPN = "ScopeWithSPNParameterSet";
@@ -62,18 +68,40 @@ public static class ParameterSet
6268

6369
public const string ApplicationWithKeyCredential = "ApplicationWithKeyCredentialParameterSet";
6470

71+
public const string ApplicationObjectWithoutCredential = "ApplicationObjectWithoutCredentialParameterSet";
72+
73+
public const string ApplicationObjectWithPasswordPlain = "ApplicationObjectWithPasswordPlainParameterSet";
74+
75+
public const string ApplicationObjectWithPasswordCredential = "ApplicationObjectWithPasswordCredentialParameterSet";
76+
77+
public const string ApplicationObjectWithKeyPlain = "ApplicationObjectWithKeyPlainParameterSet";
78+
79+
public const string ApplicationObjectWithKeyCredential = "ApplicationObjectWithKeyCredentialParameterSet";
80+
6581
public const string ApplicationObjectIdWithPassword = "ApplicationObjectIdWithPasswordParameterSet";
6682

6783
public const string ApplicationObjectIdWithCertValue = "ApplicationObjectIdWithCertValueParameterSet";
6884

85+
public const string ApplicationObjectWithPassword = "ApplicationObjectWithPasswordParameterSet";
86+
87+
public const string ApplicationObjectWithCertValue = "ApplicationObjectWithCertValueParameterSet";
88+
6989
public const string ApplicationIdWithPassword = "ApplicationIdWithPasswordParameterSet";
7090

7191
public const string ApplicationIdWithCertValue = "ApplicationIdWithCertValueParameterSet";
7292

93+
public const string DisplayNameWithPassword = "DisplayNameWithPasswordParameterSet";
94+
95+
public const string DisplayNameWithCertValue = "DisplayNameWithCertValueParameterSet";
96+
7397
public const string Empty = "EmptyParameterSet";
7498

7599
public const string InputFile = "InputFileParameterSet";
76100

101+
public const string InputObject = "InputObjectParameterSet";
102+
103+
public const string InputObjectWithUpdateParams = "InputObjectWithUpdateParamsParameterSet";
104+
77105
public const string RoleDefinition = "RoleDefinitionParameterSet";
78106

79107
public const string RoleDefinitionName = "RoleDefinitionNameParameterSet";
@@ -86,6 +114,10 @@ public static class ParameterSet
86114

87115
public const string ApplicationObjectId = "ApplicationObjectIdParameterSet";
88116

117+
public const string ApplicationObject = "ApplicationObjectParameterSet";
118+
119+
public const string ApplicationObjectWithKeyId = "ApplicationObjectWithKeyIdParameterSet";
120+
89121
public const string ApplicationId = "ApplicationIdParameterSet";
90122

91123
public const string ApplicationDisplayName = "ApplicationDisplayNameParameterSet";
@@ -108,6 +140,12 @@ public static class ParameterSet
108140

109141
public const string SPNWithPassword = "SPNWithPasswordParameterSet";
110142

143+
public const string ServicePrincipalObjectWithCertValue = "ServicePrincipalObjectWithCertValueParameterSet";
144+
145+
public const string ServicePrincipalObjectWithPassword = "ServicePrincipalObjectWithPasswordParameterSet";
146+
147+
public const string DisplayNameWithKeyId = "DisplayNameWithKeyIdParameterSet";
148+
111149
public const string ObjectIdWithKeyId = "ObjectIdWithKeyIdParameterSet";
112150

113151
public const string ObjectIdWithAll = "ObjectIdWithAllParameterSet";
@@ -116,10 +154,14 @@ public static class ParameterSet
116154

117155
public const string SPNWithAll = "SPNWithAllParameterSet";
118156

157+
public const string SPNObject = "SPNObjectParameterSet";
158+
119159
public const string ApplicationObjectIdWithUpdateParams = "ApplicationObjectIdWithUpdateParamsParameterSet";
120160

121161
public const string ApplicationIdWithUpdateParams = "ApplicationIdWithUpdateParamsParameterSet";
122162

163+
public const string DisplayName = "DisplayNameParameterSet";
164+
123165
public const string DisplayNameWithoutCredential = "DisplayNameWithoutCredentialParameterSet";
124166

125167
public const string DisplayNameWithPasswordPlain = "DisplayNameWithPasswordPlainParameterSet";
@@ -132,8 +174,26 @@ public static class ParameterSet
132174

133175
public const string SpObjectIdWithDisplayName = "SpObjectIdWithDisplayNameParameterSet";
134176

177+
public const string SpApplicationIdWithDisplayName = "SpApplicationIdWithDisplayNameParameterSet";
178+
179+
public const string InputObjectWithDisplayName = "InputObjectWithDisplayNameParameterSet";
180+
135181
public const string SPNWithDisplayName = "SPNWithDisplayNameParameterSet";
136182

137183
public const string RoleAssignment = "RoleAssignmentParameterSet";
184+
185+
public const string Explicit = "ExplicitParameterSet";
186+
187+
public const string MemberUPNWithGroupDisplayName = "MemberUPNWithGroupDisplayNameParameterSet";
188+
189+
public const string MemberUPNWithGroupObjectId = "MemberUPNWithGroupObjectIdParameterSet";
190+
191+
public const string MemberUPNWithGroupObject = "MemberUPNWithGroupObjectParameterSet";
192+
193+
public const string MemberObjectIdWithGroupDisplayName = "MemberObjectIdWithGroupDisplayName";
194+
195+
public const string MemberObjectIdWithGroupObjectId = "MemberObjectIdWithGroupObjectId";
196+
197+
public const string MemberObjectIdWithGroupObject = "MemberObjectIdWithGroupObject";
138198
}
139199
}

src/Common/Commands.Common.Graph.RBAC/Properties/Resources.Designer.cs

Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Common/Commands.Common.Graph.RBAC/Properties/Resources.resx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@
120120
<data name="ApplicationWithAppIdDoesntExist" xml:space="preserve">
121121
<value>Application with AppId '{0}' does not exist.</value>
122122
</data>
123+
<data name="ApplicationWithDisplayNameDoesntExist" xml:space="preserve">
124+
<value>Application with display name '{0}' does not exist.</value>
125+
</data>
123126
<data name="CreateApplicationNotAllowedGuestUser" xml:space="preserve">
124127
<value>You are a guest user in the directory and are not allowed to create an application. Please contact the administrator of the directory.</value>
125128
</data>
@@ -132,18 +135,42 @@
132135
<data name="GraphException" xml:space="preserve">
133136
<value>Received exception from graph. ErrorCode: {0}, Message: {1}</value>
134137
</data>
138+
<data name="GroupWithDisplayNameDoesntExist" xml:space="preserve">
139+
<value>Group with display name '{0}' does not exist.</value>
140+
</data>
135141
<data name="KeyCredentialNotValid" xml:space="preserve">
136142
<value>KeyCredential object is not valid.</value>
137143
</data>
144+
<data name="MultipleApplicationsWithDisplayNameFound" xml:space="preserve">
145+
<value>More than one application found with display name '{0}'. Please use the Get-AzureRmADApplication cmdlet to get the object id of the desired application.</value>
146+
</data>
147+
<data name="MultipleGroupsWithDisplayNameFound" xml:space="preserve">
148+
<value>More than one group found with the display name '{0}'. Please use the Get-AzureRmADGroup cmdlet to get the object id of the desired group.</value>
149+
</data>
150+
<data name="MultipleServicePrincipalsWithDisplayNameFound" xml:space="preserve">
151+
<value>More than one service principal found with display name '{0}'. Please use the Get-AzureRmADServicePrincipal cmdlet to get the object id of the desired service principal.</value>
152+
</data>
153+
<data name="MultipleUsersWithDisplayNameFound" xml:space="preserve">
154+
<value>More than one user found with display name '{0}'. Please use the Get-AzureRmADUser cmdlet to get the object id of the desired user.</value>
155+
</data>
138156
<data name="PasswordCredentialNotValid" xml:space="preserve">
139157
<value>PasswordCredential object is not valid.</value>
140158
</data>
141159
<data name="ServicePrincipalDoesntExist" xml:space="preserve">
142160
<value>Service principal with object id '{0}' does not exist.</value>
143161
</data>
162+
<data name="ServicePrincipalWithAppIdDoesntExist" xml:space="preserve">
163+
<value>Service principal with AppId '{0}' does not exist.</value>
164+
</data>
165+
<data name="ServicePrincipalWithDisplayNameDoesntExist" xml:space="preserve">
166+
<value>Service principal with display name '{0}' does not exist.</value>
167+
</data>
144168
<data name="ServicePrincipalWithSPNDoesntExist" xml:space="preserve">
145169
<value>Service principal with SPN '{0}' does not exist.</value>
146170
</data>
171+
<data name="UserWithDisplayNameDoesntExist" xml:space="preserve">
172+
<value>User with display name '{0}' does not exist.</value>
173+
</data>
147174
<data name="UserWithUPNDoesntExist" xml:space="preserve">
148175
<value>User with UPN '{0}' does not exist.</value>
149176
</data>

src/Common/Commands.Common/Extensions/CmdletExtensions.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Collections.Generic;
1919
using System.Collections.ObjectModel;
2020
using System.IO;
21+
using System.Linq.Expressions;
2122
using System.Management.Automation;
2223
using System.Reflection;
2324
using System.Text;
@@ -256,7 +257,7 @@ public static string ResolvePath(this PSCmdlet psCmdlet, string path)
256257
}
257258

258259
/// <summary>
259-
/// Execute the given cmdlet in powershell usign the given pipeline parameters.
260+
/// Execute the given cmdlet in powershell usign the given pipeline parameters.
260261
/// </summary>
261262
/// <typeparam name="T">The output type for the cmdlet</typeparam>
262263
/// <param name="cmdlet">The cmdlet to execute</param>
@@ -353,6 +354,13 @@ public static List<T> ExecuteScript<T>(this PSCmdlet cmdlet, string contents)
353354

354355
return output;
355356
}
357+
358+
public static bool IsParameterBound<TPSCmdlet, TProp>(this TPSCmdlet cmdlet, Expression<Func<TPSCmdlet, TProp>> propertySelector) where TPSCmdlet : PSCmdlet
359+
{
360+
var propName = ((MemberExpression)propertySelector.Body).Member.Name;
361+
return cmdlet.MyInvocation.BoundParameters.ContainsKey(propName);
362+
}
363+
356364
#region PowerShell Commands
357365

358366
public static void RemoveModule(this PSCmdlet cmdlet, string moduleName)

0 commit comments

Comments
 (0)