// Token: 0x06001A00 RID: 6656 RVA: 0x0005DE80 File Offset: 0x0005C080
 protected RmsTemplateType[] GetRmsTemplates(OrganizationId organizationId, CultureInfo userCulture)
 {
     try
     {
         ExTraceGlobals.IrmTracer.TraceDebug <OrganizationId, CultureInfo>((long)this.GetHashCode(), "Getting rms templates for organization {0} with culture {1}", organizationId, userCulture);
         IEnumerable <RmsTemplate>     source  = this.AcquireRmsTemplates(organizationId);
         IEnumerable <RmsTemplateType> source2 = from mesrTemplate in source
                                                 select new RmsTemplateType(mesrTemplate.Id.ToString(), mesrTemplate.GetName(userCulture), mesrTemplate.GetDescription(userCulture)) into template
                                                 orderby template.Name
                                                 select template;
         string arg = string.Join(",", from template in source2
                                  select string.Format(userCulture, "{0}:{1}", new object[]
         {
             template.Id,
             template.Name
         }));
         ExTraceGlobals.IrmTracer.TraceDebug <string>((long)this.GetHashCode(), "Loaded templates= {0}", arg);
         return(source2.ToArray <RmsTemplateType>());
     }
     catch (OwaThrottlingException)
     {
         throw;
     }
     catch (Exception ex)
     {
         OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_RmsTemplateLoadFailure, organizationId.ToString(), new object[]
         {
             ex
         });
         OwaServerTraceLogger.AppendToLog(new RmsLoadingLogEvent(organizationId, ex));
     }
     return(null);
 }
 // Token: 0x06000A94 RID: 2708 RVA: 0x000244A8 File Offset: 0x000226A8
 private void LogPayloadNotPickedEvent()
 {
     if (!this.isOverMaxSize)
     {
         this.isOverMaxSize = true;
         string uriForUser = this.GetUriForUser();
         ExTraceGlobals.InstantMessagingTracer.TraceError((long)this.GetHashCode(), "InstantMessageNotifier.LogPayloadNotPickedEvent. Payload has grown too large without being picked up. User: {0}", new object[]
         {
             uriForUser
         });
         OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_PayloadNotBeingPickedup, string.Empty, new object[]
         {
             this.GetUriForUser()
         });
         PendingRequestManager pendingRequestManager = base.UserContext.PendingRequestManager;
         if (pendingRequestManager != null && pendingRequestManager.HasAnyActivePendingGetChannel())
         {
             InstantMessageUtilities.SendWatsonReport("InstantMessageNotifier.LogPayloadNotPickedEvent", (IUserContext)base.UserContext, new OverflowException(string.Format("Payload has grown too large without being picked up. User: {0}", uriForUser)));
         }
         this.Cancel();
         this.Add(new InstantMessagePayload(InstantMessagePayloadType.ServiceUnavailable)
         {
             ServiceError = InstantMessageServiceError.OverMaxPayloadSize
         });
     }
 }
Beispiel #3
0
        private void LoadThemeFiles(string resourcesDiskRelativeFolderPath)
        {
            ExTraceGlobals.ThemesCallTracer.TraceDebug(0L, "LoadThemeFiles");
            string text = Path.Combine(FolderConfiguration.Instance.RootPath, resourcesDiskRelativeFolderPath, ThemeManager.themesFolderSubPath);

            if (!Directory.Exists(text))
            {
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_NoThemesFolder, string.Empty, new object[]
                {
                    text
                });
                throw new OwaThemeManagerInitializationException("Themes folder not found ('" + text + "')");
            }
            string[]     directories = Directory.GetDirectories(text);
            List <Theme> list        = new List <Theme>();

            foreach (string text2 in directories)
            {
                Path.GetFileNameWithoutExtension(text2);
                ExTraceGlobals.ThemesTracer.TraceDebug <string>(0L, "Inspecting theme folder '{0}'", text2);
                Theme theme = Theme.Create(text2);
                if (theme == null)
                {
                    ExTraceGlobals.ThemesTracer.TraceWarning <string>(0L, "Theme folder '{0}' is invalid", text2);
                }
                else
                {
                    list.Add(theme);
                    if (theme.IsBase)
                    {
                        this.baseTheme = theme;
                    }
                    if (this.storageIdToIdMap.ContainsKey(theme.StorageId))
                    {
                        throw new OwaThemeManagerInitializationException(string.Format("Duplicated theme found (folder name={0})", theme.FolderName));
                    }
                    this.storageIdToIdMap.Add(theme.StorageId, uint.MaxValue);
                    ExTraceGlobals.ThemesTracer.TraceDebug <string>(0L, "Successfully added theme. Name={0}", theme.DisplayName);
                }
            }
            list.Sort();
            this.themes = list.ToArray();
            for (int j = 0; j < this.themes.Length; j++)
            {
                this.storageIdToIdMap[this.themes[j].StorageId] = (uint)j;
            }
            if (this.baseTheme == null)
            {
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_NoBaseTheme, string.Empty, new object[]
                {
                    ThemeManager.BaseThemeFolderName
                });
                throw new OwaThemeManagerInitializationException(string.Format("Couldn't find a base theme (folder name={0})", ThemeManager.BaseThemeFolderName));
            }
        }
