Пример #1
0
        public override void RequestReceived()
        {
            this.ThrowIfUserIsMailboxButNoMyBaseOptions();
            this.RedirectIfUserEsoSelf();
            this.RedirectIfTargetTenantSpecifiedForRegularAdmin();
            bool        flag        = !this.HasRegionalSettings;
            HttpContext httpContext = HttpContext.Current;

            DiagnosticsBehavior.CheckSystemProbeCookie(httpContext);
            string text = HttpContext.Current.Request.QueryString["mkt"];

            if (string.IsNullOrEmpty(text))
            {
                text = HttpContext.Current.Request.QueryString["mkt2"];
            }
            if (this.HasRegionalSettings && !string.IsNullOrEmpty(text))
            {
                try
                {
                    CultureInfo cultureInfoByIetfLanguageTag = CultureInfo.GetCultureInfoByIetfLanguageTag(text);
                    if (Culture.IsSupportedCulture(cultureInfoByIetfLanguageTag) && base.UserCulture.LCID != RoleBasedStringMapping.GetRoleBasedCultureInfo(cultureInfoByIetfLanguageTag, base.RbacConfiguration.RoleTypes).LCID)
                    {
                        flag = true;
                    }
                }
                catch (ArgumentException)
                {
                }
            }
            if (flag)
            {
                this.InitializeRegionalSettings();
                if (!this.HasRegionalSettings)
                {
                    if (!(httpContext.Request.HttpMethod == "GET"))
                    {
                        throw new RegionalSettingsNotConfiguredException(base.ExecutingUserId);
                    }
                    base.RbacConfiguration.ExecutingUserLanguagesChanged = true;
                    string url = string.Format(EcpUrl.OwaVDir + "languageselection.aspx?url={0}", HttpUtility.UrlEncode(EcpUrl.ProcessUrl(httpContext.GetRequestUrlPathAndQuery())));
                    httpContext.Response.Redirect(url, true);
                }
            }
            base.RequestReceived();
        }
Пример #2
0
        void IErrorHandler.ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            string value = DiagnosticsBehavior.GetErrorCause(error) ?? error.GetType().FullName;

            EcpPerfCounters.WebServiceErrors.Increment();
            EcpEventLogConstants.Tuple_WebServiceFailed.LogPeriodicFailure(EcpEventLogExtensions.GetUserNameToLog(), HttpContext.Current.GetRequestUrlForLog(), error, EcpEventLogExtensions.GetFlightInfoForLog());
            ExTraceGlobals.EventLogTracer.TraceError <string, EcpTraceFormatter <Exception> >(0, 0L, "{0}'s webservice request failed with exception: {1}", EcpEventLogExtensions.GetUserNameToLog(), error.GetTraceFormatter());
            HttpContext.Current.Response.AddHeader("X-ECP-ERROR", value);
            DDIHelper.Trace("Webservice request failed with exception: {0}", new object[]
            {
                error.GetTraceFormatter()
            });
            if (fault != null && version == MessageVersion.None)
            {
                MessageProperties properties = fault.Properties;
                fault = Message.CreateMessage(version, string.Empty, new JsonFaultDetail(error), new DataContractJsonSerializer(typeof(JsonFaultDetail)));
                fault.Properties.CopyProperties(properties);
            }
        }
