protected void DisposeMailboxSession() { this.UserContextDiposeGraph.Append(".a1"); if (this.mailboxSession != null) { this.UserContextDiposeGraph.Append(".a2"); try { UserContextUtilities.DisconnectStoreSession(this.mailboxSession); this.mailboxSession.Dispose(); } catch (StoragePermanentException ex) { this.UserContextDiposeGraph.Append(".a3"); ExTraceGlobals.UserContextTracer.TraceDebug <string>(0L, "Unable to disconnect mailbox session. exception {0}", ex.Message); } catch (StorageTransientException ex2) { this.UserContextDiposeGraph.Append(".a4"); ExTraceGlobals.UserContextTracer.TraceDebug <string>(0L, "Unable to disconnect mailbox session. exception {0}", ex2.Message); } catch (Exception ex3) { this.UserContextDiposeGraph.Append(".a5"); ExTraceGlobals.UserContextTracer.TraceError <string>(0L, "Unable to to disconnect mailbox session. exception {0}", ex3.Message); throw; } finally { this.UserContextDiposeGraph.Append(".a6"); this.mailboxSession = null; } } }
// Token: 0x06001BC9 RID: 7113 RVA: 0x0006B100 File Offset: 0x00069300 private bool LocalizeFolders(CultureInfo culture) { MailboxSession mailboxSession = null; bool result = false; try { OwaIdentity logonIdentity = RequestContext.Current.UserContext.LogonIdentity; mailboxSession = logonIdentity.CreateMailboxSession(RequestContext.Current.UserContext.ExchangePrincipal, culture); Exception[] array; mailboxSession.LocalizeDefaultFolders(out array); mailboxSession.SetMailboxLocale(culture); if (array != null && array.Length > 0) { ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "Exception Message-{0}", array[0].Message); } else { result = true; } } finally { if (mailboxSession != null) { UserContextUtilities.DisconnectStoreSession(mailboxSession); mailboxSession.Dispose(); mailboxSession = null; } } return(result); }
public void UnlockAndDisconnectMailboxSession() { if (this.mailboxSessionLock.IsWriterLockHeld) { try { if (this.mailboxSession != null) { UserContextUtilities.DisconnectStoreSession(this.mailboxSession); } } finally { this.mailboxSessionLock.ReleaseWriterLock(); } } }
private static DispatchStepResult HandleLanguagePost(RequestContext requestContext, CultureInfo culture, string timeZoneKeyName, bool isOptimized, string destination) { ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[RequestDispatcher::HandleLanguagePost] entry."); if (requestContext.UserContext == null) { throw new OwaInvalidOperationException("UserContext should be created by the time language post is handled"); } requestContext.LanguagePostUserCulture = culture; requestContext.HttpContext.Response.Cookies.Set(new HttpCookie("mkt", culture.Name)); if (!string.IsNullOrWhiteSpace(destination) && (destination.StartsWith("/ecp/", StringComparison.OrdinalIgnoreCase) || destination.StartsWith("/owa/", StringComparison.OrdinalIgnoreCase))) { requestContext.DestinationUrl = destination; } else { requestContext.DestinationUrl = string.Empty; } Culture.InternalSetThreadPreferredCulture(culture); MailboxSession mailboxSession = null; try { ExTraceGlobals.CoreCallTracer.TraceDebug <string, bool>(0L, "[RequestDispatcher::HandleLanguagePost] Attempting to save the timeZoneKeyName (tzid={0}) and isOptimized={1} in the mailbox.", timeZoneKeyName, isOptimized); OwaIdentity logonIdentity = requestContext.UserContext.LogonIdentity; mailboxSession = logonIdentity.CreateMailboxSession(requestContext.UserContext.ExchangePrincipal, culture); if (requestContext.UserContext.IsExplicitLogon && !mailboxSession.CanActAsOwner) { throw new OwaExplicitLogonException("User has no access rights to the mailbox", "ErrorExplicitLogonAccessDenied"); } try { ExTraceGlobals.CoreCallTracer.TraceDebug <int>(0L, "[RequestDispatcher::HandleLanguagePost] Trying to save the culture to the AD (lcid={0})", culture.LCID); PreferredCultures preferredCultures = new PreferredCultures(requestContext.UserContext.ExchangePrincipal.PreferredCultures); preferredCultures.AddSupportedCulture(culture, new Predicate <CultureInfo>(ClientCultures.IsSupportedCulture)); Culture.SetPreferredCulture(requestContext.UserContext.ExchangePrincipal, preferredCultures, mailboxSession.GetADRecipientSession(false, ConsistencyMode.FullyConsistent)); requestContext.UserContext.ExchangePrincipal = requestContext.UserContext.ExchangePrincipal.WithPreferredCultures(preferredCultures); } catch (Exception ex) { if (!(ex is ADOperationException) && !(ex is InvalidOperationException)) { throw; } requestContext.FailedToSaveUserCulture = true; if (ExTraceGlobals.CoreCallTracer.IsTraceEnabled(TraceType.ErrorTrace)) { StringBuilder stringBuilder = new StringBuilder("Failed to save user's culture in the AD."); stringBuilder.Append("\n\nException: "); stringBuilder.Append(ex.GetType().ToString()); stringBuilder.Append("\n"); stringBuilder.Append(ex.Message); stringBuilder.Append(")"); if (!string.IsNullOrEmpty(ex.StackTrace)) { stringBuilder.Append("\n\nCallstack:\n"); stringBuilder.Append(ex.StackTrace); } ExTraceGlobals.CoreCallTracer.TraceError(0L, stringBuilder.ToString()); } } UserOptionsType userOptionsType = new UserOptionsType(); bool flag = true; try { userOptionsType.Load(mailboxSession, false, false); } catch (QuotaExceededException ex2) { ExTraceGlobals.UserContextCallTracer.TraceDebug <string>(0L, "[RequestDispatcher::HandleLanguagePost] UserOptions.LoadAll failed. Exception: {0}.", ex2.Message); flag = false; } userOptionsType.TimeZone = timeZoneKeyName; userOptionsType.IsOptimizedForAccessibility = isOptimized; userOptionsType.UserOptionsMigrationState = UserOptionsMigrationState.WorkingHoursTimeZoneFixUp; if (flag) { UserConfigurationPropertyDefinition propertyDefinition = UserOptionPropertySchema.Instance.GetPropertyDefinition(UserConfigurationPropertyId.TimeZone); UserConfigurationPropertyDefinition propertyDefinition2 = UserOptionPropertySchema.Instance.GetPropertyDefinition(UserConfigurationPropertyId.IsOptimizedForAccessibility); UserConfigurationPropertyDefinition propertyDefinition3 = UserOptionPropertySchema.Instance.GetPropertyDefinition(UserConfigurationPropertyId.UserOptionsMigrationState); userOptionsType.Commit(mailboxSession, new UserConfigurationPropertyDefinition[] { propertyDefinition, propertyDefinition2, propertyDefinition3 }); } RequestDispatcher.InitializeFavorites(mailboxSession); } finally { if (mailboxSession != null) { UserContextUtilities.DisconnectStoreSession(mailboxSession); mailboxSession.Dispose(); mailboxSession = null; } } return(DispatchStepResult.Continue); }