Beispiel #4
0
 private static void ThrowParserException(XmlTextReader reader, string folderName, string description, ExEventLog.EventTuple tuple, params object[] eventMessageArgs)
 {
     OwaDiagnostics.LogEvent(tuple, string.Empty, eventMessageArgs);
     throw new OwaThemeManagerInitializationException(string.Format(CultureInfo.InvariantCulture, "Invalid theme info file in folder '{0}'. Line {1} Position {2}.{3}", new object[]
     {
         folderName,
         reader.LineNumber.ToString(CultureInfo.InvariantCulture),
         reader.LinePosition.ToString(CultureInfo.InvariantCulture),
         (description != null) ? (" " + description) : string.Empty
     }), null, null);
 }
        // Token: 0x0600036F RID: 879 RVA: 0x0000DA10 File Offset: 0x0000BC10
        private void LogExceptionFromBposShellService(Exception e, string guid)
        {
            Exception baseException = e.GetBaseException();

            OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_BposHeaderConfigurationError, string.Empty, new object[]
            {
                baseException.ToString(),
                this.userPrincipalName,
                this.userPuid + " GUID: " + guid,
                this.boxServiceUrl
            });
        }
        // Token: 0x06000A44 RID: 2628 RVA: 0x000238E8 File Offset: 0x00021AE8
        private static bool HasPrivateKey(X509Certificate2 cert)
        {
            bool result = true;

            if (!cert.HasPrivateKey)
            {
                ExTraceGlobals.InstantMessagingTracer.TraceDebug(0L, "IM Certificate does not have a private key.");
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_ErrorIMCertificateNoPrivateKey, string.Empty, new object[0]);
                OwaDiagnostics.PublishMonitoringEventNotification(ExchangeComponent.OwaDependency.Name, Feature.InstantMessage.ToString(), "IM Certificate does not have a private key.", ResultSeverityLevel.Error);
                result = false;
            }
            return(result);
        }
        // Token: 0x06000A41 RID: 2625 RVA: 0x00023644 File Offset: 0x00021844
        private static X509Certificate2 FindCertByThumbprint(string thumbprint)
        {
            X509Certificate2 x509Certificate = null;
            X509Store        x509Store       = new X509Store(StoreName.My, StoreLocation.LocalMachine);

            try
            {
                x509Store.Open(OpenFlags.ReadOnly);
                X509Certificate2Collection x509Certificate2Collection = x509Store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false);
                x509Certificate = ((x509Certificate2Collection.Count > 0) ? x509Certificate2Collection[0] : null);
                if (x509Certificate == null)
                {
                    ExTraceGlobals.InstantMessagingTracer.TraceDebug(0L, "IM Certificate with thumbprint {0} could not be found.", new object[]
                    {
                        thumbprint
                    });
                    OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_ErrorIMCertificateNotFound, string.Empty, new object[]
                    {
                        thumbprint
                    });
                    OwaDiagnostics.PublishMonitoringEventNotification(ExchangeComponent.OwaDependency.Name, Feature.InstantMessage.ToString(), string.Format("IM Certificate with thumbprint {0} could not be found.", thumbprint), ResultSeverityLevel.Error);
                }
            }
            catch (CryptographicException ex)
            {
                ExTraceGlobals.InstantMessagingTracer.TraceError(0L, "Cryptographic exception is thrown: {0}", new object[]
                {
                    ex
                });
            }
            catch (SecurityException ex2)
            {
                ExTraceGlobals.InstantMessagingTracer.TraceError(0L, "Security exception is thrown: {0}", new object[]
                {
                    ex2
                });
            }
            catch (ArgumentException ex3)
            {
                ExTraceGlobals.InstantMessagingTracer.TraceError(0L, "Argument exception is thrown: {0}", new object[]
                {
                    ex3
                });
            }
            finally
            {
                x509Store.Close();
            }
            return(x509Certificate);
        }
        // Token: 0x06000A46 RID: 2630 RVA: 0x0002397C File Offset: 0x00021B7C
        private static void DoesCertificateExpireSoon(X509Certificate2 cert)
        {
            ExDateTime exDateTime = new ExDateTime(ExTimeZone.CurrentTimeZone, cert.NotAfter);
            TimeSpan   threshold  = new TimeSpan(30, 0, 0, 0);

            if (ExDateTime.Compare(exDateTime, ExDateTime.Now) >= 0 && ExDateTime.Compare(exDateTime, ExDateTime.Now, threshold) == 0)
            {
                ExTraceGlobals.InstantMessagingTracer.TraceDebug(0L, "IM Certificate will expire soon.");
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_ErrorIMCertificateWillExpireSoon, string.Empty, new object[]
                {
                    exDateTime
                });
            }
        }
        // Token: 0x06000A42 RID: 2626 RVA: 0x000237D0 File Offset: 0x000219D0
        private static bool IsExpired(X509Certificate2 cert)
        {
            bool       result     = false;
            ExDateTime exDateTime = new ExDateTime(ExTimeZone.CurrentTimeZone, cert.NotAfter);

            if (ExDateTime.Compare(exDateTime, ExDateTime.Now) <= 0)
            {
                ExTraceGlobals.InstantMessagingTracer.TraceDebug(0L, "IM Certificate has expired.");
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_ErrorIMCertificateExpired, string.Empty, new object[]
                {
                    exDateTime
                });
                OwaDiagnostics.PublishMonitoringEventNotification(ExchangeComponent.OwaDependency.Name, Feature.InstantMessage.ToString(), "IM Certificate has expired.", ResultSeverityLevel.Error);
                result = true;
            }
            return(result);
        }
