Пример #1
0
        protected override IConfigurable PrepareDataObject()
        {
            PartnerApplication partnerApplication = (PartnerApplication)base.PrepareDataObject();

            if (base.Fields.IsModified(PartnerApplicationSchema.AuthMetadataUrl))
            {
                if (partnerApplication.UseAuthServer)
                {
                    base.WriteError(new TaskException(Strings.ErrorPartnerApplicationUseAuthServerCannotSetUrl), ErrorCategory.InvalidArgument, null);
                }
                partnerApplication.AuthMetadataUrl = this.AuthMetadataUrl;
                OAuthTaskHelper.FetchAuthMetadata(partnerApplication, this.TrustAnySSLCertificate, false, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            else if (base.Fields.IsModified(PartnerApplicationSchema.Realm) || base.Fields.IsModified(PartnerApplicationSchema.ApplicationIdentifier) || base.Fields.IsModified(PartnerApplicationSchema.IssuerIdentifier))
            {
                base.WriteError(new TaskException(Strings.ErrorChangePartnerApplicationDirectTrust), ErrorCategory.InvalidArgument, null);
            }
            if (base.Fields.IsModified(PartnerApplicationSchema.LinkedAccount))
            {
                if (this.LinkedAccount == null)
                {
                    partnerApplication.LinkedAccount = null;
                }
                else
                {
                    ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(this.LinkedAccount, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorRecipientNotFound(this.LinkedAccount.ToString())), new LocalizedString?(Strings.ErrorRecipientNotUnique(this.LinkedAccount.ToString())));
                    partnerApplication.LinkedAccount = adrecipient.Id;
                }
            }
            if (base.Fields.IsModified(PartnerApplicationSchema.AppOnlyPermissions))
            {
                partnerApplication.AppOnlyPermissions = this.AppOnlyPermissions;
            }
            if (base.Fields.IsModified(PartnerApplicationSchema.ActAsPermissions))
            {
                partnerApplication.ActAsPermissions = this.ActAsPermissions;
            }
            OAuthTaskHelper.ValidateApplicationRealmAndUniqueness(partnerApplication, this.ConfigurationSession, new Task.TaskErrorLoggingDelegate(base.WriteError));
            return(partnerApplication);
        }
        protected override IConfigurable PrepareDataObject()
        {
            this.CreatePartnerApplicationsContainer();
            PartnerApplication partnerApplication = (PartnerApplication)base.PrepareDataObject();
            ADObjectId         containerId        = PartnerApplication.GetContainerId(this.ConfigurationSession);

            partnerApplication.SetId(containerId.GetChildId(partnerApplication.Name));
            partnerApplication.UseAuthServer = true;
            if (partnerApplication.IsModified(PartnerApplicationSchema.AuthMetadataUrl))
            {
                partnerApplication.UseAuthServer = false;
                OAuthTaskHelper.FetchAuthMetadata(partnerApplication, this.TrustAnySSLCertificate, true, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            if (base.Fields.IsModified(PartnerApplicationSchema.LinkedAccount))
            {
                if (this.LinkedAccount == null)
                {
                    partnerApplication.LinkedAccount = null;
                }
                else
                {
                    ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(this.LinkedAccount, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorRecipientNotFound(this.LinkedAccount.ToString())), new LocalizedString?(Strings.ErrorRecipientNotUnique(this.LinkedAccount.ToString())));
                    partnerApplication.LinkedAccount = adrecipient.Id;
                }
            }
            if (base.Fields.IsModified(PartnerApplicationSchema.AppOnlyPermissions))
            {
                partnerApplication.AppOnlyPermissions = this.AppOnlyPermissions;
            }
            if (base.Fields.IsModified(PartnerApplicationSchema.ActAsPermissions))
            {
                partnerApplication.ActAsPermissions = this.ActAsPermissions;
            }
            OAuthTaskHelper.ValidateApplicationRealmAndUniqueness(partnerApplication, this.ConfigurationSession, new Task.TaskErrorLoggingDelegate(base.WriteError));
            return(partnerApplication);
        }