コード例 #1
0
 private UserSettingError GetSettingErrorFromResponse(UserResponse userResponse, string settingName)
 {
     if (userResponse.UserSettingErrors != null)
     {
         UserSettingError[] userSettingErrors = userResponse.UserSettingErrors;
         int i = 0;
         while (i < userSettingErrors.Length)
         {
             UserSettingError userSettingError = userSettingErrors[i];
             if (userSettingError != null && StringComparer.InvariantCulture.Equals(userSettingError.SettingName, settingName))
             {
                 if (userSettingError.ErrorCode != ErrorCode.NoError)
                 {
                     return(userSettingError);
                 }
                 break;
             }
             else
             {
                 i++;
             }
         }
     }
     return(null);
 }
コード例 #2
0
        private bool HasSettingErrorInResponse(MailboxInfo mailbox, UserResponse userResponse, out GroupId groupId)
        {
            groupId = null;
            UserSettingError settingErrorFromResponse = this.GetSettingErrorFromResponse(userResponse, UserSettingAutodiscovery.ExternalEwsUrl);

            if (settingErrorFromResponse != null)
            {
                Factory.Current.AutodiscoverTracer.TraceError((long)this.GetHashCode(), "Correlation Id:{0}. Request '{1}' got error response for user {2}. Error: {3}:{4}:{5}", new object[]
                {
                    this.callerInfo.QueryCorrelationId,
                    this,
                    mailbox.ToString(),
                    settingErrorFromResponse.SettingName,
                    settingErrorFromResponse.ErrorCode,
                    settingErrorFromResponse.ErrorMessage
                });
                groupId = new GroupId(new MultiMailboxSearchException(Strings.descSoapAutoDiscoverRequestUserSettingError(this.autodiscoveryEndpoint.ToString(), settingErrorFromResponse.SettingName, settingErrorFromResponse.ErrorMessage)));
                return(true);
            }
            return(false);
        }
コード例 #3
0
        private AutoDiscoverRequestResult GetAutodiscoverResultFromUserResponseInternal(EmailAddress emailAddress, UserResponse userResponse)
        {
            if (userResponse == null)
            {
                SoapAutoDiscoverRequest.AutoDiscoverTracer.TraceError <object, UserSoapAutoDiscoverRequest, string>((long)this.GetHashCode(), "{0}: Request '{1}' got empty response for user {2}.", TraceContext.Get(), this, emailAddress.Address);
                return(null);
            }
            if (userResponse.ErrorCodeSpecified)
            {
                switch (userResponse.ErrorCode)
                {
                case ErrorCode.NoError:
                    break;

                case ErrorCode.RedirectAddress:
                    SoapAutoDiscoverRequest.AutoDiscoverTracer.TraceDebug((long)this.GetHashCode(), "{0}: Request '{1}' got address redirect response for user {2} to {3}", new object[]
                    {
                        TraceContext.Get(),
                        this,
                        emailAddress.Address,
                        userResponse.RedirectTarget
                    });
                    return(new AutoDiscoverRequestResult(base.TargetUri, userResponse.RedirectTarget, null, null, base.FrontEndServerName, base.BackEndServerName));

                case ErrorCode.RedirectUrl:
                    if (!Uri.IsWellFormedUriString(userResponse.RedirectTarget, UriKind.Absolute))
                    {
                        SoapAutoDiscoverRequest.AutoDiscoverTracer.TraceError((long)this.GetHashCode(), "{0}: Request '{1}' got URL redirect response for user {2} but the redirect value is not valid: {3}", new object[]
                        {
                            TraceContext.Get(),
                            this,
                            "ExternalEwsUrl",
                            userResponse.RedirectTarget
                        });
                        return(null);
                    }
                    SoapAutoDiscoverRequest.AutoDiscoverTracer.TraceDebug((long)this.GetHashCode(), "{0}: Request '{1}' got URL redirect response for user {2} to {3}", new object[]
                    {
                        TraceContext.Get(),
                        this,
                        emailAddress.Address,
                        userResponse.RedirectTarget
                    });
                    return(new AutoDiscoverRequestResult(base.TargetUri, null, new Uri(userResponse.RedirectTarget), null, base.FrontEndServerName, base.BackEndServerName));

                default:
                    return(new AutoDiscoverRequestResult(base.TargetUri, new AutoDiscoverInvalidUserException(Strings.descSoapAutoDiscoverRequestUserSettingInvalidError(base.TargetUri.ToString(), "ExternalEwsUrl")), base.FrontEndServerName, base.BackEndServerName));
                }
            }
            UserSettingError settingErrorFromResponse  = this.GetSettingErrorFromResponse(userResponse, "ExternalEwsUrl");
            UserSettingError settingErrorFromResponse2 = this.GetSettingErrorFromResponse(userResponse, "InteropExternalEwsUrl");

            if (settingErrorFromResponse != null && settingErrorFromResponse2 != null)
            {
                SoapAutoDiscoverRequest.AutoDiscoverTracer.TraceError((long)this.GetHashCode(), "{0}: Request '{1}' got error response for user {2}. Error: {3}:{4}:{5}", new object[]
                {
                    TraceContext.Get(),
                    this,
                    emailAddress.Address,
                    settingErrorFromResponse.SettingName,
                    settingErrorFromResponse.ErrorCode,
                    settingErrorFromResponse.ErrorMessage
                });
                return(new AutoDiscoverRequestResult(base.TargetUri, new AutoDiscoverFailedException(Strings.descSoapAutoDiscoverRequestUserSettingError(base.TargetUri.ToString(), settingErrorFromResponse.SettingName, settingErrorFromResponse.ErrorMessage), 60220U), base.FrontEndServerName, base.BackEndServerName));
            }
            string versionValue = null;
            string text         = null;

            if (settingErrorFromResponse == null)
            {
                text         = this.GetStringSettingFromResponse(userResponse, emailAddress.Address, "ExternalEwsUrl");
                versionValue = this.GetStringSettingFromResponse(userResponse, emailAddress.Address, "ExternalEwsVersion");
            }
            if (text == null && settingErrorFromResponse2 == null)
            {
                text         = this.GetStringSettingFromResponse(userResponse, emailAddress.Address, "InteropExternalEwsUrl");
                versionValue = this.GetStringSettingFromResponse(userResponse, emailAddress.Address, "InteropExternalEwsVersion");
            }
            if (text == null)
            {
                SoapAutoDiscoverRequest.AutoDiscoverTracer.TraceError <object, UserSoapAutoDiscoverRequest, string>((long)this.GetHashCode(), "{0}: Request '{1}' for user {2} got no URL value.", TraceContext.Get(), this, emailAddress.Address);
                return(null);
            }
            return(base.GetAutodiscoverResult(text, versionValue, emailAddress));
        }