Beispiel #10
0
        // Token: 0x06000964 RID: 2404 RVA: 0x0002007C File Offset: 0x0001E27C
        private static VdirConfiguration CreateInstance(Guid vDirADObjectGuid)
        {
            ITopologyConfigurationSession topologyConfigurationSession = VdirConfiguration.CreateADSystemConfigurationSessionScopedToFirstOrg();
            string     text = null;
            ADObjectId adobjectId;

            if (vDirADObjectGuid == Guid.Empty)
            {
                Server server = topologyConfigurationSession.FindLocalServer();
                string text2  = HttpRuntime.AppDomainAppVirtualPath.Replace("'", "''");
                if (text2[0] == '/')
                {
                    text2 = text2.Substring(1);
                }
                text = HttpRuntime.AppDomainAppId;
                if (text[0] == '/')
                {
                    text = text.Substring(1);
                }
                int num = text.IndexOf('/');
                text       = text.Substring(num);
                text       = string.Format("IIS://{0}{1}", server.Fqdn, text);
                num        = text.LastIndexOf('/');
                text       = VdirConfiguration.GetWebSiteName(text.Substring(0, num));
                adobjectId = new ADObjectId(server.DistinguishedName).GetDescendantId("Protocols", "HTTP", new string[]
                {
                    string.Format("{0} ({1})", text2, text)
                });
            }
            else
            {
                adobjectId = new ADObjectId(vDirADObjectGuid);
            }
            ADOwaVirtualDirectory adowaVirtualDirectory = topologyConfigurationSession.Read <ADOwaVirtualDirectory>(adobjectId);

            if (adowaVirtualDirectory == null)
            {
                ExTraceGlobals.ConfigurationManagerTracer.TraceDebug <ADObjectId, string>(0L, "Unable to retrieve the vdir configuration for {0}, website name {1}", adobjectId, text);
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_OwaConfigurationNotFound, adobjectId.ToDNString(), new object[]
                {
                    adobjectId.ToString()
                });
                throw new ADConfigurationException();
            }
            return(new VdirConfiguration(topologyConfigurationSession, adowaVirtualDirectory));
        }
Beispiel #11
0
        // Token: 0x06000966 RID: 2406 RVA: 0x000201FC File Offset: 0x0001E3FC
        private static string GetWebSiteName(string webSiteRootPath)
        {
            string result;

            try
            {
                using (DirectoryEntry directoryEntry = new DirectoryEntry(webSiteRootPath))
                {
                    using (DirectoryEntry parent = directoryEntry.Parent)
                    {
                        if (parent != null)
                        {
                            result = (((string)parent.Properties["ServerComment"].Value) ?? string.Empty);
                        }
                        else
                        {
                            result = string.Empty;
                        }
                    }
                }
            }
            catch (DirectoryServicesCOMException ex)
            {
                ExTraceGlobals.ConfigurationManagerTracer.TraceDebug <string, DirectoryServicesCOMException>(0L, "Unable to retrieve the web site name for {0}. DirectoryServicesCOMException {1}", webSiteRootPath, ex);
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_OwaConfigurationWebSiteUnavailable, webSiteRootPath, new object[]
                {
                    webSiteRootPath,
                    ex
                });
                throw new ADConfigurationException(ex);
            }
            catch (DirectoryNotFoundException ex2)
            {
                ExTraceGlobals.ConfigurationManagerTracer.TraceDebug <string, DirectoryNotFoundException>(0L, "Unable to retrieve the web site name for {0}. DirectoryNotFoundException {1}", webSiteRootPath, ex2);
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_OwaConfigurationWebSiteUnavailable, webSiteRootPath, new object[]
                {
                    webSiteRootPath,
                    ex2
                });
                throw new ADConfigurationException(ex2);
            }
            return(result);
        }
        // Token: 0x06000280 RID: 640 RVA: 0x00009514 File Offset: 0x00007714
        public WacDiscoveryResultBase FetchDiscoveryResults()
        {
            OwaServerTraceLogger.AppendToLog(new WacAttachmentLogEvent(string.Format(CultureInfo.InvariantCulture, "Fetching wac discovery data from endPoint {0}", new object[]
            {
                this.wacDiscoveryEndPoint
            })));
            string text = null;
            WacDiscoveryResultBase wacDiscoveryResultBase = null;

            ExEventLog.EventTuple tuple = ClientsEventLogConstants.Tuple_WacDiscoveryDataRetrievalFailure;
            for (int i = 0; i < 3; i++)
            {
                WebRequest webRequest = WebRequest.Create(this.wacDiscoveryEndPoint);
                webRequest.Method = "GET";
                try
                {
                    WebResponse response = webRequest.GetResponse();
                    using (Stream responseStream = response.GetResponseStream())
                    {
                        using (XmlReader xmlReader = XmlReader.Create(responseStream))
                        {
                            if (this.ParseUntilExternalHttpsNetZoneNode(xmlReader))
                            {
                                wacDiscoveryResultBase = new WacDiscoveryResultSuccess();
                                this.ParseNetZoneData(xmlReader, wacDiscoveryResultBase);
                                wacDiscoveryResultBase.MarkInitializationComplete();
                                if (wacDiscoveryResultBase.WacViewableFileTypes.Length != 0)
                                {
                                    text = string.Format(CultureInfo.InvariantCulture, "Successfully retrieved configuration data from {0}. Supported File types: {1}", new object[]
                                    {
                                        this.wacDiscoveryEndPoint,
                                        wacDiscoveryResultBase.GetWacViewableFileTypesDisplayText()
                                    });
                                    OwaServerTraceLogger.AppendToLog(new WacAttachmentLogEvent(text));
                                    tuple = ClientsEventLogConstants.Tuple_WacDiscoveryDataRetrievedSuccessfully;
                                }
                                else
                                {
                                    text = string.Format(CultureInfo.InvariantCulture, "Successfully retrieved configuration data from {0}, but no file types defined", new object[]
                                    {
                                        this.wacDiscoveryEndPoint
                                    });
                                    OwaServerTraceLogger.AppendToLog(new WacAttachmentLogEvent(text));
                                    wacDiscoveryResultBase = new WacDiscoveryResultFailure(new WacDiscoveryFailureException(text));
                                }
                            }
                            else
                            {
                                text = string.Format(CultureInfo.InvariantCulture, "Successfully retrieved configuration data from {0}, but retrieved discovery xml does not contain an external https net zone node", new object[]
                                {
                                    this.wacDiscoveryEndPoint
                                });
                                OwaServerTraceLogger.AppendToLog(new WacAttachmentLogEvent(text));
                                wacDiscoveryResultBase = new WacDiscoveryResultFailure(new WacDiscoveryFailureException(text));
                            }
                        }
                    }
                    break;
                }
                catch (WebException ex)
                {
                    text = string.Format(CultureInfo.InvariantCulture, "Error retrieving wac discovery data from endpoint {0}. Exception was {1}", new object[]
                    {
                        this.wacDiscoveryEndPoint,
                        ex
                    });
                    OwaServerTraceLogger.AppendToLog(new WacAttachmentLogEvent(text));
                    wacDiscoveryResultBase = new WacDiscoveryResultFailure(new WacDiscoveryFailureException(text));
                }
                Thread.Sleep(100);
            }
            OwaDiagnostics.LogEvent(tuple, string.Empty, new object[]
            {
                text
            });
            return(wacDiscoveryResultBase);
        }
