public override void OnSetFederatedOrganizationIdentifier(FederationTrust federationTrust, SmtpDomain accountNamespace)
        {
            string    text                 = accountNamespace.ToString();
            string    wkgDomain            = FederatedOrganizationId.AddHybridConfigurationWellKnownSubDomain(text);
            AppIdInfo appIdInfo            = null;
            ManageDelegation2Client client = this.GetManageDelegation(wkgDomain);

            try
            {
                appIdInfo = client.CreateAppId(wkgDomain);
            }
            catch (LiveDomainServicesException ex)
            {
                if (ex.DomainError != null && ex.DomainError.Value == DomainError.ProofOfOwnershipNotValid)
                {
                    throw new DomainProofOwnershipException(Strings.ErrorManageDelegation2ProofDomainOwnership, ex);
                }
                throw new ProvisioningFederatedExchangeException(ex.LocalizedString, ex);
            }
            if (string.IsNullOrEmpty(federationTrust.ApplicationIdentifier))
            {
                if (appIdInfo == null || string.IsNullOrEmpty(appIdInfo.AppId))
                {
                    throw new LiveDomainServicesException(Strings.ErrorLiveDomainServicesUnexpectedResult(Strings.ErrorInvalidApplicationId));
                }
                base.WriteVerbose(Strings.NewFederationTrustSuccessAppId(FederationTrust.PartnerSTSType.LiveId.ToString(), appIdInfo.AppId));
                federationTrust.ApplicationIdentifier = appIdInfo.AppId.Trim();
            }
            base.ReserveDomain(wkgDomain, federationTrust.ApplicationIdentifier, client, Strings.ErrorManageDelegation2ProofDomainOwnership, () => LiveFederationProvision2.GetDomainStateFromDomainInfo(client.GetDomainInfo(federationTrust.ApplicationIdentifier, wkgDomain)));
            using (ManageDelegation2Client manageDelegation = this.GetManageDelegation(text))
            {
                manageDelegation.AddUri(appIdInfo.AppId, text);
            }
        }
Exemple #2
0
        private void ValidateSetParameters()
        {
            ADObjectId adobjectId = ADObjectIdResolutionHelper.ResolveDN(this.DataObject.DelegationTrustLink);

            if (adobjectId != null && (string.IsNullOrEmpty(adobjectId.DistinguishedName) || adobjectId.Parent.Equals(this.ConfigurationSession.DeletedObjectsContainer)))
            {
                adobjectId = null;
            }
            if (this.DelegationFederationTrust == null && this.AccountNamespace == null)
            {
                if (adobjectId == null)
                {
                    base.WriteError(new NoTrustConfiguredException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
                }
                this.noTrustToUpdate = true;
                return;
            }
            if (this.DelegationFederationTrust != null)
            {
                if (this.AccountNamespace == null)
                {
                    if (adobjectId != null)
                    {
                        return;
                    }
                    base.WriteError(new NoAccountNamespaceException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
                }
            }
            else
            {
                base.WriteError(new CannotSpecifyAccountNamespaceWithoutTrustException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            if (this.DataObject.AccountNamespace != null)
            {
                string x = FederatedOrganizationId.ContainsHybridConfigurationWellKnownSubDomain(this.DataObject.AccountNamespace.Domain) ? FederatedOrganizationId.AddHybridConfigurationWellKnownSubDomain(this.AccountNamespace.Domain) : this.AccountNamespace.Domain;
                if (!StringComparer.OrdinalIgnoreCase.Equals(x, this.DataObject.AccountNamespace.Domain) && adobjectId != null)
                {
                    base.WriteError(new TrustAlreadyDefinedException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
                }
                if (adobjectId != null && !adobjectId.Equals(this.delegationTrustId))
                {
                    base.WriteError(new TrustAlreadyDefinedException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
                }
            }
            ADObjectId adobjectId2 = this.matchedAcceptedDomain.FederatedOrganizationLink;

            if (adobjectId2 != null && adobjectId2.Parent.Equals(this.ConfigurationSession.DeletedObjectsContainer))
            {
                adobjectId2 = null;
            }
            if (adobjectId2 != null)
            {
                if (adobjectId2.ObjectGuid != this.DataObject.Id.ObjectGuid)
                {
                    base.WriteError(new DomainAlreadyFederatedException(this.AccountNamespace.Domain), ErrorCategory.InvalidOperation, this.DataObject.Identity);
                }
                else
                {
                    this.noTrustToUpdate = true;
                }
            }
            TaskLogger.LogExit();
        }
Exemple #3
0
 protected override void InternalProcessRecord()
 {
     if (base.Fields.IsModified("DefaultDomain"))
     {
         IEnumerable <AcceptedDomain> enumerable = base.DataSession.FindPaged <AcceptedDomain>(null, base.CurrentOrgContainerId, true, null, 1000);
         foreach (AcceptedDomain acceptedDomain in enumerable)
         {
             if (acceptedDomain.IsDefaultFederatedDomain && (this.matchedDefaultAcceptedDomain == null || !this.matchedDefaultAcceptedDomain.Id.Equals(acceptedDomain.Id)))
             {
                 acceptedDomain.IsDefaultFederatedDomain = false;
                 base.DataSession.Save(acceptedDomain);
             }
         }
         if (this.matchedDefaultAcceptedDomain != null && !this.matchedDefaultAcceptedDomain.IsDefaultFederatedDomain)
         {
             this.matchedDefaultAcceptedDomain.IsDefaultFederatedDomain = true;
             base.DataSession.Save(this.matchedDefaultAcceptedDomain);
             this.defaultDomainChanged = true;
         }
     }
     if (this.noTrustToUpdate)
     {
         if (this.IsObjectStateChanged())
         {
             base.InternalProcessRecord();
             return;
         }
     }
     else
     {
         base.ZapDanglingDomainTrusts();
         this.ProvisionSTS();
         SmtpDomain smtpDomain = this.AccountNamespace;
         if (this.federationTrust.NamespaceProvisioner == FederationTrust.NamespaceProvisionerType.LiveDomainServices2)
         {
             smtpDomain = new SmtpDomain(FederatedOrganizationId.AddHybridConfigurationWellKnownSubDomain(this.AccountNamespace.Domain));
         }
         this.DataObject.AccountNamespace    = smtpDomain;
         this.DataObject.DelegationTrustLink = this.delegationTrustId;
         if (!this.DataObject.IsModified(FederatedOrganizationIdSchema.Enabled))
         {
             this.DataObject.Enabled = true;
         }
         bool flag           = false;
         Uri  applicationUri = null;
         if (null == this.federationTrust.ApplicationUri)
         {
             if (!Uri.TryCreate(smtpDomain.Domain, UriKind.RelativeOrAbsolute, out applicationUri))
             {
                 base.WriteError(new InvalidApplicationUriException(Strings.ErrorInvalidApplicationUri(this.AccountNamespace.Domain)), ErrorCategory.InvalidArgument, this.DataObject.Identity);
             }
             flag = true;
         }
         base.InternalProcessRecord();
         if (flag)
         {
             this.federationTrust.ApplicationUri = applicationUri;
             base.DataSession.Save(this.federationTrust);
         }
         AcceptedDomain acceptedDomain2 = (AcceptedDomain)base.DataSession.Read <AcceptedDomain>(this.matchedAcceptedDomain.Id);
         acceptedDomain2.FederatedOrganizationLink        = this.DataObject.Id;
         acceptedDomain2.PendingFederatedAccountNamespace = false;
         acceptedDomain2.PendingFederatedDomain           = false;
         base.DataSession.Save(acceptedDomain2);
     }
 }