Exemplo n.º 1
0
 public static void SendCanary(this HttpContext context, ref CanaryStatus canaryStatus, ref bool shouldAddLog)
 {
     if (context.Request.IsAuthenticated && !context.IsLogoffRequest())
     {
         bool       flag = false;
         string     cachedUserUniqueKey = context.GetCachedUserUniqueKey();
         string     canaryName          = context.GetCanaryName();
         HttpCookie httpCookie          = context.Request.Cookies[canaryName];
         if (httpCookie != null && Canary.RestoreCanary(httpCookie.Value, cachedUserUniqueKey) != null)
         {
             flag = true;
         }
         if (!flag)
         {
             if (httpCookie != null)
             {
                 EcpEventLogConstants.Tuple_ResetCanaryInCookie.LogEvent(new object[]
                 {
                     EcpEventLogExtensions.GetUserNameToLog(),
                     cachedUserUniqueKey,
                     canaryName,
                     context.GetRequestUrlForLog(),
                     (httpCookie != null) ? httpCookie.Value : string.Empty
                 });
             }
             Canary     canary      = new Canary(Guid.NewGuid(), cachedUserUniqueKey);
             HttpCookie httpCookie2 = new HttpCookie(canaryName, canary.ToString());
             httpCookie2.HttpOnly = false;
             httpCookie2.Path     = EcpUrl.GetEcpVDirForCanary();
             context.Response.Cookies.Add(httpCookie2);
             canaryStatus |= CanaryStatus.IsCanaryRenewed;
         }
     }
     shouldAddLog = true;
 }
Exemplo n.º 2
0
 protected override void OnRequestException(HttpWebRequest request, WebException exception)
 {
     ExTraceGlobals.ProxyTracer.TraceError <Uri, WebException>(0, 0L, "Request Exception. Url={0}, Exception={1}", request.RequestUri, exception);
     base.OnRequestException(request, exception);
     if (!exception.IsProxyNeedIdentityError())
     {
         string machineName = Environment.MachineName;
         string host        = request.RequestUri.Host;
         ExEventLog.EventTuple proxyEventLogTuple = exception.GetProxyEventLogTuple();
         if (proxyEventLogTuple.Period == ExEventLog.EventPeriod.LogAlways)
         {
             proxyEventLogTuple.LogEvent(new object[]
             {
                 EcpEventLogExtensions.GetUserNameToLog(),
                 machineName,
                 host,
                 request.RequestUri,
                 exception
             });
             return;
         }
         proxyEventLogTuple.LogPeriodicEvent(host, new object[]
         {
             EcpEventLogExtensions.GetUserNameToLog(),
             machineName,
             host
         });
     }
 }
Exemplo n.º 3
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     try
     {
         LinkedInConfig    linkedInConfig          = this.ReadConfiguration();
         LinkedInAppConfig config                  = this.ReadAppConfiguration();
         LinkedInAppAuthorizationResponse response = new LinkedInAuthenticator(linkedInConfig, new LinkedInWebClient(config, LinkedInSetup.Tracer), LinkedInSetup.Tracer).AuthorizeApplication(base.Request.QueryString, base.Request.Cookies, base.Response.Cookies, this.GetAuthorizationCallbackUrl());
         this.ProcessAuthorizationResponse(response);
     }
     catch (ExchangeConfigurationException ex)
     {
         EcpEventLogConstants.Tuple_BadLinkedInConfiguration.LogPeriodicEvent(EcpEventLogExtensions.GetPeriodicKeyPerUser(), new object[]
         {
             EcpEventLogExtensions.GetUserNameToLog(),
             ex
         });
         ErrorHandlingUtil.TransferToErrorPage("badlinkedinconfiguration");
     }
     catch (LinkedInAuthenticationException ex2)
     {
         EcpEventLogConstants.Tuple_LinkedInAuthorizationError.LogEvent(new object[]
         {
             EcpEventLogExtensions.GetUserNameToLog(),
             ex2
         });
         ErrorHandlingUtil.TransferToErrorPage("linkedinauthorizationerror");
     }
 }
        public string Translate(Identity id, Exception ex, string originalMessage)
        {
            string text = null;
            PropertyValidationException ex2 = ex as PropertyValidationException;

            if (ex2 != null)
            {
                StringBuilder stringBuilder = new StringBuilder(128);
                foreach (PropertyValidationError propertyValidationError in ex2.PropertyValidationErrors)
                {
                    stringBuilder.Append(propertyValidationError.Description);
                    stringBuilder.Append(" ");
                }
                text = stringBuilder.ToString();
            }
            if (this.IsLogging)
            {
                EcpEventLogConstants.Tuple_PowershellExceptionTranslated.LogEvent(new object[]
                {
                    EcpEventLogExtensions.GetUserNameToLog(),
                    ex.GetType(),
                    text,
                    originalMessage
                });
            }
            return(text);
        }