Пример #3
0
        private static void Application_Error(object sender, EventArgs e)
        {
            HttpContext httpContext = HttpContext.Current;
            Exception   ex          = httpContext.GetError();

            ExTraceGlobals.EventLogTracer.TraceError <EcpTraceFormatter <Exception> >(0, 0L, "Application Error: {0}", ex.GetTraceFormatter());
            DDIHelper.Trace("Application Error: {0}", new object[]
            {
                ex.GetTraceFormatter()
            });
            EcpPerfCounters.AspNetErrors.Increment();
            EcpEventLogConstants.Tuple_RequestFailed.LogPeriodicFailure(EcpEventLogExtensions.GetUserNameToLog(), httpContext.GetRequestUrlForLog(), ex, EcpEventLogExtensions.GetFlightInfoForLog());
            RbacPrincipal current    = RbacPrincipal.GetCurrent(false);
            string        tenantName = string.Empty;

            if (current != null)
            {
                OrganizationId organizationId = current.RbacConfiguration.OrganizationId;
                if (organizationId != null && organizationId.OrganizationalUnit != null)
                {
                    tenantName = organizationId.OrganizationalUnit.Name;
                }
            }
            ActivityContextLogger.Instance.LogEvent(new PeriodicFailureEvent(ActivityContext.ActivityId.FormatForLog(), tenantName, httpContext.GetRequestUrlForLog(), ex, EcpEventLogExtensions.GetFlightInfoForLog()));
            ActivityContextManager.CleanupActivityContext(httpContext);
            if (ex is DelegatedSecurityTokenExpiredException)
            {
                ErrorHandlingModule.HandleDelegatedSecurityTokenExpire(httpContext);
                return;
            }
            if (httpContext.IsWebServiceRequest())
            {
                string errorCause = DiagnosticsBehavior.GetErrorCause(ex);
                ErrorHandlingUtil.SendReportForCriticalException(httpContext, ex);
                ErrorHandlingModule.SendJsonError(httpContext, ex, errorCause);
                return;
            }
            if (httpContext.IsUploadRequest())
            {
                ErrorHandlingUtil.SendReportForCriticalException(httpContext, ex);
                ErrorHandlingModule.SendJsonErrorForUpload(httpContext, ex);
                return;
            }
            if (ex is HttpException && ex.InnerException != null)
            {
                ex = ex.InnerException;
            }
            httpContext.Request.ServerVariables["X-ECP-ERROR"] = ex.GetType().FullName;
            string text  = null;
            string text2 = null;

            if (ex is OverBudgetException)
            {
                text = "overbudget";
            }
            else if (ex is IdentityNotMappedException || ex is TransientException)
            {
                text = "transientserviceerror";
            }
            else if (ex is ObjectNotFoundException)
            {
                if (ex.InnerException is NonUniqueRecipientException)
                {
                    text = "nonuniquerecipient";
                }
                else
                {
                    text = "nonmailbox";
                }
            }
            else if (ex is ServerNotInSiteException || ex is LowVersionUserDeniedException)
            {
                text = "lowversion";
            }
            else if (ex is CmdletAccessDeniedException || ex is DelegatedAccessDeniedException)
            {
                text = "noroles";
            }
            else if (ex is UrlNotFoundOrNoAccessException)
            {
                text = "urlnotfoundornoaccess";
            }
            else if (ex is BadRequestException)
            {
                text = "badrequest";
            }
            else if (ex is BadQueryParameterException)
            {
                text = "badqueryparameter";
            }
            else if (ex is ProxyFailureException)
            {
                text = "transientserviceerror";
            }
            else if (ex is ProxyCantFindCasServerException)
            {
                text = "proxy";
            }
            else if (ex is CasServerNotSupportEsoException)
            {
                text = "noeso";
            }
            else if (ex is RegionalSettingsNotConfiguredException)
            {
                text = "regionalsettingsnotconfigured";
            }
            else if (ex is SecurityException || (ErrorHandlingUtil.KnownReflectedExceptions.Value.ContainsKey("Microsoft.Exchange.Hygiene.Security.Authorization.NoValidRolesAssociatedToUserException, Microsoft.Exchange.Hygiene.Security.Authorization") && ex.GetType() == ErrorHandlingUtil.KnownReflectedExceptions.Value["Microsoft.Exchange.Hygiene.Security.Authorization.NoValidRolesAssociatedToUserException, Microsoft.Exchange.Hygiene.Security.Authorization"]))
            {
                text = "noroles";
            }
            else if (ex is ExchangeConfigurationException)
            {
                text = "anonymousauthenticationdisabled";
            }
            else if (ex is CannotAccessOptionsWithBEParamOrCookieException)
            {
                text = "cannotaccessoptionswithbeparamorcookie";
            }
            else if (ex.IsMaxRequestLengthExceededException())
            {
                EcpPerfCounters.RedirectToError.Increment();
                text2 = httpContext.Request.AppRelativeCurrentExecutionFilePath;
            }
            else
            {
                ErrorHandlingUtil.SendReportForCriticalException(httpContext, ex);
                if (!ErrorHandlingUtil.ShowIisNativeErrorPage && !ex.IsInterestingHttpException())
                {
                    text = "unexpected";
                }
            }
            if (text2 != null)
            {
                httpContext.Server.Transfer(text2, true);
                return;
            }
            if (text != null)
            {
                ErrorHandlingModule.TransferToErrorPage(text, ErrorHandlingUtil.CanShowDebugInfo(ex));
            }
        }
Пример #4
0
 object IDispatchMessageInspector.AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
 {
     DiagnosticsBehavior.CheckSystemProbeCookie(HttpContext.Current);
     PerfRecord.Current.WebServiceCallStarted();
     return(null);
 }