Skip to content

Resources improvements #6008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ private void HandleException(Exception exception)
throw exception;
}
}


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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public static PSADObject ToPSADObject(this AADObject obj)
DisplayName = obj.DisplayName,
Type = obj.ObjectType,
Id = new Guid(obj.ObjectId),
SecurityEnabled = obj.SecurityEnabled
SecurityEnabled = obj.SecurityEnabled,
MailNickname = obj.Mail
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MailNickname = obj.Mail [](start = 20, length = 23)

for a group the mail will be always null,do we need this?
https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/groups-operations

};

}
Expand Down Expand Up @@ -111,7 +112,8 @@ public static PSADGroup ToPSADGroup(this ADGroup group)
DisplayName = group.DisplayName,
Id = new Guid(group.ObjectId),
SecurityEnabled = group.SecurityEnabled,
Type = group.ObjectType
Type = group.ObjectType,
MailNickname = group.Mail
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public class PSADCredential

public string KeyId { get; set; }

public string Type { get; set; }
public string Type { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ namespace Microsoft.Azure.Graph.RBAC.Version1_6.ActiveDirectory
public class PSADGroup : PSADObject
{
public bool? SecurityEnabled { get; set; }

public string MailNickname { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public static class ParameterSet

public const string UPN = "UPNParameterSet";

public const string UPNOrObjectId = "UPNOrObjectIdParameterSet";

public const string SPN = "SPNParameterSet";

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

public const string ObjectId = "ObjectIdParameterSet";

public const string GroupObject = "GroupObjectParameterSet";

public const string ServicePrincipalObject = "ServicePrincipalObjectParameterSet";

public const string Scope = "ScopeParameterSet";

public const string ScopeWithSPN = "ScopeWithSPNParameterSet";
Expand Down Expand Up @@ -62,18 +68,40 @@ public static class ParameterSet

public const string ApplicationWithKeyCredential = "ApplicationWithKeyCredentialParameterSet";

public const string ApplicationObjectWithoutCredential = "ApplicationObjectWithoutCredentialParameterSet";

public const string ApplicationObjectWithPasswordPlain = "ApplicationObjectWithPasswordPlainParameterSet";

public const string ApplicationObjectWithPasswordCredential = "ApplicationObjectWithPasswordCredentialParameterSet";

public const string ApplicationObjectWithKeyPlain = "ApplicationObjectWithKeyPlainParameterSet";

public const string ApplicationObjectWithKeyCredential = "ApplicationObjectWithKeyCredentialParameterSet";

public const string ApplicationObjectIdWithPassword = "ApplicationObjectIdWithPasswordParameterSet";

public const string ApplicationObjectIdWithCertValue = "ApplicationObjectIdWithCertValueParameterSet";

public const string ApplicationObjectWithPassword = "ApplicationObjectWithPasswordParameterSet";

public const string ApplicationObjectWithCertValue = "ApplicationObjectWithCertValueParameterSet";

public const string ApplicationIdWithPassword = "ApplicationIdWithPasswordParameterSet";

public const string ApplicationIdWithCertValue = "ApplicationIdWithCertValueParameterSet";

public const string DisplayNameWithPassword = "DisplayNameWithPasswordParameterSet";

public const string DisplayNameWithCertValue = "DisplayNameWithCertValueParameterSet";

public const string Empty = "EmptyParameterSet";

public const string InputFile = "InputFileParameterSet";

public const string InputObject = "InputObjectParameterSet";

public const string InputObjectWithUpdateParams = "InputObjectWithUpdateParamsParameterSet";

public const string RoleDefinition = "RoleDefinitionParameterSet";

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

public const string ApplicationObjectId = "ApplicationObjectIdParameterSet";

public const string ApplicationObject = "ApplicationObjectParameterSet";

public const string ApplicationObjectWithKeyId = "ApplicationObjectWithKeyIdParameterSet";

public const string ApplicationId = "ApplicationIdParameterSet";

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

public const string SPNWithPassword = "SPNWithPasswordParameterSet";

public const string ServicePrincipalObjectWithCertValue = "ServicePrincipalObjectWithCertValueParameterSet";

public const string ServicePrincipalObjectWithPassword = "ServicePrincipalObjectWithPasswordParameterSet";

public const string DisplayNameWithKeyId = "DisplayNameWithKeyIdParameterSet";

public const string ObjectIdWithKeyId = "ObjectIdWithKeyIdParameterSet";

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

public const string SPNWithAll = "SPNWithAllParameterSet";

public const string SPNObject = "SPNObjectParameterSet";

public const string ApplicationObjectIdWithUpdateParams = "ApplicationObjectIdWithUpdateParamsParameterSet";

public const string ApplicationIdWithUpdateParams = "ApplicationIdWithUpdateParamsParameterSet";

public const string DisplayName = "DisplayNameParameterSet";

public const string DisplayNameWithoutCredential = "DisplayNameWithoutCredentialParameterSet";

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

public const string SpObjectIdWithDisplayName = "SpObjectIdWithDisplayNameParameterSet";

public const string SpApplicationIdWithDisplayName = "SpApplicationIdWithDisplayNameParameterSet";

public const string InputObjectWithDisplayName = "InputObjectWithDisplayNameParameterSet";

public const string SPNWithDisplayName = "SPNWithDisplayNameParameterSet";

public const string RoleAssignment = "RoleAssignmentParameterSet";

public const string Explicit = "ExplicitParameterSet";

public const string MemberUPNWithGroupDisplayName = "MemberUPNWithGroupDisplayNameParameterSet";

public const string MemberUPNWithGroupObjectId = "MemberUPNWithGroupObjectIdParameterSet";

public const string MemberUPNWithGroupObject = "MemberUPNWithGroupObjectParameterSet";

public const string MemberObjectIdWithGroupDisplayName = "MemberObjectIdWithGroupDisplayName";

public const string MemberObjectIdWithGroupObjectId = "MemberObjectIdWithGroupObjectId";

public const string MemberObjectIdWithGroupObject = "MemberObjectIdWithGroupObject";
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions src/Common/Commands.Common.Graph.RBAC/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
<data name="ApplicationWithAppIdDoesntExist" xml:space="preserve">
<value>Application with AppId '{0}' does not exist.</value>
</data>
<data name="ApplicationWithDisplayNameDoesntExist" xml:space="preserve">
<value>Application with display name '{0}' does not exist.</value>
</data>
<data name="CreateApplicationNotAllowedGuestUser" xml:space="preserve">
<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>
</data>
Expand All @@ -132,18 +135,42 @@
<data name="GraphException" xml:space="preserve">
<value>Received exception from graph. ErrorCode: {0}, Message: {1}</value>
</data>
<data name="GroupWithDisplayNameDoesntExist" xml:space="preserve">
<value>Group with display name '{0}' does not exist.</value>
</data>
<data name="KeyCredentialNotValid" xml:space="preserve">
<value>KeyCredential object is not valid.</value>
</data>
<data name="MultipleApplicationsWithDisplayNameFound" xml:space="preserve">
<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>
</data>
<data name="MultipleGroupsWithDisplayNameFound" xml:space="preserve">
<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>
</data>
<data name="MultipleServicePrincipalsWithDisplayNameFound" xml:space="preserve">
<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>
</data>
<data name="MultipleUsersWithDisplayNameFound" xml:space="preserve">
<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>
</data>
<data name="PasswordCredentialNotValid" xml:space="preserve">
<value>PasswordCredential object is not valid.</value>
</data>
<data name="ServicePrincipalDoesntExist" xml:space="preserve">
<value>Service principal with object id '{0}' does not exist.</value>
</data>
<data name="ServicePrincipalWithAppIdDoesntExist" xml:space="preserve">
<value>Service principal with AppId '{0}' does not exist.</value>
</data>
<data name="ServicePrincipalWithDisplayNameDoesntExist" xml:space="preserve">
<value>Service principal with display name '{0}' does not exist.</value>
</data>
<data name="ServicePrincipalWithSPNDoesntExist" xml:space="preserve">
<value>Service principal with SPN '{0}' does not exist.</value>
</data>
<data name="UserWithDisplayNameDoesntExist" xml:space="preserve">
<value>User with display name '{0}' does not exist.</value>
</data>
<data name="UserWithUPNDoesntExist" xml:space="preserve">
<value>User with UPN '{0}' does not exist.</value>
</data>
Expand Down
10 changes: 9 additions & 1 deletion src/Common/Commands.Common/Extensions/CmdletExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq.Expressions;
using System.Management.Automation;
using System.Reflection;
using System.Text;
Expand Down Expand Up @@ -256,7 +257,7 @@ public static string ResolvePath(this PSCmdlet psCmdlet, string path)
}

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

return output;
}

public static bool IsParameterBound<TPSCmdlet, TProp>(this TPSCmdlet cmdlet, Expression<Func<TPSCmdlet, TProp>> propertySelector) where TPSCmdlet : PSCmdlet
{
var propName = ((MemberExpression)propertySelector.Body).Member.Name;
return cmdlet.MyInvocation.BoundParameters.ContainsKey(propName);
}

#region PowerShell Commands

public static void RemoveModule(this PSCmdlet cmdlet, string moduleName)
Expand Down
Loading