public override void ExecuteCmdlet() { ExecutionBlock(() => { if (!string.IsNullOrEmpty(ApplicationId)) { ObjectId = ActiveDirectoryClient.GetObjectIdFromApplicationId(ApplicationId); } bool deleteAllCredentials = false; if (All.IsPresent) { deleteAllCredentials = true; } if (KeyId != Guid.Empty) { ConfirmAction( Force.IsPresent, string.Format(ProjectResources.RemovingAppCredentialWithId, KeyId, ObjectId), ProjectResources.RemoveCredential, ObjectId, () => ActiveDirectoryClient.RemoveAppCredentialByKeyId(ObjectId, KeyId)); } else if (deleteAllCredentials) { ConfirmAction( Force.IsPresent, string.Format(ProjectResources.RemovingAllAppCredentials, ObjectId.ToString()), ProjectResources.RemoveCredential, ObjectId, () => ActiveDirectoryClient.RemoveAllAppCredentials(ObjectId)); } }); }
public override void ExecuteCmdlet() { ExecutionBlock(() => { if (this.IsParameterBound(c => c.ApplicationObject)) { ObjectId = ApplicationObject.ObjectId; } else if (this.IsParameterBound(c => c.ApplicationId)) { ObjectId = ActiveDirectoryClient.GetAppObjectIdFromApplicationId(ApplicationId); } else if (this.IsParameterBound(c => c.DisplayName)) { ObjectId = ActiveDirectoryClient.GetAppObjectIdFromDisplayName(DisplayName); } if (this.IsParameterBound(c => c.KeyId)) { ConfirmAction( Force.IsPresent, string.Format(ProjectResources.RemovingAppCredentialWithId, KeyId, ObjectId), ProjectResources.RemoveCredential, ObjectId.ToString(), () => ActiveDirectoryClient.RemoveAppCredentialByKeyId(ObjectId, KeyId)); } else { ConfirmAction( Force.IsPresent, string.Format(ProjectResources.RemovingAllAppCredentials, ObjectId.ToString()), ProjectResources.RemoveCredential, ObjectId.ToString(), () => ActiveDirectoryClient.RemoveAllAppCredentials(ObjectId)); } if (PassThru.IsPresent) { WriteObject(true); } }); }