Example #1
0
 public static void TerminateSession(IMailboxContext userContext, CacheItemRemovedReason abandonedReason)
 {
     ExTraceGlobals.UserContextTracer.TraceDebug(0L, "UserContextManager.TerminateSession");
     if (userContext == null)
     {
         throw new ArgumentNullException("userContext");
     }
     try
     {
         userContext.LogBreadcrumb("TerminateSession");
         string text = string.Empty;
         if (userContext.LogonIdentity != null && userContext.LogonIdentity.UserSid != null)
         {
             text = userContext.LogonIdentity.UserSid.ToString();
         }
         if (!string.IsNullOrEmpty(text))
         {
             PerformanceCounterManager.UpdatePerfCounteronUserContextDeletion(text, false, false, Globals.ArePerfCountersEnabled);
         }
     }
     finally
     {
         userContext.Dispose();
         userContext = null;
     }
 }
Example #2
0
        private static void InsertIntoCache(HttpContext httpContext, IMailboxContext userContext)
        {
            UserContextManager.UserContextCacheWrapper userContextCacheWrapper = (UserContextManager.UserContextCacheWrapper)HttpRuntime.Cache.Get(userContext.Key.ToString());
            if (userContextCacheWrapper == null)
            {
                userContextCacheWrapper = new UserContextManager.UserContextCacheWrapper
                {
                    Lock = new OwaRWLockWrapper()
                };
            }
            UserContextManager.TombstoneExistingUserContext(userContextCacheWrapper);
            userContextCacheWrapper.UserContext = userContext;
            int num = UserContextManager.UserContextTimeout;

            if (UserAgentUtilities.IsMonitoringRequest(httpContext.Request.UserAgent))
            {
                num = 1;
                if (userContext.UserPrincipalName.EndsWith(".exchangemon.net", StringComparison.InvariantCultureIgnoreCase))
                {
                    ExMonitoringRequestTracker.Instance.ReportMonitoringRequest(httpContext.Request);
                }
            }
            HttpRuntime.Cache.Insert(userContext.Key.ToString(), userContextCacheWrapper, null, DateTime.MaxValue, new TimeSpan((long)num * 600000000L), CacheItemPriority.NotRemovable, new CacheItemRemovedCallback(UserContextManager.UserContextRemovedCallback));
            userContext.LogBreadcrumb("Cached:Key=" + userContext.Key.ToString());
        }
Example #3
0
        private static void TombstoneExistingUserContext(UserContextManager.UserContextCacheWrapper wrapper)
        {
            IMailboxContext userContext = wrapper.UserContext;

            if (userContext != null)
            {
                userContext.LogBreadcrumb("This context will be tombstoned.");
                string key = string.Format("Tombstoned-{0}", userContext.Key.ToString());
                UserContextManager.UserContextCacheWrapper value = new UserContextManager.UserContextCacheWrapper
                {
                    Lock        = new OwaRWLockWrapper(),
                    UserContext = userContext
                };
                HttpRuntime.Cache.Insert(key, value, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(1.0), CacheItemPriority.NotRemovable, new CacheItemRemovedCallback(UserContextManager.UserContextRemovedCallback));
            }
        }