public override Microsoft.Exchange.Data.Directory.Management.DomainState GetDomainState(string domain)
 {
     Microsoft.Exchange.Data.Directory.Management.DomainState domainStateFromDomainInfo;
     using (ManageDelegation2Client manageDelegation = this.GetManageDelegation(domain))
     {
         domainStateFromDomainInfo = LiveFederationProvision2.GetDomainStateFromDomainInfo(manageDelegation.GetDomainInfo(base.ApplicationIdentifier, domain));
     }
     return(domainStateFromDomainInfo);
 }
        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);
            }
        }