Exemplo n.º 5
0
        private static bool HasValidCanary(this HttpContext context, string canaryInHeader, string canaryInForm, string canaryInUrl, out string canaryVersion, ref CanaryStatus canaryStatus)
        {
            bool flag  = context.User is InboundProxySession;
            bool flag2 = !flag || !string.IsNullOrEmpty(context.Request.Headers["msExchEcpOutboundProxyVersion"]);

            canaryVersion = (flag2 ? "14.2" : "14.1");
            string     canaryName          = context.GetCanaryName();
            HttpCookie httpCookie          = context.Request.Cookies[canaryName];
            string     text                = (httpCookie == null) ? string.Empty : httpCookie.Value;
            string     cachedUserUniqueKey = context.GetCachedUserUniqueKey();
            Canary     canary              = Canary.RestoreCanary(text, cachedUserUniqueKey);
            bool       flag3               = !flag2 || canary != null;
            bool       flag4               = StringComparer.Ordinal.Equals(httpCookie.Value, canaryInForm);
            bool       flag5               = StringComparer.Ordinal.Equals(httpCookie.Value, canaryInHeader);
            bool       flag6               = StringComparer.Ordinal.Equals(httpCookie.Value, canaryInUrl);
            bool       flag7               = false;

            if (httpCookie != null && !string.IsNullOrEmpty(httpCookie.Value) && flag3)
            {
                flag7 = (flag5 || flag4 || flag6);
            }
            if (flag7)
            {
                if (flag4)
                {
                    canaryStatus |= (CanaryStatus)3;
                }
                if (flag5)
                {
                    canaryStatus |= (CanaryStatus)1;
                }
                if (flag6)
                {
                    canaryStatus |= (CanaryStatus)2;
                }
            }
            else if (!flag3)
            {
                EcpEventLogConstants.Tuple_InvalidCanaryInCookieDetected.LogPeriodicEvent(EcpEventLogExtensions.GetPeriodicKeyPerUser(), new object[]
                {
                    EcpEventLogExtensions.GetUserNameToLog(),
                    cachedUserUniqueKey,
                    canaryName,
                    context.GetRequestUrlForLog(),
                    text
                });
            }
            else
            {
                EcpEventLogConstants.Tuple_InvalidCanaryDetected.LogPeriodicEvent(EcpEventLogExtensions.GetPeriodicKeyPerUser(), new object[]
                {
                    EcpEventLogExtensions.GetUserNameToLog(),
                    context.GetRequestUrlForLog(),
                    text,
                    string.Format("{0} in header, {1} in form, in URL {2}", canaryInHeader, canaryInForm, canaryInUrl)
                });
            }
            return(flag7);
        }
Exemplo n.º 6
0
 protected override void WriteInitializationLog()
 {
     EcpEventLogConstants.Tuple_StandardSessionInitialize.LogEvent(new object[]
     {
         base.NameForEventLog,
         EcpEventLogExtensions.GetFlightInfoForLog()
     });
 }
Exemplo n.º 7
0
 private static void LogError(string key, string errorMessage)
 {
     EcpEventLogConstants.Tuple_UnableToDetectRbacRoleViaCmdlet.LogEvent(new object[]
     {
         EcpEventLogExtensions.GetUserNameToLog(),
         key,
         errorMessage
     });
 }
