Beispiel #1
0
        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()
        {
            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(() =>
            {
                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());
                }
            });
        }
Beispiel #4
0
        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);
                }
            });
        }