Esempio n. 1
0
        internal static MailboxSession GetClonedMailboxSession(Guid mailboxGuid, CultureInfo cultureInfo, LogonType logonType, string userContextKey, ExchangePrincipal exchangePrincipal, IADOrgPerson person, ClientSecurityContext clientSecurityContext, GenericIdentity genericIdentity, bool unifiedLogon)
        {
            MailboxSession clonedMailboxSession = null;
            UserContext    userContext          = null;
            string         expectedMailboxKey   = string.Empty;

            if (!string.IsNullOrEmpty(userContextKey))
            {
                try
                {
                    OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                    {
                        UserContextManager.UserContextCacheWrapper userContextCacheWrapper = (UserContextManager.UserContextCacheWrapper)HttpRuntime.Cache.Get(userContextKey);
                        if (userContextCacheWrapper != null && userContextCacheWrapper.UserContext != null && userContextCacheWrapper.UserContext.TerminationStatus == UserContextTerminationStatus.NotTerminate)
                        {
                            userContext = (userContextCacheWrapper.UserContext as UserContext);
                            if (userContext != null && userContext.FeaturesManager != null && userContext.FeaturesManager.ServerSettings.OwaMailboxSessionCloning.Enabled && userContext.UserCulture != null && !userContext.IsExplicitLogon)
                            {
                                expectedMailboxKey   = AccessingPrincipalTiedCache.BuildKeyCacheKey(mailboxGuid, cultureInfo, logonType);
                                clonedMailboxSession = userContext.CloneMailboxSession(expectedMailboxKey, exchangePrincipal, person, clientSecurityContext, genericIdentity, unifiedLogon);
                            }
                        }
                    });
                }
                catch (GrayException ex)
                {
                    ExTraceGlobals.UserContextCallTracer.TraceError(0L, string.Format("Exception while cloning MailboxSession, MailboxKey: {0}, Exception: {1}", expectedMailboxKey, ex.Message));
                }
            }
            return(clonedMailboxSession);
        }
        public MailboxSession CloneMailboxSession(string mailboxKey, ExchangePrincipal exchangePrincipal, IADOrgPerson person, ClientSecurityContext clientSecurityContext, GenericIdentity genericIdentity, bool unifiedLogon)
        {
            MailboxSession result = null;

            if (!string.IsNullOrEmpty(mailboxKey) && !base.IsDisposed && this.mailboxSession != null)
            {
                string text = AccessingPrincipalTiedCache.BuildKeyCacheKey(this.clonedMailboxProperties.MailboxGuid, this.clonedMailboxProperties.MailboxCulture, this.clonedMailboxProperties.LogonType);
                if (mailboxKey.Equals(text, StringComparison.InvariantCulture))
                {
                    if (this.ExchangePrincipal != null && object.Equals(this.ExchangePrincipal.ObjectId, exchangePrincipal.ObjectId))
                    {
                        result = this.mailboxSession.CloneWithBestAccess(exchangePrincipal, person, clientSecurityContext, this.clonedMailboxProperties.ClientInfoString, genericIdentity, unifiedLogon);
                    }
                    else
                    {
                        ExTraceGlobals.UserContextCallTracer.TraceWarning(0L, string.Format("CloneMailboxSession: Mailbox owner not same, mailboxkey:{0}", text));
                    }
                }
            }
            return(result);
        }