Exemplo n.º 8
0
        internal void LogCmdletError(PowerShellResults results, string roleName)
        {
            string text = string.Empty;

            if (results.ErrorRecords.Length > 0)
            {
                text = results.ErrorRecords[0].ToString();
            }
            EcpEventLogConstants.Tuple_UnableToDetectRbacRoleViaCmdlet.LogEvent(new object[]
            {
                EcpEventLogExtensions.GetUserNameToLog(),
                roleName,
                text
            });
        }
Exemplo n.º 9
0
 void IEndpointBehavior.ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
 {
     EcpEventLogConstants.Tuple_EcpWebServiceStarted.LogEvent(new object[]
     {
         EcpEventLogExtensions.GetUserNameToLog(),
         endpoint.Address.Uri
     });
     endpointDispatcher.ChannelDispatcher.ErrorHandlers.Add(this);
     endpointDispatcher.DispatchRuntime.MessageInspectors.Add(this);
     foreach (DispatchOperation dispatchOperation in endpointDispatcher.DispatchRuntime.Operations)
     {
         if (dispatchOperation.Formatter != null)
         {
             dispatchOperation.Formatter = new DiagnosticsBehavior.SerializationPerformanceTracker(dispatchOperation.Formatter);
         }
     }
 }
Exemplo n.º 10
0
 public override void ProcessRequest(HttpContext context)
 {
     if (ToolkitScriptManager.CacheScriptBuckets == null)
     {
         base.ProcessRequest(context);
     }
     try
     {
         if (!ToolkitScriptManager.OutputCombineScriptResourcesFile(context))
         {
             throw new BadRequestException(new Exception("'ToolkitScriptManager' could not generate combined script resources file."));
         }
     }
     catch (Exception ex)
     {
         EcpEventLogConstants.Tuple_ScriptRequestFailed.LogPeriodicFailure(EcpEventLogExtensions.GetUserNameToLog(), context.GetRequestUrlForLog(), ex, EcpEventLogExtensions.GetFlightInfoForLog());
         throw new BadRequestException(ex);
     }
 }
Exemplo n.º 11
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);
            }
        }
Exemplo n.º 12
0
 public static void InitializeActivityContext(HttpContext httpContext, ActivityContextLoggerId eventId = ActivityContextLoggerId.Request)
 {
     try
     {
         if (httpContext != null && !ActivityContext.IsStarted)
         {
             ActivityScope activityScope = ActivityContext.DeserializeFrom(httpContext.Request, null);
             activityScope.SetProperty(ExtensibleLoggerMetadata.EventId, eventId.ToString());
             if (activityScope.DisposeTracker is DisposeTrackerObject <ActivityScope> )
             {
                 activityScope.DisposeTracker.AddExtraData(httpContext.GetRequestUrl().ToString());
             }
             httpContext.Items[ActivityContextManager.ECPActivityScopePropertyName] = activityScope;
         }
     }
     catch (Exception exception)
     {
         EcpEventLogConstants.Tuple_ActivityContextError.LogPeriodicFailure(EcpEventLogExtensions.GetUserNameToLog(), httpContext.GetRequestUrlForLog(), exception, EcpEventLogExtensions.GetFlightInfoForLog());
     }
 }
Exemplo n.º 13
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     try
     {
         this.ctlUserConsentForm.Visible = false;
         FacebookAuthenticatorConfig config = this.ReadConfiguration();
         FacebookAuthenticator       facebookAuthenticator = new FacebookAuthenticator(config);
         AppAuthorizationResponse    response = FacebookAuthenticator.ParseAppAuthorizationResponse(base.Request.QueryString);
         if (!FacebookAuthenticator.IsRedirectFromFacebook(response))
         {
             string text = facebookAuthenticator.GetAppAuthorizationUri().ToString();
             if (this.IsReconnect())
             {
                 base.Response.Redirect(text);
             }
             else
             {
                 this.ctlUserConsentForm.Visible          = true;
                 this.ctlUserConsentForm.AuthorizationUrl = text;
             }
         }
         else if (facebookAuthenticator.IsAuthorizationGranted(response))
         {
             this.ProcessAuthorizationGranted(response);
         }
         else
         {
             this.ProcessAuthorizationDenied();
         }
     }
     catch (ExchangeConfigurationException ex)
     {
         EcpEventLogConstants.Tuple_BadFacebookConfiguration.LogPeriodicEvent(EcpEventLogExtensions.GetPeriodicKeyPerUser(), new object[]
         {
             EcpEventLogExtensions.GetUserNameToLog(),
             ex
         });
         ErrorHandlingUtil.TransferToErrorPage("badfacebookconfiguration");
     }
 }
