Skip to content

Commit

Permalink
Merge pull request Azure#7710 from cormacpayne/new-sp-cred-fix
Browse files Browse the repository at this point in the history
Fix issue where EndDate parameter was not being honored for AD cmdlets
  • Loading branch information
markcowl authored Nov 1, 2018
2 parents 5b23f0a + dcea2ff commit 9a27595
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public override void ExecuteCmdlet()
{
if (!this.IsParameterBound(c => c.EndDate))
{
WriteVerbose("No value specified for -EndDate parameter; setting the value to one year after start date.");
WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed);
EndDate = StartDate.AddYears(1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using Microsoft.Azure.Graph.RBAC.Version1_6.ActiveDirectory;
using Microsoft.WindowsAzure.Commands.Common;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System;
using System.Management.Automation;
using System.Security;
Expand Down Expand Up @@ -124,11 +125,16 @@ public NewAzureADApplicationCommand()
{
DateTime currentTime = DateTime.UtcNow;
StartDate = currentTime;
EndDate = currentTime.AddYears(1);
}

public override void ExecuteCmdlet()
{
if (!this.IsParameterBound(c => c.EndDate))
{
WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed);
EndDate = StartDate.AddYears(1);
}

CreatePSApplicationParameters createParameters = new CreatePSApplicationParameters
{
DisplayName = DisplayName,
Expand All @@ -137,7 +143,7 @@ public override void ExecuteCmdlet()
ReplyUrls = ReplyUrls,
AvailableToOtherTenants = AvailableToOtherTenants
};

switch (ParameterSetName)
{
case ParameterSet.ApplicationWithPasswordPlain:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ public NewAzureADServicePrincipalCommand()
{
DateTime currentTime = DateTime.UtcNow;
StartDate = currentTime;
EndDate = currentTime.AddYears(1);
}

public override void ExecuteCmdlet()
Expand All @@ -190,6 +189,12 @@ public override void ExecuteCmdlet()
return;
}

if (!this.IsParameterBound(c => c.EndDate))
{
WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed);
EndDate = StartDate.AddYears(1);
}

if (this.IsParameterBound(c => c.ApplicationObject))
{
ApplicationId = ApplicationObject.ApplicationId;
Expand Down Expand Up @@ -292,7 +297,7 @@ private void CreateSimpleServicePrincipal()
if (!this.IsParameterBound(c => c.EndDate))
{
EndDate = StartDate.AddYears(1);
WriteVerbose("No end date provided - using the default value of one year after the start date.");
WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed);
}

if (!this.IsParameterBound(c => c.DisplayName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ public override void ExecuteCmdlet()
{
ExecutionBlock(() =>
{
EndDate = StartDate.AddYears(1);
if (!this.IsParameterBound(c => c.EndDate))
{
WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed);
EndDate = StartDate.AddYears(1);
}

if (this.IsParameterBound(c => c.ServicePrincipalObject))
{
ObjectId = ServicePrincipalObject.Id;
Expand Down
2 changes: 2 additions & 0 deletions src/ResourceManager/Resources/Commands.Resources/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
## Current Release
* Fix for https://github.com/Azure/azure-powershell/issues/7402
- Allow listing resources using the `-ResourceId` parameter for `Get-AzureRmResource`
* Fix for https://github.com/Azure/azure-powershell/issues/7700
- Fix issue where `EndDate` parameter was not being honored for AD cmdlets

## Version 6.7.0
* Fix isssue where Get-AzureRMRoleDefinition throws an unintelligible exception (when the default profile has no subscription in it and no scope is specified) by adding a meaningful exception in the scenario. Also set the default param set to `RoleDefinitionNameParameterSet`.
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,7 @@
<data name="ApplicationWithDisplayNameDoesntExist" xml:space="preserve">
<value>Application with display name '{0}' does not exist.</value>
</data>
<data name="DefaultEndDateUsed" xml:space="preserve">
<value>No value specified for -EndDate parameter; setting the value to one year after start date.</value>
</data>
</root>

0 comments on commit 9a27595

Please sign in to comment.