Beispiel #13
0
        private static void UserContextRemoved(object parameters)
        {
            bool flag = false;

            try
            {
                if (flag)
                {
                }
            }
            finally
            {
                try
                {
                    object[] array = parameters as object[];
                    string   text  = array[0] as string;
                    object   obj   = array[1];
                    CacheItemRemovedReason cacheItemRemovedReason = (CacheItemRemovedReason)array[2];
                    UserContextManager.UserContextCacheWrapper userContextCacheWrapper = obj as UserContextManager.UserContextCacheWrapper;
                    if (userContextCacheWrapper != null)
                    {
                        if (userContextCacheWrapper.UserContext != null)
                        {
                            userContextCacheWrapper.UserContext.LogBreadcrumb("UserContextRemoved Invoked.  Key=" + text);
                        }
                        if (userContextCacheWrapper.Lock != null && !userContextCacheWrapper.Lock.IsWriterLockHeld)
                        {
                            try
                            {
                                if (userContextCacheWrapper.Lock.LockWriterElastic(3000) && userContextCacheWrapper.UserContext != null)
                                {
                                    ExTraceGlobals.UserContextTracer.TraceDebug <string, IMailboxContext, int>(0L, "Removing user context from cache, Key={0}, User context instance={1}, Reason={2}", text, userContextCacheWrapper.UserContext, (int)cacheItemRemovedReason);
                                    userContextCacheWrapper.UserContext.LogBreadcrumb("UserContextRemoved Terminating.  Key=" + userContextCacheWrapper.UserContext.Key.ToString());
                                    UserContextManager.TerminateSession(userContextCacheWrapper.UserContext, cacheItemRemovedReason);
                                    userContextCacheWrapper.UserContext.LogBreadcrumb("UserContextRemoved Terminated.  Key=" + userContextCacheWrapper.UserContext.Key.ToString());
                                    userContextCacheWrapper.UserContext.TerminationStatus = UserContextTerminationStatus.TerminateCompleted;
                                }
                            }
                            finally
                            {
                                if (userContextCacheWrapper.Lock.IsWriterLockHeld)
                                {
                                    userContextCacheWrapper.Lock.ReleaseWriterLock();
                                }
                            }
                        }
                        if (userContextCacheWrapper.UserContext != null && userContextCacheWrapper.UserContext.TerminationStatus != UserContextTerminationStatus.TerminateCompleted)
                        {
                            userContextCacheWrapper.UserContext.TerminationStatus = UserContextTerminationStatus.TerminatePending;
                            userContextCacheWrapper.UserContext.AbandonedReason   = cacheItemRemovedReason;
                        }
                    }
                }
                catch (ThreadAbortException)
                {
                }
                catch (Exception ex)
                {
                    OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_UserContextTerminationError, string.Empty, new object[]
                    {
                        ex.ToString()
                    });
                    ExTraceGlobals.UserContextTracer.TraceDebug(0L, "Sending watson report");
                    ExWatson.SendReport(ex, ReportOptions.None, null);
                }
            }
        }
        // Token: 0x06000273 RID: 627 RVA: 0x00008E98 File Offset: 0x00007098
        private WacConfiguration()
        {
            this.BlockWacViewingThroughUI      = new BoolAppSettingsEntry("BlockWacViewingThroughUI", false, ExTraceGlobals.AttachmentHandlingTracer).Value;
            this.AccessTokenExpirationDuration = new TimeSpanAppSettingsEntry("WacAccessTokenExpirationInMinutes", TimeSpanUnit.Minutes, new TimeSpan(8, 0, 0), ExTraceGlobals.AttachmentHandlingTracer).Value;
            this.AccessTokenCacheTime          = new TimeSpanAppSettingsEntry("WacAccessTokenCacheTimeInMinutes", TimeSpanUnit.Minutes, new TimeSpan(0, 30, 0), ExTraceGlobals.AttachmentHandlingTracer).Value;
            this.UseHttpsForWacUrl             = new BoolAppSettingsEntry("UseHttpsForWacUrl", true, ExTraceGlobals.AttachmentHandlingTracer).Value;
            this.DiscoveryDataRefreshInterval  = new TimeSpanAppSettingsEntry("WacDiscoveryDataRefreshIntervalInMinutes", TimeSpanUnit.Minutes, TimeSpan.FromHours(8.0), ExTraceGlobals.AttachmentHandlingTracer).Value;
            this.DiscoveryDataRetrievalErrorBaseRefreshInterval = new TimeSpanAppSettingsEntry("WacDiscoveryDataRetrievalErrorBaseRefreshIntervalInMinutes", TimeSpanUnit.Minutes, TimeSpan.FromMinutes(5.0), ExTraceGlobals.AttachmentHandlingTracer).Value;
            this.MdbCacheInterval              = new TimeSpanAppSettingsEntry("WacMdbCacheIntervalInMinutes", TimeSpanUnit.Minutes, TimeSpan.FromMinutes(30.0), ExTraceGlobals.AttachmentHandlingTracer).Value;
            this.CobaltStoreCleanupInterval    = new TimeSpanAppSettingsEntry("WacCobaltStoreCleanupIntervalInHours", TimeSpanUnit.Hours, TimeSpan.FromHours(24.0), ExTraceGlobals.AttachmentHandlingTracer).Value;
            this.CobaltStoreExpirationInterval = new TimeSpanAppSettingsEntry("WacCobaltStoreExpirationIntervalInHours", TimeSpanUnit.Hours, TimeSpan.FromHours(12.0), ExTraceGlobals.AttachmentHandlingTracer).Value;
            this.AutoSaveInterval              = new TimeSpanAppSettingsEntry("WacAutoSaveIntervalInSeconds", TimeSpanUnit.Seconds, TimeSpan.FromSeconds(180.0), ExTraceGlobals.AttachmentHandlingTracer).Value;
            this.DiagnosticsEnabled            = new BoolAppSettingsEntry("WacDiagnosticsEnabled", false, ExTraceGlobals.AttachmentHandlingTracer).Value;
            this.EditingEnabled        = new BoolAppSettingsEntry("WacEditingEnabled", true, ExTraceGlobals.AttachmentHandlingTracer).Value;
            this.BlobStoreMemoryBudget = new IntAppSettingsEntry("WacCobaltBlobStoreMemoryBudget", 524288, ExTraceGlobals.AttachmentHandlingTracer).Value;
            if (this.BlockWacViewingThroughUI)
            {
                this.WacDiscoveryEndPoint = null;
                string text = "BlockWacViewingThroughUI is set to true";
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_WacConfigurationSetupSuccessful, string.Empty, new object[]
                {
                    text
                });
                OwaServerTraceLogger.AppendToLog(new WacAttachmentLogEvent(text));
                return;
            }
            string text2 = new StringAppSettingsEntry("WacUrlHostName", null, ExTraceGlobals.AttachmentHandlingTracer).Value;
            bool   flag  = false;

            if (string.IsNullOrEmpty(text2) && !VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).OwaDeployment.WacConfigurationFromOrgConfig.Enabled)
            {
                flag  = true;
                text2 = WacConfiguration.ReadFromOrganizationConfig();
            }
            if (string.IsNullOrEmpty(text2) || !Uri.TryCreate(text2, UriKind.Absolute, out this.WacDiscoveryEndPoint))
            {
                this.BlockWacViewingThroughUI = true;
                string text3 = string.Format("The WacUrlHostName was invalid. Expected a valid Uri. Actual value was '{0}'. Value read from '{1}'", text2, flag ? "OrganizationConfig" : "web.config");
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_WacConfigurationSetupError, string.Empty, new object[]
                {
                    text3
                });
                OwaServerTraceLogger.AppendToLog(new WacAttachmentLogEvent(text3));
                return;
            }
            string value = new StringAppSettingsEntry("WacDataCenterPrefix", null, ExTraceGlobals.AttachmentHandlingTracer).Value;

            if (!string.IsNullOrEmpty(value))
            {
                this.WacDiscoveryEndPoint = new Uri(string.Format(CultureInfo.InvariantCulture, "{0}?dcPrefix={1}", new object[]
                {
                    this.WacDiscoveryEndPoint,
                    value
                }));
            }
            string text4 = string.Format("Wac enabled and configured with {0} as the endpoint. Value was read from {1}.", this.WacDiscoveryEndPoint, flag ? "OrganizationConfig" : "web.config");

            OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_WacConfigurationSetupSuccessful, string.Empty, new object[]
            {
                text4
            });
            text4 += string.Format(" DiagnosticsEnabled={0}, EditingEnabled={1}", this.DiagnosticsEnabled, this.EditingEnabled);
            OwaServerTraceLogger.AppendToLog(new WacAttachmentLogEvent(text4));
        }
        // Token: 0x06000983 RID: 2435 RVA: 0x00021474 File Offset: 0x0001F674
        private static ErrorInformation GetExceptionHandlingInformation(Exception exception, RequestContext requestContext)
        {
            bool sendWatsonReport = false;

            Strings.IDs?    messageId        = null;
            string          messageParameter = null;
            string          lids             = null;
            SupportLevel?   supportLevel     = null;
            IMailboxContext mailboxContext   = (requestContext != null) ? requestContext.UserContext : null;
            string          text             = string.Empty;

            if (mailboxContext != null)
            {
                text = mailboxContext.PrimarySmtpAddress.ToString();
            }
            string message;

            if (exception is OwaNotSupportedException)
            {
                message = exception.Message;
            }
            else if (exception is OwaIdentityException)
            {
                sendWatsonReport = false;
                message          = exception.Message;
            }
            else if (exception is OwaExistentNotificationPipeException)
            {
                message   = Strings.GetLocalizedString(1295605912);
                messageId = new Strings.IDs?(1295605912);
            }
            else if (exception is OwaNotificationPipeException)
            {
                message          = Strings.GetLocalizedString(-771052428);
                messageId        = new Strings.IDs?(-771052428);
                sendWatsonReport = false;
            }
            else if (exception is OwaOperationNotSupportedException)
            {
                message = exception.Message;
            }
            else if (exception is OwaADObjectNotFoundException)
            {
                OwaADUserNotFoundException ex = exception as OwaADUserNotFoundException;
                supportLevel = new SupportLevel?(SupportLevel.TenantAdmin);
                if (ex != null && !string.IsNullOrWhiteSpace(ex.UserName))
                {
                    message          = string.Format(Strings.GetLocalizedString(-765910865), ex.UserName);
                    messageId        = new Strings.IDs?(-765910865);
                    messageParameter = ex.UserName;
                }
                else
                {
                    message   = Strings.GetLocalizedString(-950823100);
                    messageId = new Strings.IDs?(-950823100);
                }
            }
            else if (exception is OwaLockTimeoutException || exception is BailOutException)
            {
                message   = Strings.GetLocalizedString(-116001901);
                messageId = new Strings.IDs?(-116001901);
                if (requestContext != null)
                {
                    requestContext.HttpContext.Response.AppendToLog("&s=ReqTimeout");
                }
            }
            else if (exception is ObjectExistedException)
            {
                message   = Strings.GetLocalizedString(-1399945920);
                messageId = new Strings.IDs?(-1399945920);
            }
            else if (exception is MailboxInSiteFailoverException)
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(26604436);
                messageId        = new Strings.IDs?(26604436);
                supportLevel     = new SupportLevel?(SupportLevel.Transient);
            }
            else if (exception is MailboxCrossSiteFailoverException || exception is WrongServerException)
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(26604436);
                messageId        = new Strings.IDs?(26604436);
                supportLevel     = new SupportLevel?(SupportLevel.Transient);
            }
            else if (exception is MailboxInTransitException)
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(-1739093686);
                messageId        = new Strings.IDs?(-1739093686);
                supportLevel     = new SupportLevel?(SupportLevel.Transient);
            }
            else if (exception is ResourceUnhealthyException)
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(198161982);
                messageId        = new Strings.IDs?(198161982);
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_ErrorResourceUnhealthy, string.Empty, new object[]
                {
                    text,
                    exception.ToString()
                });
            }
            else if (exception is ConnectionFailedPermanentException || exception is ServerNotFoundException)
            {
                message          = string.Format(Strings.GetLocalizedString(-765910865), text);
                messageId        = new Strings.IDs?(-765910865);
                messageParameter = text;
                supportLevel     = new SupportLevel?(SupportLevel.EscalateToSupport);
            }
            else if (exception is ConnectionFailedTransientException || exception is MailboxOfflineException)
            {
                if (exception.InnerException is MapiExceptionLogonFailed && mailboxContext.IsExplicitLogon)
                {
                    message      = Strings.GetLocalizedString(882888134);
                    messageId    = new Strings.IDs?(882888134);
                    supportLevel = new SupportLevel?(SupportLevel.TenantAdmin);
                }
                else
                {
                    message      = Strings.GetLocalizedString(198161982);
                    messageId    = new Strings.IDs?(198161982);
                    supportLevel = new SupportLevel?(SupportLevel.Transient);
                }
            }
            else if (exception is SendAsDeniedException)
            {
                message      = Strings.GetLocalizedString(2059222100);
                messageId    = new Strings.IDs?(2059222100);
                supportLevel = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is ADTransientException)
            {
                message      = Strings.GetLocalizedString(634294555);
                messageId    = new Strings.IDs?(634294555);
                supportLevel = new SupportLevel?(SupportLevel.Transient);
            }
            else if (exception is ADOperationException)
            {
                message      = Strings.GetLocalizedString(-256207770);
                messageId    = new Strings.IDs?(-256207770);
                supportLevel = new SupportLevel?(SupportLevel.Unknown);
            }
            else if (exception is DataValidationException)
            {
                message      = Strings.GetLocalizedString(-256207770);
                messageId    = new Strings.IDs?(-256207770);
                supportLevel = new SupportLevel?(SupportLevel.EscalateToSupport);
            }
            else if (exception is SaveConflictException || exception is OwaSaveConflictException)
            {
                message   = Strings.GetLocalizedString(-482397486);
                messageId = new Strings.IDs?(-482397486);
            }
            else if (exception is FolderSaveException)
            {
                message   = Strings.GetLocalizedString(1487149567);
                messageId = new Strings.IDs?(1487149567);
            }
            else if (exception is ObjectValidationException)
            {
                message   = Strings.GetLocalizedString(-1670564952);
                messageId = new Strings.IDs?(-1670564952);
            }
            else if (exception is CorruptDataException)
            {
                message   = Strings.GetLocalizedString(-1670564952);
                messageId = new Strings.IDs?(-1670564952);
            }
            else if (exception is Microsoft.Exchange.Data.Storage.QuotaExceededException || exception is MessageTooBigException)
            {
                message   = Strings.GetLocalizedString(-640701623);
                messageId = new Strings.IDs?(-640701623);
            }
            else if (exception is SubmissionQuotaExceededException)
            {
                message   = Strings.GetLocalizedString(178029729);
                messageId = new Strings.IDs?(178029729);
            }
            else if (exception is MessageSubmissionExceededException)
            {
                message   = Strings.GetLocalizedString(-1381793955);
                messageId = new Strings.IDs?(-1381793955);
            }
            else if (exception is AttachmentExceededException)
            {
                message   = Strings.GetLocalizedString(-2137146650);
                messageId = new Strings.IDs?(-2137146650);
            }
            else if (exception is ResourcesException || exception is NoMoreConnectionsException)
            {
                message      = Strings.GetLocalizedString(-639453714);
                messageId    = new Strings.IDs?(-639453714);
                supportLevel = new SupportLevel?(SupportLevel.EscalateToSupport);
            }
            else if (exception is AccountDisabledException)
            {
                message      = Strings.GetLocalizedString(531497785);
                messageId    = new Strings.IDs?(531497785);
                supportLevel = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is AccessDeniedException)
            {
                message   = Strings.GetLocalizedString(995407892);
                messageId = new Strings.IDs?(995407892);
                AccessDeniedException ex2 = (AccessDeniedException)exception;
                if (ex2.InnerException != null)
                {
                    Exception innerException = ex2.InnerException;
                    if (innerException is MapiExceptionPasswordChangeRequired || innerException is MapiExceptionPasswordExpired)
                    {
                        message   = Strings.GetLocalizedString(540943741);
                        messageId = new Strings.IDs?(540943741);
                    }
                }
                supportLevel = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is InvalidLicenseException)
            {
                message          = string.Format(Strings.GetLocalizedString(468041898), requestContext.UserContext.MailboxIdentity.SafeGetRenderableName());
                messageId        = new Strings.IDs?(468041898);
                messageParameter = requestContext.UserContext.MailboxIdentity.SafeGetRenderableName();
                sendWatsonReport = false;
                supportLevel     = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is TenantAccessBlockedException)
            {
                message          = Strings.GetLocalizedString(1045420842);
                messageId        = new Strings.IDs?(1045420842);
                sendWatsonReport = false;
                supportLevel     = new SupportLevel?(SupportLevel.EscalateToSupport);
            }
            else if (exception is PropertyErrorException)
            {
                message   = Strings.GetLocalizedString(641346049);
                messageId = new Strings.IDs?(641346049);
            }
            else if (exception is OwaInvalidOperationException)
            {
                message   = Strings.GetLocalizedString(641346049);
                messageId = new Strings.IDs?(641346049);
            }
            else if (exception is VirusDetectedException)
            {
                message   = Strings.GetLocalizedString(-589723291);
                messageId = new Strings.IDs?(-589723291);
            }
            else if (exception is VirusScanInProgressException)
            {
                message   = Strings.GetLocalizedString(-1019777596);
                messageId = new Strings.IDs?(-1019777596);
            }
            else if (exception is VirusMessageDeletedException)
            {
                message   = Strings.GetLocalizedString(1164605313);
                messageId = new Strings.IDs?(1164605313);
            }
            else if (exception is OwaExplicitLogonException)
            {
                message          = Strings.GetLocalizedString(882888134);
                messageId        = new Strings.IDs?(882888134);
                sendWatsonReport = false;
                supportLevel     = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is NoReplicaException)
            {
                message   = Strings.GetLocalizedString(1179266056);
                messageId = new Strings.IDs?(1179266056);
            }
            else if (exception is TooManyObjectsOpenedException)
            {
                message      = Strings.GetLocalizedString(-1763248954);
                messageId    = new Strings.IDs?(-1763248954);
                supportLevel = new SupportLevel?(SupportLevel.User);
            }
            else if (exception is OwaUserHasNoMailboxAndNoLicenseAssignedException)
            {
                message      = Strings.GetLocalizedString(115127791);
                messageId    = new Strings.IDs?(115127791);
                supportLevel = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is UserHasNoMailboxException)
            {
                message          = Strings.GetLocalizedString(-765910865);
                messageId        = new Strings.IDs?(-765910865);
                messageParameter = exception.Data["PrimarySmtpAddress"].ToString();
                supportLevel     = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is StorageTransientException)
            {
                message   = Strings.GetLocalizedString(-238819799);
                messageId = new Strings.IDs?(-238819799);
                if (exception.InnerException is MapiExceptionRpcServerTooBusy)
                {
                    sendWatsonReport = false;
                    OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_ErrorMailboxServerTooBusy, string.Empty, new object[]
                    {
                        text,
                        exception.ToString()
                    });
                }
                supportLevel = new SupportLevel?(SupportLevel.Transient);
            }
            else if (exception is RulesTooBigException)
            {
                message   = Strings.GetLocalizedString(-791981113);
                messageId = new Strings.IDs?(-791981113);
            }
            else if (exception is DuplicateActionException)
            {
                message   = Strings.GetLocalizedString(-555068615);
                messageId = new Strings.IDs?(-555068615);
            }
            else if (exception is ConversionFailedException && ((ConversionFailedException)exception).ConversionFailureReason == ConversionFailureReason.CorruptContent)
            {
                message   = Strings.GetLocalizedString(-1670564952);
                messageId = new Strings.IDs?(-1670564952);
            }
            else if (exception is IOException && ErrorHandlerUtilities.IsDiskFullException(exception))
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(-1729839551);
                messageId        = new Strings.IDs?(-1729839551);
                supportLevel     = new SupportLevel?(SupportLevel.EscalateToSupport);
            }
            else if (exception is StoragePermanentException)
            {
                message   = Strings.GetLocalizedString(861904327);
                messageId = new Strings.IDs?(861904327);
                if (exception.InnerException is MapiPermanentException)
                {
                    DiagnosticContext diagCtx = ((MapiPermanentException)exception.InnerException).DiagCtx;
                    if (diagCtx != null)
                    {
                        lids = diagCtx.ToCompactString();
                    }
                }
                supportLevel = new SupportLevel?(SupportLevel.EscalateToSupport);
            }
            else if (exception is TransientException)
            {
                message      = Strings.GetLocalizedString(-1729839551);
                messageId    = new Strings.IDs?(-1729839551);
                supportLevel = new SupportLevel?(SupportLevel.Transient);
                if (exception.InnerException is MapiRetryableException)
                {
                    DiagnosticContext diagCtx2 = ((MapiRetryableException)exception.InnerException).DiagCtx;
                    if (diagCtx2 != null)
                    {
                        lids = diagCtx2.ToCompactString();
                    }
                }
            }
            else if (exception is HttpException)
            {
                HttpException ex3 = (HttpException)exception;
                message          = string.Format(Strings.GetLocalizedString(1331629462), ex3.GetHttpCode());
                messageId        = new Strings.IDs?(1331629462);
                messageParameter = ex3.GetHttpCode().ToString();
            }
            else if (exception is OverBudgetException)
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(1856724252);
                messageId        = new Strings.IDs?(1856724252);
            }
            else if (exception is COMException || exception.InnerException is COMException)
            {
                sendWatsonReport = !ErrorHandlerUtilities.ShouldIgnoreException((exception is COMException) ? exception : exception.InnerException);
                message          = Strings.GetLocalizedString(641346049);
                messageId        = new Strings.IDs?(641346049);
                supportLevel     = new SupportLevel?(SupportLevel.EscalateToSupport);
            }
            else if (exception is ThreadAbortException)
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(641346049);
                messageId        = new Strings.IDs?(641346049);
            }
            else if (exception is FaultException || exception is InvalidSerializedAccessTokenException)
            {
                sendWatsonReport = false;
                message          = exception.Message;
            }
            else if (exception is NonExistentMailboxException)
            {
                sendWatsonReport = false;
                message          = exception.Message;
                supportLevel     = new SupportLevel?(SupportLevel.TenantAdmin);
            }
            else if (exception is SlabManifestException || exception is FlightConfigurationException)
            {
                sendWatsonReport = false;
                message          = Strings.GetLocalizedString(2099558169);
                messageId        = new Strings.IDs?(2099558169);
            }
            else
            {
                sendWatsonReport = true;
                message          = Strings.GetLocalizedString(641346049);
                messageId        = new Strings.IDs?(641346049);
            }
            string empty = string.Empty;

            Strings.IDs?ds          = null;
            bool        siteMailbox = false;
            bool        flag        = ErrorHandlerUtilities.RemedyExceptionHandlingError(exception, requestContext, out empty, out ds, out siteMailbox);

            if (flag)
            {
                message   = empty;
                messageId = ds;
            }
            string groupMailboxDestination = ErrorHandlerUtilities.GetGroupMailboxDestination(exception, requestContext);

            return(new ErrorInformation
            {
                Exception = exception,
                Message = message,
                MessageId = messageId,
                MessageParameter = messageParameter,
                SendWatsonReport = sendWatsonReport,
                SharePointApp = flag,
                SiteMailbox = siteMailbox,
                GroupMailboxDestination = groupMailboxDestination,
                Lids = lids,
                SupportLevel = supportLevel
            });
        }
        // Token: 0x06001BCF RID: 7119 RVA: 0x0006B438 File Offset: 0x00069638
        private bool UpdateO365Theme(string themeId, string userPrincipalName, UserContext userContext)
        {
            bool flag = userContext.FeaturesManager.ClientServerSettings.O365Header.Enabled || userContext.FeaturesManager.ClientServerSettings.O365G2Header.Enabled;

            this.tracer.TraceDebug <bool, bool>(0L, "UpdateO365Theme::isFeatureSupported='{0}', this.skipO365Call='{1}'", flag, this.request.SkipO365Call);
            if (!flag || this.request.SkipO365Call)
            {
                return(false);
            }
            string text  = null;
            string text2 = null;
            string text3 = string.Empty;
            bool   result;

            try
            {
                using (ShellServiceClient shellServiceClient = new ShellServiceClient("MsOnlineShellService_EndPointConfiguration"))
                {
                    string text4 = ConfigurationManager.AppSettings["MsOnlineShellService_CertThumbprint"];
                    this.tracer.TraceDebug <string, CommunicationState>(1L, "UpdateO365Theme::certificateThumbprint='{0}',client.State'={1}'", text4, shellServiceClient.State);
                    shellServiceClient.ClientCredentials.ClientCertificate.Certificate = TlsCertificateInfo.FindCertByThumbprint(text4);
                    EndpointAddress address = shellServiceClient.Endpoint.Address;
                    Uri             uri     = new Uri(address.Uri.AbsoluteUri);
                    shellServiceClient.Endpoint.Address = new EndpointAddress(uri, address.Identity, new AddressHeader[0]);
                    string text5 = HttpContext.Current.Request.Headers["RPSOrgIdPUID"];
                    text  = (string.IsNullOrEmpty(text5) ? HttpContext.Current.Request.Headers["RPSPUID"] : text5);
                    text2 = shellServiceClient.Endpoint.Address.Uri.AbsoluteUri;
                    text3 = Guid.NewGuid().ToString();
                    this.tracer.TraceDebug(2L, "UpdateO365Theme::orgIdPuid='{0}', userPuid='{1}', userPrincipalName='{2}',serviceUrl='{3}'", new object[]
                    {
                        text5,
                        text,
                        userPrincipalName,
                        text2
                    });
                    SetUserThemeRequest setUserThemeRequest = new SetUserThemeRequest
                    {
                        ThemeId           = themeId,
                        TrackingGuid      = text3,
                        UserPrincipalName = userPrincipalName,
                        UserPuid          = text,
                        WorkloadId        = WorkloadAuthenticationId.Exchange
                    };
                    this.tracer.TraceDebug(3L, "UpdateO365Theme::setUserThemeRequest.ThemeId='{0}', .TrackingGuid='{1}', .UserPrincipalName='{2}', .UserPuid='{3}', .WorkloadId='{4}'", new object[]
                    {
                        setUserThemeRequest.ThemeId,
                        setUserThemeRequest.TrackingGuid,
                        setUserThemeRequest.UserPrincipalName,
                        setUserThemeRequest.UserPuid,
                        setUserThemeRequest.WorkloadId
                    });
                    shellServiceClient.SetUserTheme(setUserThemeRequest);
                    this.tracer.TraceDebug <CommunicationState>(4L, "UpdateO365Theme::setUserThemeRequest.State='{0}'", shellServiceClient.State);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                this.tracer.TraceError(5L, "UpdateO365Theme::Exception: themeId='{0}', trackingGuid='{1}', userPrincipalName='{2}', userPuid='{3}', serviceUrl='{4}', exception='{5}'", new object[]
                {
                    themeId,
                    text3,
                    userPrincipalName,
                    text,
                    text2,
                    ex
                });
                OwaDiagnostics.LogEvent(ClientsEventLogConstants.Tuple_O365SetUserThemeError, userPrincipalName + text2 + themeId, new object[]
                {
                    text,
                    userPrincipalName,
                    text3,
                    text2,
                    themeId,
                    ex
                });
                result = false;
            }
            return(result);
        }