Exemplo n.º 14
0
 protected bool LogException()
 {
     if (this.shellServiceException != null)
     {
         NavBarDiagnosticsDetails navBarDiagnosticsDetails = (NavBarDiagnosticsDetails)HttpContext.Current.Cache["NavBarDiagnostics.Details"];
         if (navBarDiagnosticsDetails != null)
         {
             navBarDiagnosticsDetails.Exception = this.shellServiceException;
         }
         string nameForEventLog = this.rbacPrincipal.NameForEventLog;
         string text            = this.shellServiceException.ToString();
         ExTraceGlobals.WebServiceTracer.TraceError <string, string>(0, 0L, "NavBarHelper catch exception when try to connect to Shell Service. User: {0}. Exception: {1}.", nameForEventLog, text);
         EcpEventLogConstants.Tuple_Office365ShellServiceFailed.LogPeriodicEvent(EcpEventLogExtensions.GetPeriodicKeyPerUser(), new object[]
         {
             EcpEventLogExtensions.GetUserNameToLog(),
             text
         });
         return(true);
     }
     return(false);
 }
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     this.InstallMarketplaceAssetID = this.Context.Request.QueryString["AssetID"];
     this.MarketplaceQueryMarket    = this.Context.Request.QueryString["LC"];
     this.Scope        = this.Context.Request.QueryString["Scope"];
     this.DeploymentId = this.Context.Request.QueryString["DeployId"];
     this.Etoken       = this.GetClientTokenParameter(this.Context.Request.RawUrl);
     if (!string.IsNullOrWhiteSpace(this.InstallMarketplaceAssetID) && !string.IsNullOrWhiteSpace(this.MarketplaceQueryMarket))
     {
         return;
     }
     EcpEventLogConstants.Tuple_MissingRequiredParameterDetected.LogPeriodicEvent(EcpEventLogExtensions.GetPeriodicKeyPerUser(), new object[]
     {
         EcpEventLogExtensions.GetUserNameToLog(),
         this.Context.GetRequestUrlForLog(),
         (this.InstallMarketplaceAssetID != null) ? this.InstallMarketplaceAssetID : string.Empty,
         (this.MarketplaceQueryMarket != null) ? this.MarketplaceQueryMarket : string.Empty
     });
     ErrorHandlingUtil.TransferToErrorPage("badofficecallback");
 }
Exemplo n.º 16
0
 public static void CleanupActivityContext(HttpContext httpContext)
 {
     try
     {
         if (httpContext != null)
         {
             ActivityScope activityScope = (ActivityScope)httpContext.Items[ActivityContextManager.ECPActivityScopePropertyName];
             if (activityScope != null)
             {
                 httpContext.Items.Remove(ActivityContextManager.ECPActivityScopePropertyName);
                 if (!activityScope.IsDisposed)
                 {
                     activityScope.End();
                 }
             }
         }
     }
     catch (Exception exception)
     {
         EcpEventLogConstants.Tuple_ActivityContextError.LogPeriodicFailure(EcpEventLogExtensions.GetUserNameToLog(), httpContext.GetRequestUrlForLog(), exception, EcpEventLogExtensions.GetFlightInfoForLog());
     }
 }
		public string Translate(Identity id, Exception ex, string originalMessage)
		{
			string text;
			if (this.HasDisplayName(id))
			{
				text = this.TranslationWithDisplayName(id, originalMessage);
			}
			else
			{
				text = this.MessageWithoutDisplayName;
			}
			if (this.IsLogging)
			{
				EcpEventLogConstants.Tuple_PowershellExceptionTranslated.LogEvent(new object[]
				{
					EcpEventLogExtensions.GetUserNameToLog(),
					ex.GetType(),
					text,
					originalMessage
				});
			}
			return text;
		}
