public override void ExecuteCmdlet() { ADObjectFilterOptions options = new ADObjectFilterOptions { SPN = ServicePrincipalName, Id = ObjectId }; ExecutionBlock(() => { // At max 1 SP can be returned with SPN and Id options var sp = ActiveDirectoryClient.FilterServicePrincipals(options).FirstOrDefault(); if (sp == null) { throw new InvalidOperationException("ServicePrincipal does not exist."); } // Get AppObjectId string applicationObjectId = ActiveDirectoryClient.GetObjectIdFromApplicationId(sp.ApplicationId.ToString()); if (!string.IsNullOrEmpty(DisplayName)) { ApplicationUpdateParameters parameters = new ApplicationUpdateParameters() { DisplayName = DisplayName }; if (ShouldProcess(target: sp.Id.ToString(), action: string.Format("Updating properties on application associated with a service principal with object id '{0}'", sp.Id))) { ActiveDirectoryClient.UpdateApplication(applicationObjectId, parameters); } } }); }
public override void ExecuteCmdlet() { ExecutionBlock(() => { if (this.IsParameterBound(c => c.InputObject)) { ObjectId = InputObject.ObjectId; } else if (this.IsParameterBound(c => c.ApplicationId)) { ObjectId = ActiveDirectoryClient.GetAppObjectIdFromApplicationId(ApplicationId); } ApplicationUpdateParameters parameters = new ApplicationUpdateParameters { DisplayName = DisplayName, Homepage = HomePage, IdentifierUris = IdentifierUri, ReplyUrls = ReplyUrl, AvailableToOtherTenants = AvailableToOtherTenants }; if (ShouldProcess(target: ObjectId.ToString(), action: string.Format("Updating an application with object id '{0}'", ObjectId))) { ActiveDirectoryClient.UpdateApplication(ObjectId, parameters); WriteObject(ActiveDirectoryClient.GetApplication(ObjectId)); } }); }
public override void ExecuteCmdlet() { ExecutionBlock(() => { var sp = InputObject; if (sp == null) { IEnumerable <PSADServicePrincipal> result = null; if (this.IsParameterBound(c => c.ApplicationId)) { var appId = ApplicationId.ToString(); Rest.Azure.OData.ODataQuery <ServicePrincipal> odataQuery = new Rest.Azure.OData.ODataQuery <ServicePrincipal>(s => s.AppId == appId); result = ActiveDirectoryClient.FilterServicePrincipals(odataQuery); } else { ADObjectFilterOptions options = new ADObjectFilterOptions() { SPN = ServicePrincipalName, Id = ObjectId }; result = ActiveDirectoryClient.FilterServicePrincipals(options); } if (result == null) { throw new InvalidOperationException("ServicePrincipal does not exist."); } sp = result.FirstOrDefault(); } // Get AppObjectId var applicationObjectId = GetObjectIdFromApplicationId(sp.ApplicationId.ToString()); ApplicationUpdateParameters parameters = new ApplicationUpdateParameters() { DisplayName = DisplayName, Homepage = Homepage, IdentifierUris = (IdentifierUri == null) ? new string[] { } : IdentifierUri, KeyCredentials = KeyCredential, PasswordCredentials = PasswordCredential }; if (ShouldProcess(target: sp.Id, action: string.Format("Updating properties on application associated with a service principal with object id '{0}'", sp.Id))) { ActiveDirectoryClient.UpdateApplication(applicationObjectId, parameters); WriteObject(ActiveDirectoryClient.FilterServicePrincipals(new ADObjectFilterOptions() { Id = applicationObjectId }).FirstOrDefault()); } }); }
internal ActiveDirectoryApplicationImpl(ApplicationInner innerObject, GraphRbacManager manager) : base(innerObject.DisplayName, innerObject) { this.manager = manager; this.createParameters = new ApplicationCreateParameters { DisplayName = innerObject.DisplayName }; this.updateParameters = new ApplicationUpdateParameters { DisplayName = innerObject.DisplayName }; }
public virtual Response Patch(string applicationObjectId, ApplicationUpdateParameters parameters, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ApplicationsClient.Patch"); scope.Start(); try { return(RestClient.Patch(applicationObjectId, parameters, cancellationToken)); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response> PatchAsync(string applicationObjectId, ApplicationUpdateParameters parameters, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ApplicationsClient.Patch"); scope.Start(); try { return(await RestClient.PatchAsync(applicationObjectId, parameters, cancellationToken).ConfigureAwait(false)); } catch (Exception e) { scope.Failed(e); throw; } }
public void UpdateApplication(MockContext context, string applicaitonObjectId, string newDisplayName = null, string newIdentifierUri = null, PasswordCredential passwordCredential = null, KeyCredential keyCredential = null) { var parameters = new ApplicationUpdateParameters(); parameters.DisplayName = newDisplayName; if (!string.IsNullOrEmpty(newIdentifierUri)) { parameters.IdentifierUris = new[] { newIdentifierUri }; } if (passwordCredential != null) { parameters.PasswordCredentials = new PasswordCredential[] { passwordCredential }; } if (keyCredential != null) { parameters.KeyCredentials = new KeyCredential[] { keyCredential }; } GetGraphClient(context).Applications.Patch(applicaitonObjectId, parameters); }
public override void ExecuteCmdlet() { ExecutionBlock(() => { if (!string.IsNullOrEmpty(ApplicationId)) { ObjectId = ActiveDirectoryClient.GetObjectIdFromApplicationId(ApplicationId); } ApplicationUpdateParameters parameters = new ApplicationUpdateParameters { DisplayName = DisplayName, Homepage = HomePage, IdentifierUris = IdentifierUris, ReplyUrls = ReplyUrls, AvailableToOtherTenants = AvailableToOtherTenants }; if (ShouldProcess(target: ObjectId, action: string.Format("Updating an application with object id '{0}'", ObjectId))) { ActiveDirectoryClient.UpdateApplication(ObjectId, parameters); } }); }
/// <summary> /// Update an existing application. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='applicationObjectId'> /// Application object ID. /// </param> /// <param name='parameters'> /// Parameters to update an existing application. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task PatchAsync(this IApplicationsOperations operations, string applicationObjectId, ApplicationUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) { (await operations.PatchWithHttpMessagesAsync(applicationObjectId, parameters, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
public void UpdateApplication(Guid appObjectId, ApplicationUpdateParameters parameters) { GraphClient.Applications.Patch(appObjectId.ToString(), parameters); }
public void UpdateApplication(string appObjectId, ApplicationUpdateParameters parameters) { GraphClient.Applications.Patch(appObjectId, parameters); }
/// <summary> /// Update an existing application. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='applicationObjectId'> /// Application object ID. /// </param> /// <param name='parameters'> /// Parameters to update an existing application. /// </param> public static void Patch(this IApplicationsOperations operations, string applicationObjectId, ApplicationUpdateParameters parameters) { operations.PatchAsync(applicationObjectId, parameters).GetAwaiter().GetResult(); }
/// <summary> /// Update existing application. Reference: /// http://msdn.microsoft.com/en-us/library/azure/hh974476.aspx /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='applicationObjectId'> /// Application object id /// </param> /// <param name='parameters'> /// Parameters to update an existing application. /// </param> public static void Patch(this IApplicationsOperations operations, string applicationObjectId, ApplicationUpdateParameters parameters) { Task.Factory.StartNew(s => ((IApplicationsOperations)s).PatchAsync(applicationObjectId, parameters), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }