internal MeetingValidatorEwsBinding(ExchangePrincipal principal, Uri endpoint) : base("ExchangeCalendarRepairAssistant", new RemoteCertificateValidationCallback(MeetingValidatorEwsBinding.CertificateErrorHandler))
 {
     this.RequestServerVersionValue = MeetingValidatorEwsBinding.RequestServerVersionExchange2013;
     base.UserAgent = "ExchangeCalendarRepairAssistant";
     base.Url       = endpoint.AbsoluteUri;
     base.Timeout   = (int)TimeSpan.FromSeconds((double)Configuration.WebRequestTimeoutInSeconds).TotalMilliseconds;
     NetworkServiceImpersonator.Initialize();
     if (NetworkServiceImpersonator.Exception == null)
     {
         base.Authenticator = SoapHttpClientAuthenticator.CreateNetworkService();
         base.Authenticator.AdditionalSoapHeaders.Add(new OpenAsAdminOrSystemServiceType
         {
             ConnectingSID = new ConnectingSIDType
             {
                 Item = new SmtpAddressType
                 {
                     Value = principal.MailboxInfo.PrimarySmtpAddress.ToString()
                 }
             },
             LogonType           = SpecialLogonType.SystemService,
             BudgetType          = 1,
             BudgetTypeSpecified = true
         });
     }
 }
 // Token: 0x06001C62 RID: 7266 RVA: 0x000714E0 File Offset: 0x0006F6E0
 public FindInGALSpeechRecognitionEWSBinding(SmtpAddress orgMboxSmtpAddress, Uri serviceUri, object state) : base("FindInGALSpeechRecognition", new RemoteCertificateValidationCallback(FindInGALSpeechRecognitionEWSBinding.CertificateErrorHandler))
 {
     ValidateArgument.NotNull(orgMboxSmtpAddress, "orgMboxSmtpAddress");
     ValidateArgument.NotNull(serviceUri, "serviceUri");
     ValidateArgument.NotNull(state, "state");
     base.Url = serviceUri.ToString();
     this.RequestServerVersionValue = FindInGALSpeechRecognitionEWSBinding.RequestServerVersion;
     base.UserAgent     = "FindInGALSpeechRecognition";
     base.Proxy         = new WebProxy();
     base.Authenticator = SoapHttpClientAuthenticator.CreateNetworkService();
     base.Authenticator.AdditionalSoapHeaders.Add(new OpenAsAdminOrSystemServiceType
     {
         ConnectingSID = new ConnectingSIDType
         {
             Item = new SmtpAddressType
             {
                 Value = orgMboxSmtpAddress.ToString()
             }
         },
         LogonType           = SpecialLogonType.SystemService,
         BudgetType          = 2,
         BudgetTypeSpecified = true
     });
     this.State = state;
     NetworkServiceImpersonator.Initialize();
 }
Пример #3
0
 protected override void SetAuthenticationMechanism(ExchangeServiceBinding ewsBinding)
 {
     if (ADAuthenticationTrackingAuthority.CanImpersonateNetworkService)
     {
         ewsBinding.Authenticator = SoapHttpClientAuthenticator.CreateNetworkService();
         return;
     }
     ewsBinding.Credentials = CredentialCache.DefaultNetworkCredentials;
 }
		private static void SetSecurityHeader(ExchangeServiceBinding binding, string email)
		{
			binding.Authenticator = SoapHttpClientAuthenticator.CreateNetworkService();
			binding.Authenticator.AdditionalSoapHeaders.Add(new OpenAsAdminOrSystemServiceType
			{
				ConnectingSID = new ConnectingSIDType
				{
					Item = new PrimarySmtpAddressType
					{
						Value = email
					}
				},
				LogonType = SpecialLogonType.SystemService
			});
		}
 internal UpdateGroupMailboxEwsBinding(ADUser group, Uri ewsEndpoint) : base("GroupMailboxCmdlet", new RemoteCertificateValidationCallback(CommonCertificateValidationCallbacks.InternalServerToServer))
 {
     ArgumentValidator.ThrowIfNull("group", group);
     ArgumentValidator.ThrowIfNull("ewsEndpointUrl", ewsEndpoint);
     base.Url = ewsEndpoint.ToString();
     base.HttpHeaders[WellKnownHeader.EWSTargetVersion] = EwsTargetVersion.V2_14;
     base.UserAgent = "GroupMailboxCmdlet";
     base.Proxy     = new WebProxy();
     base.SetClientRequestIdHeaderFromActivityId();
     using (new StopwatchPerformanceTracker("UpdateGroupMailboxEwsBinding.CreateNetworkService", GenericCmdletInfoDataLogger.Instance))
     {
         base.Authenticator = SoapHttpClientAuthenticator.CreateNetworkService();
     }
     using (new StopwatchPerformanceTracker("UpdateGroupMailboxEwsBinding.InitNetworkServiceImpersonator", GenericCmdletInfoDataLogger.Instance))
     {
         NetworkServiceImpersonator.Initialize();
     }
 }
        public virtual IExchangeService CreateBinding(RemoteCertificateValidationCallback certificateErrorHandler)
        {
            bool flag = true;

            NetworkServiceImpersonator.Initialize();
            if (NetworkServiceImpersonator.Exception != null)
            {
                if (this.IsTraceEnabled(TraceType.ErrorTrace))
                {
                    this.Tracer.TraceError <LocalizedException>(0L, "Unable to impersonate network service to call EWS due to exception {0}", NetworkServiceImpersonator.Exception);
                }
                flag = false;
            }
            ExchangeServiceBinding exchangeServiceBinding = new ExchangeServiceBinding(certificateErrorHandler);

            exchangeServiceBinding.UserAgent = WellKnownUserAgent.GetEwsNegoAuthUserAgent("AuditLog");
            exchangeServiceBinding.RequestServerVersionValue = new RequestServerVersion
            {
                Version = ExchangeVersionType.Exchange2013
            };
            if (flag)
            {
                exchangeServiceBinding.Authenticator = SoapHttpClientAuthenticator.CreateNetworkService();
            }
            else
            {
                exchangeServiceBinding.Authenticator = SoapHttpClientAuthenticator.Create(CredentialCache.DefaultCredentials);
            }
            exchangeServiceBinding.Authenticator.AdditionalSoapHeaders.Add(new OpenAsAdminOrSystemServiceType
            {
                ConnectingSID = new ConnectingSIDType
                {
                    Item = new PrimarySmtpAddressType
                    {
                        Value = this.GetSmtpAddress()
                    }
                },
                LogonType           = SpecialLogonType.SystemService,
                BudgetType          = (int)this.budgetType,
                BudgetTypeSpecified = true
            });
            return(exchangeServiceBinding);
        }
Пример #7
0
        internal MailboxAssociationEwsBinding(ADUser user, OpenAsAdminOrSystemServiceBudgetTypeType budgetType) : base("GroupMailboxAccessLayer", new RemoteCertificateValidationCallback(CommonCertificateValidationCallbacks.InternalServerToServer))
        {
            ArgumentValidator.ThrowIfNull("user", user);
            ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(user, null);

            MailboxAssociationEwsBinding.Tracer.TraceDebug <bool>((long)this.GetHashCode(), "MailboxAssociationEwsBinding.ctor - ExchangePrincipal.MailboxInfo.Location is null? {0}", exchangePrincipal.MailboxInfo.Location == null);
            Uri ewsEndpoint = null;

            MailboxAssociationEwsBinding.ExecuteEwsOperationWithRetry("GetBackEndWebServicesUrl", delegate
            {
                ewsEndpoint = BackEndLocator.GetBackEndWebServicesUrl(exchangePrincipal.MailboxInfo);
            });
            if (ewsEndpoint == null)
            {
                throw new MailboxNotFoundException(Strings.EwsUrlDiscoveryFailed(user.PrimarySmtpAddress.ToString()));
            }
            base.Url = ewsEndpoint.ToString();
            if (string.IsNullOrEmpty(base.Url))
            {
                throw new MailboxNotFoundException(Strings.EwsUrlDiscoveryFailed(user.PrimarySmtpAddress.ToString()));
            }
            base.HttpHeaders[WellKnownHeader.EWSTargetVersion] = EwsTargetVersion.V2_7;
            base.UserAgent = "GroupMailboxAccessLayer";
            base.Proxy     = new WebProxy();
            base.SetClientRequestIdHeaderFromActivityId();
            base.Authenticator = SoapHttpClientAuthenticator.CreateNetworkService();
            base.Authenticator.AdditionalSoapHeaders.Add(new OpenAsAdminOrSystemServiceType
            {
                ConnectingSID = new ConnectingSIDType
                {
                    Item = new SmtpAddressType
                    {
                        Value = user.PrimarySmtpAddress.ToString()
                    }
                },
                LogonType           = SpecialLogonType.Admin,
                BudgetType          = (int)budgetType,
                BudgetTypeSpecified = true
            });
            NetworkServiceImpersonator.Initialize();
        }
Пример #8
0
        public static ProxyAuthenticator Create(CredentialCache cache, SerializedSecurityContext serializedContext, string messageId)
        {
            SoapHttpClientAuthenticator soapHttpClientAuthenticator;

            if (cache == null)
            {
                ProxyAuthenticator.SecurityTracer.TraceDebug(0L, "{0}: creating ProxyAuthenticator for network service", new object[]
                {
                    TraceContext.Get()
                });
                soapHttpClientAuthenticator = SoapHttpClientAuthenticator.CreateNetworkService();
            }
            else
            {
                ProxyAuthenticator.SecurityTracer.TraceDebug <object, CredentialCache>(0L, "{0}: creating ProxyAuthenticator for credential cache: {1}", TraceContext.Get(), cache);
                soapHttpClientAuthenticator = SoapHttpClientAuthenticator.Create(cache);
            }
            if (serializedContext != null)
            {
                soapHttpClientAuthenticator.AdditionalSoapHeaders.Add(serializedContext);
            }
            ProxyAuthenticator.SetMessageId(soapHttpClientAuthenticator, messageId);
            return(new ProxyAuthenticator(soapHttpClientAuthenticator, AuthenticatorType.NetworkCredentials));
        }
Пример #9
0
        protected override IAsyncResult BeginInvoke()
        {
            GetFolderType getFolder = new GetFolderType
            {
                FolderShape = GetFolderRequest.GetFolderShape,
                FolderIds   = new BaseFolderIdType[]
                {
                    new DistinguishedFolderIdType
                    {
                        Id = DistinguishedFolderIdNameType.calendar
                    }
                }
            };

            this.binding.Authenticator = SoapHttpClientAuthenticator.CreateNetworkService();
            this.binding.Authenticator.AdditionalSoapHeaders.Add(new SerializedSecurityContextType
            {
                UserSid             = (this.query.RecipientData.Sid ?? this.query.RecipientData.MasterAccountSid).ToString(),
                GroupSids           = GetFolderRequest.SidStringAndAttributesConverter(ClientSecurityContext.DisabledEveryoneOnlySidStringAndAttributesArray),
                RestrictedGroupSids = null,
                PrimarySmtpAddress  = this.query.RecipientData.PrimarySmtpAddress.ToString()
            });
            return(this.binding.BeginGetFolder(getFolder, new AsyncCallback(base.Complete), null));
        }
        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);
        }