Exemplo n.º 18
0
        public PowerShellResults ProcessFileUploadRequest(HttpContext httpContext)
        {
            HttpPostedFile httpPostedFile = httpContext.Request.Files["uploadFile"];

            if (httpPostedFile != null && !string.IsNullOrEmpty(httpPostedFile.FileName) && httpPostedFile.ContentLength > 0)
            {
                string         text          = httpContext.Request.Form["handlerClass"];
                IUploadHandler uploadHandler = this.CreateInstance(text);
                if (httpPostedFile.ContentLength <= uploadHandler.MaxFileSize)
                {
                    string            text2   = httpContext.Request.Form["parameters"];
                    object            obj     = text2.JsonDeserialize(uploadHandler.SetParameterType, null);
                    UploadFileContext context = new UploadFileContext(httpPostedFile.FileName, httpPostedFile.InputStream);
                    try
                    {
                        EcpEventLogConstants.Tuple_UploadRequestStarted.LogEvent(new object[]
                        {
                            EcpEventLogExtensions.GetUserNameToLog(),
                            text,
                            text2
                        });
                        return(uploadHandler.ProcessUpload(context, (WebServiceParameters)obj));
                    }
                    finally
                    {
                        EcpEventLogConstants.Tuple_UploadRequestCompleted.LogEvent(new object[]
                        {
                            EcpEventLogExtensions.GetUserNameToLog()
                        });
                    }
                }
                ByteQuantifiedSize byteQuantifiedSize = new ByteQuantifiedSize((ulong)((long)uploadHandler.MaxFileSize));
                throw new HttpException(Strings.FileExceedsLimit(byteQuantifiedSize.ToString()));
            }
            throw new HttpException(Strings.UploadFileCannotBeEmpty);
        }
Exemplo n.º 19
0
        private bool CheckVersionCompatibility(Version internalApplicationVersion)
        {
            bool result;

            using (StringWriter stringWriter = new StringWriter())
            {
                bool flag = ProxyConnection.ValidProxyVersions.IsCompatible(internalApplicationVersion, stringWriter);
                if (!flag)
                {
                    string periodicKey = base.BaseUri.Host + internalApplicationVersion.ToString();
                    EcpEventLogConstants.Tuple_ProxyErrorCASCompatibility.LogPeriodicEvent(periodicKey, new object[]
                    {
                        EcpEventLogExtensions.GetUserNameToLog(),
                        Environment.MachineName,
                        ThemeResource.ApplicationVersion,
                        base.BaseUri.Host,
                        internalApplicationVersion,
                        stringWriter.GetStringBuilder()
                    });
                }
                result = flag;
            }
            return(result);
        }
Exemplo n.º 20
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));
            }
        }
Exemplo n.º 21
0
 public static void LogEvent(this ExEventLog.EventTuple tuple, params object[] messageArgs)
 {
     EcpEventLogExtensions.InternalLogEvent(tuple, null, messageArgs);
 }
Exemplo n.º 22
0
 public static void LogPeriodicEvent(this ExEventLog.EventTuple tuple, string periodicKey, params object[] messageArgs)
 {
     EcpEventLogExtensions.InternalLogEvent(tuple, periodicKey, messageArgs);
 }
