Пример #1
0
        private string GetEnterpriseOrE14SharingUrl(ExchangePrincipal exchangePrincipal)
        {
            SharedFolderDataEncryption.Tracer.TraceDebug <ExchangePrincipal, bool>((long)this.GetHashCode(), "Entering GetEnterpriseOrE14SharingUrl - mailbox {0}, isMultitenancyEnabled={1}", exchangePrincipal, this.IsMultitenancyEnabled);
            ServiceTopology            serviceTopology = this.IsMultitenancyEnabled ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\SharedFolderDataEncryption.cs", "GetEnterpriseOrE14SharingUrl", 655) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\SharedFolderDataEncryption.cs", "GetEnterpriseOrE14SharingUrl", 655);
            IList <WebServicesService> list            = serviceTopology.FindAll <WebServicesService>(exchangePrincipal, ClientAccessType.External, SharedFolderDataEncryption.serviceVersionFilter, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\SharedFolderDataEncryption.cs", "GetEnterpriseOrE14SharingUrl", 658);

            if (list.Count != 0)
            {
                return(EwsWsSecurityUrl.Fix(list[0].Url.ToString()));
            }
            SharedFolderDataEncryption.Tracer.TraceDebug <ExchangePrincipal>((long)this.GetHashCode(), "Unable to find a CAS with external access in same site of user {0}. Trying other sites.", exchangePrincipal);
            WebServicesService webServicesService = serviceTopology.FindAny <WebServicesService>(ClientAccessType.External, SharedFolderDataEncryption.serviceVersionFilter, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\SharedFolderDataEncryption.cs", "GetEnterpriseOrE14SharingUrl", 671);

            if (webServicesService == null)
            {
                throw new NoExternalEwsAvailableException();
            }
            return(EwsWsSecurityUrl.Fix(webServicesService.Url.ToString()));
        }
Пример #2
0
        private static Uri GetEcpServiceUrl(ExchangePrincipal principal, ClientAccessType type)
        {
            bool enabled = VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled;

            if (principal.MailboxInfo.Location.ServerVersion >= Server.E15MinVersion && enabled)
            {
                return(TextMessagingHelper.GetE15MultitenancyEcpServiceUrl(principal, type));
            }
            ServiceTopology serviceTopology = enabled ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\sms\\TextMessagingHelper.cs", "GetEcpServiceUrl", 371) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\sms\\TextMessagingHelper.cs", "GetEcpServiceUrl", 371);

            if (serviceTopology != null)
            {
                IList <EcpService> list = serviceTopology.FindAll <EcpService>(principal, type, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\sms\\TextMessagingHelper.cs", "GetEcpServiceUrl", 374);
                if (list != null && 0 < list.Count)
                {
                    return(list[0].Url);
                }
            }
            return(null);
        }
        private Uri GetEnterpriseOrE14OwaServiceUrl(IExchangePrincipal exchangePrincipal)
        {
            ServiceTopology        serviceTopology = this.IsMultitenancyEnabled ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\OwaAnonymousVdirLocater.cs", "GetEnterpriseOrE14OwaServiceUrl", 230) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\OwaAnonymousVdirLocater.cs", "GetEnterpriseOrE14OwaServiceUrl", 230);
            Predicate <OwaService> serviceFilter   = (OwaService service) => service.AnonymousFeaturesEnabled;
            IList <OwaService>     list            = serviceTopology.FindAll <OwaService>(exchangePrincipal, ClientAccessType.External, serviceFilter, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\OwaAnonymousVdirLocater.cs", "GetEnterpriseOrE14OwaServiceUrl", 235);
            OwaService             owaService;

            if (list.Count > 0)
            {
                owaService = list[0];
            }
            else
            {
                owaService = serviceTopology.FindAny <OwaService>(ClientAccessType.External, serviceFilter, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\OwaAnonymousVdirLocater.cs", "GetEnterpriseOrE14OwaServiceUrl", 247);
                if (owaService == null)
                {
                    throw new NoExternalOwaAvailableException();
                }
            }
            return(owaService.Url);
        }
        private static void SyncInternal(MailboxSession mailboxSession, ExDateTime lastSyncTime, StoreId folderId, string folderDisplayname, SecurityAccessToken securityAccessToken)
        {
            RefreshSharingFolderClient.Tracer.TraceDebug <string, IExchangePrincipal>(0L, "Sync sharing folder {0} from mailbox {1}", folderDisplayname, mailboxSession.MailboxOwner);
            if (!RefreshSharingFolderClient.CanSyncNow(lastSyncTime))
            {
                return;
            }
            NetworkServiceImpersonator.Initialize();
            if (NetworkServiceImpersonator.Exception != null)
            {
                RefreshSharingFolderClient.Tracer.TraceError <LocalizedException>(0L, "Unable to impersonate network service to call EWS due exception {0}", NetworkServiceImpersonator.Exception);
                return;
            }
            string id = StoreId.StoreIdToEwsId(mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, folderId);
            IList <WebServicesService> list;

            try
            {
                ClientAccessType clientAccessType = RefreshSharingFolderClient.ClientAccessType;
                RefreshSharingFolderClient.Tracer.TraceDebug <ClientAccessType>(0L, "Will try to discover the URL for EWS with the following client access type: {0}", clientAccessType);
                ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\RefreshSharingFolderClient.cs", "SyncInternal", 153);
                list = currentServiceTopology.FindAll <WebServicesService>(mailboxSession.MailboxOwner, clientAccessType, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\RefreshSharingFolderClient.cs", "SyncInternal", 154);
            }
            catch (LocalizedException arg)
            {
                RefreshSharingFolderClient.Tracer.TraceError <IExchangePrincipal, LocalizedException>(0L, "Unable to discover internal URL for EWS for mailbox {0} due exception {1}", mailboxSession.MailboxOwner, arg);
                return;
            }
            if (list.Count != 0)
            {
                string text = list[0].Url.ToString();
                RefreshSharingFolderClient.Tracer.TraceDebug <string>(0L, "Using {0} to call BeginRefreshSharingFolder", text);
                ExchangeServiceBinding exchangeServiceBinding = new ExchangeServiceBinding("RefreshSharingFolder", new RemoteCertificateValidationCallback(RefreshSharingFolderClient.CertificateErrorHandler));
                exchangeServiceBinding.Url = text;
                exchangeServiceBinding.RequestServerVersionValue         = new RequestServerVersion();
                exchangeServiceBinding.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2010;
                exchangeServiceBinding.UserAgent     = WellKnownUserAgent.GetEwsNegoAuthUserAgent("RefreshSharingFolder");
                exchangeServiceBinding.Authenticator = SoapHttpClientAuthenticator.CreateNetworkService();
                exchangeServiceBinding.Authenticator.AdditionalSoapHeaders.Add(new SerializedSecurityContextType
                {
                    UserSid             = securityAccessToken.UserSid,
                    GroupSids           = RefreshSharingFolderClient.SidStringAndAttributesConverter(securityAccessToken.GroupSids),
                    RestrictedGroupSids = RefreshSharingFolderClient.SidStringAndAttributesConverter(securityAccessToken.RestrictedGroupSids),
                    PrimarySmtpAddress  = mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()
                });
                Exception ex = null;
                try
                {
                    exchangeServiceBinding.BeginRefreshSharingFolder(new RefreshSharingFolderType
                    {
                        SharingFolderId = new FolderIdType
                        {
                            Id = id
                        }
                    }, new AsyncCallback(RefreshSharingFolderClient.TraceResponse), exchangeServiceBinding);
                }
                catch (SoapException ex2)
                {
                    ex = ex2;
                }
                catch (WebException ex3)
                {
                    ex = ex3;
                }
                catch (IOException ex4)
                {
                    ex = ex4;
                }
                catch (InvalidOperationException ex5)
                {
                    ex = ex5;
                }
                catch (LocalizedException ex6)
                {
                    ex = ex6;
                }
                if (ex != null)
                {
                    RefreshSharingFolderClient.Tracer.TraceError <StoreId, IExchangePrincipal, Exception>(0L, "Unable to sync sharing folder {0} in mailbox {1}. Exception {2}", folderId, mailboxSession.MailboxOwner, ex);
                }
                return;
            }
            RefreshSharingFolderClient.Tracer.TraceError <IExchangePrincipal>(0L, "Unable to find internal URL for EWS for mailbox {0}", mailboxSession.MailboxOwner);
        }