Exemplo n.º 23
0
        private void InitializeRegionalSettings()
        {
            RegionalSettingsConfiguration regionalSettingsConfiguration = null;

            this.HasRegionalSettings = false;
            RegionalSettingsConfiguration regionalSettingsConfiguration2 = new RegionalSettingsConfiguration(new MailboxRegionalConfiguration());

            if (base.IsInRole("Get-MailboxRegionalConfiguration?Identity@R:Self") && base.IsInRole("!DelegatedAdmin"))
            {
                if (HttpRuntime.Cache[this.RegionalCacheKey] != null)
                {
                    regionalSettingsConfiguration2 = (RegionalSettingsConfiguration)HttpRuntime.Cache[this.RegionalCacheKey];
                    this.regionalCmdletStatus      = LocalSession.RegionalCmdletStatus.Finished;
                }
                else
                {
                    this.regionalCmdletStatus      = LocalSession.RegionalCmdletStatus.Waiting;
                    regionalSettingsConfiguration2 = new RegionalSettingsConfiguration(new MailboxRegionalConfiguration
                    {
                        Language = base.UserCulture
                    });
                }
                if (base.IsInRole("MailboxFullAccess"))
                {
                    regionalSettingsConfiguration = regionalSettingsConfiguration2;
                    this.HasRegionalSettings      = (regionalSettingsConfiguration != null && regionalSettingsConfiguration.UserCulture != null);
                    if (this.regionalCmdletStatus == LocalSession.RegionalCmdletStatus.Finished)
                    {
                        this.HasRegionalSettings = (this.HasRegionalSettings && regionalSettingsConfiguration.TimeZone != null);
                    }
                }
            }
            else
            {
                this.regionalCmdletStatus = LocalSession.RegionalCmdletStatus.NotNeeded;
            }
            bool        flag        = !this.HasRegionalSettings;
            HttpContext httpContext = HttpContext.Current;
            CultureInfo cultureInfo = (regionalSettingsConfiguration == null) ? null : regionalSettingsConfiguration.UserCulture;

            if (regionalSettingsConfiguration == null || (!this.CanRedirectToOwa(httpContext) && !this.HasRegionalSettings) || (cultureInfo == null && httpContext.TargetServerOrVersionSpecifiedInUrlOrCookie()))
            {
                if (regionalSettingsConfiguration != null && cultureInfo == null && regionalSettingsConfiguration.MailboxRegionalConfiguration.Language != null)
                {
                    EcpEventLogConstants.Tuple_LanguagePackIsNotInstalled.LogEvent(new object[]
                    {
                        EcpEventLogExtensions.GetUserNameToLog(),
                        regionalSettingsConfiguration.MailboxRegionalConfiguration.Language.IetfLanguageTag
                    });
                }
                regionalSettingsConfiguration = this.GetDefaultRegionalSettings(regionalSettingsConfiguration2);
                this.HasRegionalSettings      = true;
            }
            string text = httpContext.Request.QueryString["mkt"];

            if (flag && string.IsNullOrEmpty(text))
            {
                text = httpContext.Request.QueryString["mkt2"];
            }
            if (!string.IsNullOrEmpty(text))
            {
                httpContext.Response.Cookies.Add(new HttpCookie("mkt", text));
            }
            else
            {
                HttpCookie httpCookie = httpContext.Request.Cookies["mkt"];
                if (httpCookie != null)
                {
                    text = httpCookie.Value;
                }
            }
            if (!string.IsNullOrEmpty(text))
            {
                try
                {
                    CultureInfo cultureInfoByIetfLanguageTag = CultureInfo.GetCultureInfoByIetfLanguageTag(text);
                    if (Culture.IsSupportedCulture(cultureInfoByIetfLanguageTag))
                    {
                        MailboxRegionalConfiguration mailboxRegionalConfiguration = new MailboxRegionalConfiguration();
                        mailboxRegionalConfiguration.Language = Culture.GetCultureInfoInstance(cultureInfoByIetfLanguageTag.LCID);
                        mailboxRegionalConfiguration.TimeZone = regionalSettingsConfiguration.MailboxRegionalConfiguration.TimeZone;
                        if (regionalSettingsConfiguration.UserCulture != null && regionalSettingsConfiguration.UserCulture.DateTimeFormat != null)
                        {
                            mailboxRegionalConfiguration.DateFormat = regionalSettingsConfiguration.DateFormat;
                            mailboxRegionalConfiguration.TimeFormat = regionalSettingsConfiguration.TimeFormat;
                        }
                        regionalSettingsConfiguration = new RegionalSettingsConfiguration(mailboxRegionalConfiguration);
                        this.HasRegionalSettings      = true;
                    }
                }
                catch (ArgumentException)
                {
                }
            }
            if (this.HasRegionalSettings)
            {
                this.UpdateRegionalSettings(regionalSettingsConfiguration);
            }
        }