private MailboxSession CreateMailboxSession() { MailboxSession mailboxSession = null; bool flag = false; try { ExTraceGlobals.EventDispatcherTracer.TraceDebug <MailboxDispatcher>((long)this.GetHashCode(), "{0}: Creating mailbox session...", this); mailboxSession = this.DatabaseInfo.GetMailbox(this.mailboxOwner, ClientType.EventBased, "EventDispatcher"); base.TracePfd("PFD AIS {0} {1}: Created mailbox session.", new object[] { 30807, this }); mailboxSession.ExTimeZone = ExTimeZone.CurrentTimeZone; flag = true; } finally { if (!flag && mailboxSession != null) { mailboxSession.Dispose(); } } this.controller.DatabaseCounters.MailboxSessionsInUseByDispatchers.Increment(); return(mailboxSession); }
// Token: 0x06000AB8 RID: 2744 RVA: 0x00045EFC File Offset: 0x000440FC private void DelayTableCallback(MailboxInfo mailbox, MailboxSession session) { bool flag = false; try { ExTraceGlobals.MWITracer.TraceDebug <MailboxInfo>((long)this.GetHashCode(), "MwiAssistant.DelayTableCallback running for {0}", mailbox); if (session == null) { ExchangePrincipal principal = ExchangePrincipal.FromLocalServerMailboxGuid(mailbox.OrganizationId.ToADSessionSettings(), base.DatabaseInfo.Guid, mailbox.Guid); session = base.DatabaseInfo.GetMailbox(principal, ClientType.TimeBased, "MwiAssistant Sync Thread"); flag = true; } ExTraceGlobals.MWITracer.TraceDebug <MailboxSession, MailboxInfo>((long)this.GetHashCode(), "MwiAssistant.DelayTableCallback: Created session {0} for {1}", session, mailbox); this.SendMwiMessage(mailbox, session); } catch (Exception error) { if (!this.TryHandleException(mailbox, error)) { throw; } } finally { if (flag && session != null) { session.Dispose(); session = 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); }
// Token: 0x06000662 RID: 1634 RVA: 0x000309BC File Offset: 0x0002EBBC protected override void InvokeInternal() { if (this.IsSystemArbitrationMailbox() && this.IsDumpsterOverQuota()) { this.isOverQuota = true; if (AuditQuotaEnforcer.Tracer.IsTraceEnabled(TraceType.DebugTrace)) { AuditQuotaEnforcer.Tracer.TraceDebug <AuditQuotaEnforcer>((long)this.GetHashCode(), "{0}: The system arbitration mailbox is over dumpster warning quota. Processing the adminaudits folder.", this); } MailboxSession mailboxSession = base.MailboxDataForTags.MailboxSession; MailboxSession mailboxSession2 = null; try { mailboxSession2 = MailboxSession.OpenAsSystemService(mailboxSession.MailboxOwner, CultureInfo.InvariantCulture, mailboxSession.ClientInfoString); } catch (ObjectNotFoundException arg) { if (AuditQuotaEnforcer.Tracer.IsTraceEnabled(TraceType.DebugTrace)) { AuditQuotaEnforcer.Tracer.TraceDebug <IExchangePrincipal, ObjectNotFoundException>((long)mailboxSession.GetHashCode(), "{0}: Failed to reopen the session with SystemService because the mailbox is missing. {1}", mailboxSession.MailboxOwner, arg); } } catch (StorageTransientException arg2) { if (AuditQuotaEnforcer.Tracer.IsTraceEnabled(TraceType.WarningTrace)) { AuditQuotaEnforcer.Tracer.TraceWarning <IExchangePrincipal, MailboxSession, StorageTransientException>((long)mailboxSession.GetHashCode(), "{0}: Failed to reopen the session with SystemService: {1}.\nError:\n{2}", mailboxSession.MailboxOwner, mailboxSession, arg2); } } catch (StoragePermanentException arg3) { if (AuditQuotaEnforcer.Tracer.IsTraceEnabled(TraceType.ErrorTrace)) { AuditQuotaEnforcer.Tracer.TraceError <IExchangePrincipal, MailboxSession, StoragePermanentException>((long)mailboxSession.GetHashCode(), "{0}: Failed to reopen the session with SystemService: {1}.\nError:\n{2}", mailboxSession.MailboxOwner, mailboxSession, arg3); } } if (mailboxSession2 != null) { try { base.MailboxDataForTags.MailboxSession = mailboxSession2; base.InvokeInternal(); } finally { base.MailboxDataForTags.MailboxSession = mailboxSession; mailboxSession2.Dispose(); mailboxSession2 = null; } } if (base.IsEnabled) { this.LogAuditsCleanupEvent(); } } }
private bool SetUpConnectivityTests(TestCasConnectivity.TestCasConnectivityRunInstance instance, out CasTransactionOutcome outcome) { MailboxSession mailboxSession = null; outcome = new CasTransactionOutcome(base.CasFqdn, Strings.ValidatingTestCasConnectivityRunInstance, Strings.ValidatingTestCasConnectivityRunInstance, this.MonitoringLatencyPerformanceCounter(), base.LocalSiteName, true, string.Empty); if (instance == null) { base.WriteMonitoringEvent(2020, this.CmdletMonitoringEventSource, EventTypeEnumeration.Error, base.ShortErrorMsgFromException(new ArgumentNullException("instance"))); outcome.Update(CasTransactionResultEnum.Failure); return(false); } this.userName = instance.credentials.UserName; if (!this.SetUpConnTestValidateAndMakeADUser(instance, out outcome)) { return(false); } if (!this.SetUpConnTestSetExchangePrincipal(instance, out outcome)) { return(false); } if (instance.credentials.Password == null) { base.WriteMonitoringEvent(2020, this.CmdletMonitoringEventSource, EventTypeEnumeration.Error, base.ShortErrorMsgFromException(new ArgumentNullException("password"))); outcome.Update(CasTransactionResultEnum.Failure); return(false); } if (instance.LightMode) { return(true); } try { if (!this.SetUpConnTestSetCreateMailboxSession(instance, out mailboxSession, out outcome)) { return(false); } if (!this.SetUpConnTestSendTestMessage(instance, mailboxSession, out outcome)) { return(false); } } finally { if (mailboxSession != null) { mailboxSession.Dispose(); mailboxSession = null; } } return(true); }
// Token: 0x06000641 RID: 1601 RVA: 0x0002FDBC File Offset: 0x0002DFBC protected override void InvokeInternal() { if (!base.IsEnabled) { return; } MailboxSession mailboxSession = base.MailboxDataForTags.MailboxSession; MailboxSession mailboxSession2 = null; try { mailboxSession2 = MailboxSession.OpenAsSystemService(mailboxSession.MailboxOwner, CultureInfo.InvariantCulture, mailboxSession.ClientInfoString); } catch (ObjectNotFoundException arg) { if (AuditExpirationEnforcer.Tracer.IsTraceEnabled(TraceType.DebugTrace)) { AuditExpirationEnforcer.Tracer.TraceDebug <IExchangePrincipal, ObjectNotFoundException>((long)mailboxSession.GetHashCode(), "{0}: Failed to reopen the session with SystemService because the mailbox is missing. {1}", mailboxSession.MailboxOwner, arg); } } catch (StorageTransientException arg2) { if (AuditExpirationEnforcer.Tracer.IsTraceEnabled(TraceType.WarningTrace)) { AuditExpirationEnforcer.Tracer.TraceWarning <IExchangePrincipal, MailboxSession, StorageTransientException>((long)mailboxSession.GetHashCode(), "{0}: Failed to reopen the session with SystemService: {1}.\nError:\n{2}", mailboxSession.MailboxOwner, mailboxSession, arg2); } } catch (StoragePermanentException arg3) { if (AuditExpirationEnforcer.Tracer.IsTraceEnabled(TraceType.ErrorTrace)) { AuditExpirationEnforcer.Tracer.TraceError <IExchangePrincipal, MailboxSession, StoragePermanentException>((long)mailboxSession.GetHashCode(), "{0}: Failed to reopen the session with SystemService: {1}.\nError:\n{2}", mailboxSession.MailboxOwner, mailboxSession, arg3); } } if (mailboxSession2 != null) { try { base.MailboxDataForTags.MailboxSession = mailboxSession2; base.InvokeInternal(); } finally { base.MailboxDataForTags.MailboxSession = mailboxSession; mailboxSession2.Dispose(); mailboxSession2 = null; } } }
private void ExecuteSyncStateOperation(Action <StoreSession, CoreFolder> operation) { using (base.RHTracker.Start()) { if (base.IsPublicFolderMove || base.IsPublicFolderMailboxRestore) { PublicFolderSession publicFolderSession = this.GetPublicFolderSession(); using (CoreFolder coreFolder = CoreFolder.Bind(publicFolderSession, publicFolderSession.GetTombstonesRootFolderId())) { operation(publicFolderSession, coreFolder); goto IL_A9; } } MailboxSession mailboxSession = null; bool flag = false; try { if (base.UseHomeMDB) { mailboxSession = this.GetMailboxSession(); } else { mailboxSession = this.OpenSystemMailbox(); flag = true; } using (CoreFolder coreFolder2 = CoreFolder.Create(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Configuration), false, "MailboxReplicationService SyncStates", CreateMode.OpenIfExists)) { coreFolder2.Save(SaveMode.FailOnAnyConflict); operation(mailboxSession, coreFolder2); } } finally { if (flag && mailboxSession != null) { mailboxSession.Dispose(); } } IL_A9 :; } }
internal DelegateSessionEntry GetDelegateSessionEntry(IExchangePrincipal principal, OpenBy openBy) { MailboxSession mailboxSession = null; DelegateSessionEntry delegateSessionEntry = null; bool flag = false; try { if (!this.DelegateSessionCacheInstance.TryGet(principal, openBy, out delegateSessionEntry)) { mailboxSession = MailboxSession.InternalOpenDelegateAccess(this.masterMailboxSession, principal); delegateSessionEntry = this.DelegateSessionCacheInstance.Add(new DelegateSessionEntry(mailboxSession, openBy)); } if (!delegateSessionEntry.IsConnected) { delegateSessionEntry.Connect(); } flag = true; } finally { if (!flag) { if (delegateSessionEntry != null) { this.DelegateSessionCacheInstance.RemoveEntry(delegateSessionEntry); } else if (mailboxSession != null) { mailboxSession.CanDispose = true; mailboxSession.Dispose(); mailboxSession = null; } } } return(delegateSessionEntry); }
internal override BaseQueryResult GetData(BaseQuery query) { Stopwatch stopwatch = Stopwatch.StartNew(); MailTipsQuery mailTipsQuery = (MailTipsQuery)query; mailTipsQuery.LatencyTracker = new Dictionary <string, long>(4); EmailAddress email = query.Email; MailTips mailTips = new MailTips(query.RecipientData); mailTips.Permission = mailTipsQuery.Permission; mailTips.MarkAsPending(MailTipTypes.OutOfOfficeMessage | MailTipTypes.MailboxFullStatus); int traceId = this.clientContext.GetHashCode(); MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress>((long)traceId, "{0} / {1}: Getting mailbox MailTips...", TraceContext.Get(), mailTips.EmailAddress); MailTipsQueryResult mailTipsQueryResult = null; DateTime utcNow = DateTime.UtcNow; if (utcNow > this.deadline) { MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress, TimeSpan>((long)traceId, "{0} / {1}: Timeout expired before opening mailbox session {2}", TraceContext.Get(), mailTips.EmailAddress, utcNow - this.deadline); return(this.HandleException(email, stopwatch, mailTipsQuery, new TimeoutExpiredException("Opening-Mailbox-Session"))); } MailboxSession session = null; bool outOfOfficeSuccess = false; bool mailboxFullSuccess = false; try { mailTipsQueryResult = this.RunUnderExceptionHandler(email, stopwatch, mailTipsQuery, delegate { Stopwatch stopwatch = Stopwatch.StartNew(); ExchangePrincipal exchangePrincipal = mailTipsQuery.ExchangePrincipal; MailboxAccessInfo accessInfo = new MailboxAccessInfo(new WindowsPrincipal(WindowsIdentity.GetCurrent())); session = MailboxSession.ConfigurableOpen(exchangePrincipal, accessInfo, CultureInfo.InvariantCulture, "Client=MSExchangeRPC;Action=MailTips", LogonType.Admin, MailTipsLocalQuery.MailboxPropertyDefinitions, MailboxSession.InitializationFlags.DefaultFolders | MailboxSession.InitializationFlags.SuppressFolderIdPrefetch | MailboxSession.InitializationFlags.DeferDefaultFolderIdInitialization | MailboxSession.InitializationFlags.IgnoreForcedFolderInit, MailTipsLocalQuery.MailboxDefaultFolderTypes); session.AccountingObject = this.callerBudget; mailTipsQuery.LatencyTracker["OpenSession"] = stopwatch.ElapsedMilliseconds; stopwatch.Stop(); MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress, long>((long)traceId, "{0} / {1}: MailboxSession opened in {2} milliseconds", TraceContext.Get(), mailTips.EmailAddress, stopwatch.ElapsedMilliseconds); return(null); }); if (mailTipsQueryResult != null) { MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress>((long)traceId, "{0} / {1}: Unable to open mailbox session", TraceContext.Get(), mailTips.EmailAddress); return(mailTipsQueryResult); } utcNow = DateTime.UtcNow; if (utcNow > this.deadline) { MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress, TimeSpan>((long)traceId, "{0} / {1}: Timeout expired before getting mailbox-full {2}", TraceContext.Get(), mailTips.EmailAddress, utcNow - this.deadline); return(this.HandleException(email, stopwatch, mailTipsQuery, new TimeoutExpiredException("Getting-MailboxFull"))); } mailTipsQueryResult = this.RunUnderExceptionHandler(email, stopwatch, mailTipsQuery, delegate { mailboxFullSuccess = this.GetMailboxFullStatus(traceId, session, mailTips); mailTipsQuery.LatencyTracker["GetMailboxFull"] = stopwatch.ElapsedMilliseconds; return(null); }); if (mailTipsQueryResult != null) { MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress>((long)traceId, "{0} / {1}: Unable to get mailbox-full, but will try to get OOF.", TraceContext.Get(), mailTips.EmailAddress); } utcNow = DateTime.UtcNow; if (utcNow > this.deadline) { MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress, TimeSpan>((long)traceId, "{0} / {1}: Timeout expired before getting out-of-office message {2}", TraceContext.Get(), mailTips.EmailAddress, utcNow - this.deadline); return(this.HandleException(email, stopwatch, mailTipsQuery, new TimeoutExpiredException("Getting-OutOfOffice"))); } mailTipsQueryResult = this.RunUnderExceptionHandler(email, stopwatch, mailTipsQuery, delegate { outOfOfficeSuccess = this.GetOutOfOfficeMessage(traceId, session, mailTips); mailTipsQuery.LatencyTracker["GetOOF"] = stopwatch.ElapsedMilliseconds; return(null); }); if (mailTipsQueryResult != null) { MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress>((long)traceId, "{0} / {1}: Unable to get OOF, returning an error.", TraceContext.Get(), mailTips.EmailAddress); return(mailTipsQueryResult); } } finally { if (session != null) { session.Dispose(); } mailTipsQuery.LatencyTracker["DisposeSession"] = stopwatch.ElapsedMilliseconds; if (mailTipsQueryResult != null) { mailTips.Exception = mailTipsQueryResult.ExceptionInfo; } MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress, bool>((long)traceId, "{0} / {1}: OutOfOffice message success: {2}", TraceContext.Get(), mailTips.EmailAddress, outOfOfficeSuccess); MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress, bool>((long)traceId, "{0} / {1}: MailboxFull success: {2}", TraceContext.Get(), mailTips.EmailAddress, mailboxFullSuccess); if (!outOfOfficeSuccess) { mailTips.MarkAsUnavailable(MailTipTypes.OutOfOfficeMessage); } if (!mailboxFullSuccess) { mailTips.MarkAsUnavailable(MailTipTypes.MailboxFullStatus); } MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress>((long)traceId, "{0} / {1}: Returning MailTipsQueryResult", TraceContext.Get(), mailTips.EmailAddress); mailTipsQueryResult = new MailTipsQueryResult(mailTips); stopwatch.Stop(); MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress, long>((long)traceId, "{0} / {1}: LocalQuery took {2} milliseconds", TraceContext.Get(), mailTips.EmailAddress, stopwatch.ElapsedMilliseconds); } return(mailTipsQueryResult); }
private void Execute(MapiTransactionOutcome transactionOutcome) { ExchangePrincipal mailboxOwner = null; MapiTransactionResultEnum resultEnum = MapiTransactionResultEnum.Failure; string error = string.Empty; TimeSpan latency = TimeSpan.Zero; Guid? mailboxGuid = null; MailboxMiscFlags?mailboxMiscFlags = null; try { if (this.adRecipient == null) { try { string errorStringBasedOnDatabaseCopyState = this.GetErrorStringBasedOnDatabaseCopyState(); if (!string.IsNullOrWhiteSpace(errorStringBasedOnDatabaseCopyState)) { error = errorStringBasedOnDatabaseCopyState; } else { error = Strings.MapiTransactionErrorMsgNoMailbox; } } catch (MapiPermanentException ex) { error = Strings.MapiTransactionDiagnosticStoreStateCheckFailure(this.ShortErrorMsgFromException(ex)); this.diagnosticContext = ex.DiagCtx.ToCompactString(); } catch (MapiRetryableException ex2) { error = Strings.MapiTransactionDiagnosticStoreStateCheckFailure(this.ShortErrorMsgFromException(ex2)); this.diagnosticContext = ex2.DiagCtx.ToCompactString(); } transactionOutcome.Update(MapiTransactionResultEnum.Failure, TimeSpan.Zero, error, mailboxGuid, mailboxMiscFlags, this.isDatabaseCopyActive); } else { try { if (this.adRecipient is ADSystemMailbox) { mailboxOwner = ExchangePrincipal.FromADSystemMailbox(ADSessionSettings.FromRootOrgScopeSet(), (ADSystemMailbox)this.adRecipient, this.targetServer); } else { ADSessionSettings adSessionSettings = this.adRecipient.OrganizationId.ToADSessionSettings(); mailboxOwner = ExchangePrincipal.FromMailboxData(adSessionSettings, this.adRecipient.DisplayName, this.targetServer.Fqdn, this.targetServer.ExchangeLegacyDN, this.adRecipient.LegacyExchangeDN, this.isArchiveMailbox ? ((ADUser)this.adRecipient).ArchiveGuid : ((ADUser)this.adRecipient).ExchangeGuid, this.database.Guid, this.adRecipient.PrimarySmtpAddress.ToString(), this.adRecipient.Id, new List <CultureInfo>(), Array <Guid> .Empty, RecipientType.Invalid, RemotingOptions.AllowCrossSite); } } catch (ObjectNotFoundException ex3) { transactionOutcome.Update(MapiTransactionResultEnum.Failure, TimeSpan.Zero, this.ShortErrorMsgFromException(ex3), mailboxGuid, mailboxMiscFlags, this.isDatabaseCopyActive); this.diagnosticContext = this.GetDiagnosticContext(ex3); return; } MailboxSession mailboxSession = null; Stopwatch stopwatch = Stopwatch.StartNew(); try { if (!this.transactionTimeouted) { try { mailboxSession = MailboxSession.OpenAsAdmin(mailboxOwner, CultureInfo.InvariantCulture, "Client=StoreActiveMonitoring;Action=Test-MapiConnectivity", false, false, !this.isDatabaseCopyActive); } catch (StorageTransientException exception) { error = this.DiagnoseMapiOperationException(exception, out resultEnum); return; } catch (StoragePermanentException exception2) { error = this.DiagnoseMapiOperationException(exception2, out resultEnum); return; } if (!this.transactionTimeouted) { using (Folder.Bind(mailboxSession, DefaultFolderType.Inbox, new PropertyDefinition[] { FolderSchema.ItemCount })) { resultEnum = MapiTransactionResultEnum.Success; error = string.Empty; } mailboxSession.Mailbox.Load(new PropertyDefinition[] { MailboxSchema.MailboxGuid, MailboxSchema.MailboxMiscFlags }); byte[] array = mailboxSession.Mailbox.TryGetProperty(MailboxSchema.MailboxGuid) as byte[]; object obj = mailboxSession.Mailbox.TryGetProperty(MailboxSchema.MailboxMiscFlags); if (array != null && array.Length == 16) { mailboxGuid = new Guid?(new Guid(array)); } if (obj is int) { mailboxMiscFlags = new MailboxMiscFlags?((MailboxMiscFlags)obj); } latency = stopwatch.Elapsed; } } } finally { if (mailboxSession != null) { mailboxSession.Dispose(); } } } } catch (Exception exception3) { error = this.ShortErrorMsgFromException(exception3); } finally { lock (this.timeoutOperationLock) { if (!this.transactionTimeouted) { transactionOutcome.Update(resultEnum, latency, error, mailboxGuid, mailboxMiscFlags, this.isDatabaseCopyActive); } } } }
private void OutputLogs() { TaskLogger.LogEnter(); ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(base.SessionSettings, this.logSourceUser, RemotingOptions.AllowCrossSite); using (MailboxSession mailboxSession = StoreTasksHelper.OpenMailboxSession(exchangePrincipal, "Get-CalendarDiagnosticLogs")) { Dictionary <string, List <VersionedId> > allCalendarLogItems = this.GetAllCalendarLogItems(mailboxSession); if (allCalendarLogItems.Keys.Count == 0) { this.WriteWarning(Strings.CalendarDiagnosticLogsNotFound(this.Subject, mailboxSession.MailboxOwner.MailboxInfo.DisplayName)); return; } MailboxSession mailboxSession2 = null; try { if (this.outputMailboxUser != null) { ExchangePrincipal principal = exchangePrincipal; mailboxSession2 = StoreTasksHelper.OpenMailboxSession(principal, "Get-CalendarDiagnosticLogs"); } else { mailboxSession2 = mailboxSession; } SmtpAddress address = new SmtpAddress(exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString()); foreach (KeyValuePair <string, List <VersionedId> > keyValuePair in allCalendarLogItems) { if (!string.IsNullOrEmpty(this.LogLocation)) { this.diagnosticLogWriter = new CalendarDiagnosticLogFileWriter(this.LogLocation, mailboxSession.MailboxOwner.MailboxInfo.DisplayName, address.Domain); } base.WriteProgress(Strings.GetCalendarDiagnosticLog(this.Identity.ToString()), Strings.SavingCalendarLogs, 0); List <VersionedId> value = keyValuePair.Value; int count = value.Count; foreach (VersionedId storeId in value) { using (Item item = Item.Bind(mailboxSession, storeId)) { if (!(item.LastModifiedTime > this.EndDate) && !(item.LastModifiedTime < this.StartDate)) { if (!string.IsNullOrEmpty(this.LogLocation)) { string text = null; if (Directory.Exists(this.LogLocation)) { FileInfo fileInfo = this.diagnosticLogWriter.LogItem(item, out text); if (fileInfo == null && !string.IsNullOrEmpty(text)) { base.WriteWarning(text); } else { base.WriteResult(new CalendarLog(item, fileInfo, (string)address)); } } } else { base.WriteResult(new CalendarLog(item, (string)address)); } } } } } } finally { if (mailboxSession2 != null) { mailboxSession2.Dispose(); } } } TaskLogger.LogExit(); }
// Token: 0x06000A2B RID: 2603 RVA: 0x00042F58 File Offset: 0x00041158 public void Emit(MailboxSession session, CalendarNotificationType type, IList <CalendarInfo> events) { ExTraceGlobals.AssistantTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Text Emitter is invoked, subject: {0} for user {1}", events[0].NormalizedSubject, this.MailboxData.Settings.LegacyDN); if (type == CalendarNotificationType.Uninteresting) { return; } Emitter emitter = null; foreach (Emitter emitter2 in this.MailboxData.Settings.Text.TextNotification.CalendarNotificationSettings.Emitters) { if (EmitterType.TextMessaging == emitter2.Type) { emitter = emitter2; break; } } if (emitter == null || emitter.PhoneNumbers.Count == 0) { return; } MailboxRegionalConfiguration regionalConfiguration = this.MailboxData.Settings.Text.RegionalConfiguration; CultureInfo cultureInfo = regionalConfiguration.Language ?? CultureInfo.InvariantCulture; string text = regionalConfiguration.TimeFormat; if (string.IsNullOrEmpty(text)) { text = cultureInfo.DateTimeFormat.ShortTimePattern; } string text2 = regionalConfiguration.DateFormat; if (string.IsNullOrEmpty(text2)) { text2 = cultureInfo.DateTimeFormat.ShortDatePattern; } bool flag = false; try { if (session == null) { ExchangePrincipal mailboxOwner = ExchangePrincipal.FromLocalServerMailboxGuid(this.MailboxData.Settings.GetADSettings(), this.MailboxData.DatabaseGuid, this.MailboxData.MailboxGuid); session = MailboxSession.OpenAsSystemService(mailboxOwner, CultureInfo.InvariantCulture, "Client=TBA;Action=Emit"); flag = true; } ExTraceGlobals.AssistantTracer.TraceDebug <string>((long)this.GetHashCode(), "Text Emitter is emitting for user {0}", this.MailboxData.Settings.LegacyDN); if (CalendarNotificationType.Summary == type) { CalendarNotificationContentVersion1Point0 calendarNotificationContentVersion1Point = new CalendarNotificationContentVersion1Point0(); calendarNotificationContentVersion1Point.CalNotifType = type; calendarNotificationContentVersion1Point.CalNotifTypeDesc = Strings.notifTypeSummary.ToString(cultureInfo); string agendaDateFormat = TextNotificationFactory.TextMessagingEmitter.GetAgendaDateFormat(text2); string timeOfStartTime = string.Empty; foreach (CalendarInfo calendarInfo in events) { timeOfStartTime = calendarInfo.StartTime.ToString("H:mm", cultureInfo); if (calendarInfo.EndTime.Subtract(calendarInfo.StartTime).Equals(TimeSpan.FromDays(1.0)) && calendarInfo.StartTime.Hour == 0 && calendarInfo.StartTime.Minute == 0) { timeOfStartTime = string.Empty; } calendarNotificationContentVersion1Point.CalEvents.Add(new CalendarEvent(cultureInfo.DateTimeFormat.GetDayName(calendarInfo.StartTime.DayOfWeek), calendarInfo.StartTime.ToString(agendaDateFormat, cultureInfo), timeOfStartTime, cultureInfo.DateTimeFormat.GetDayName(calendarInfo.EndTime.DayOfWeek), calendarInfo.EndTime.ToString(agendaDateFormat, cultureInfo), calendarInfo.EndTime.ToString("H:mm", cultureInfo), calendarInfo.NormalizedSubject ?? string.Empty, calendarInfo.Location ?? string.Empty)); } TextNotificationFactory.TextMessagingEmitter.SendTextMessage(session, emitter.PhoneNumbers, calendarNotificationContentVersion1Point.ToString(), CalNotifsCounters.NumberOfAgendasSent); } else { foreach (CalendarInfo calendarInfo2 in events) { CalendarNotificationContentVersion1Point0 calendarNotificationContentVersion1Point2 = new CalendarNotificationContentVersion1Point0(); calendarNotificationContentVersion1Point2.CalNotifType = type; bool flag2 = false; ExPerformanceCounter perfcounter; switch (type) { case CalendarNotificationType.Reminder: calendarNotificationContentVersion1Point2.CalNotifTypeDesc = Strings.notifTypeReminder.ToString(cultureInfo); perfcounter = CalNotifsCounters.NumberOfTextRemindersSent; break; case CalendarNotificationType.NewUpdate: calendarNotificationContentVersion1Point2.CalNotifTypeDesc = Strings.notifTypeNewUpdate.ToString(cultureInfo); perfcounter = CalNotifsCounters.NumberOfUpdatesSent; flag2 = true; break; case CalendarNotificationType.ChangedUpdate: calendarNotificationContentVersion1Point2.CalNotifTypeDesc = Strings.notifTypeChangedUpdate.ToString(cultureInfo); perfcounter = CalNotifsCounters.NumberOfUpdatesSent; flag2 = true; break; case CalendarNotificationType.DeletedUpdate: calendarNotificationContentVersion1Point2.CalNotifTypeDesc = Strings.notifTypeDeletedUpdate.ToString(cultureInfo); perfcounter = CalNotifsCounters.NumberOfUpdatesSent; flag2 = true; break; default: throw new InvalidOperationException("unsupported CalendarNotificationType"); } if (flag2) { CalendarChangeProcessor.UpdateAverageProcessingLatency(calendarInfo2.CreationRequestTime); } calendarNotificationContentVersion1Point2.CalEvents.Add(new CalendarEvent(cultureInfo.DateTimeFormat.GetDayName(calendarInfo2.StartTime.DayOfWeek), calendarInfo2.StartTime.ToString(text2, cultureInfo), calendarInfo2.StartTime.ToString(text, cultureInfo), cultureInfo.DateTimeFormat.GetDayName(calendarInfo2.EndTime.DayOfWeek), calendarInfo2.EndTime.ToString(text2, cultureInfo), calendarInfo2.EndTime.ToString(text, cultureInfo), calendarInfo2.NormalizedSubject ?? string.Empty, calendarInfo2.Location ?? string.Empty)); TextNotificationFactory.TextMessagingEmitter.SendTextMessage(session, emitter.PhoneNumbers, calendarNotificationContentVersion1Point2.ToString(), perfcounter); } } ExTraceGlobals.AssistantTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Text Emitter is emitted, subject: {0}, user: {1}", events[0].NormalizedSubject, this.MailboxData.Settings.LegacyDN); } finally { if (flag) { session.Dispose(); session = null; } } }
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); }
private StoreSession OpenMailboxSession(StoreMailboxData mailbox) { Guid activityId = (ActivityContext.ActivityId != null) ? ActivityContext.ActivityId.Value : Guid.Empty; AssistantBase assistant = this.Assistant as AssistantBase; string nonLocalizedName = this.Assistant.NonLocalizedName; Guid mailboxGuid = mailbox.MailboxGuid; StoreSession result; try { ExchangePrincipal exchangePrincipal; if (mailbox.TenantPartitionHint != null) { ADSessionSettings adSettings = ADSessionSettings.FromTenantPartitionHint(mailbox.TenantPartitionHint); exchangePrincipal = ExchangePrincipal.FromLocalServerMailboxGuid(adSettings, this.DatabaseInfo.Guid, mailbox.Guid); } else { exchangePrincipal = ExchangePrincipal.FromMailboxData(mailbox.Guid, this.DatabaseInfo.Guid, mailbox.OrganizationId ?? OrganizationId.ForestWideOrgId, Array <CultureInfo> .Empty); } if (mailbox.IsPublicFolderMailbox) { StoreSession storeSession = PublicFolderSession.OpenAsAdmin(null, exchangePrincipal, null, CultureInfo.InstalledUICulture, string.Format("{0};Action={1}", "Client=TBA", this.Assistant.GetType().Name), null); AssistantsLog.LogMailboxSucceedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, mailboxGuid, mailbox.DisplayName, this); result = storeSession; } else { bool flag = false; MailboxSession mailbox2 = this.DatabaseInfo.GetMailbox(exchangePrincipal, ClientType.TimeBased, this.Assistant.GetType().Name); try { mailbox2.ReconstructExchangePrincipal(); mailbox2.ExTimeZone = ExTimeZone.CurrentTimeZone; flag = true; AssistantsLog.LogMailboxSucceedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, mailboxGuid, mailbox.DisplayName, this); result = mailbox2; } finally { if (!flag) { mailbox2.Dispose(); } } } } catch (ObjectNotFoundException ex) { string text = "MailboxNotFound"; string message = string.Format("{0}: {1}", this, text); string value = string.Format("{0}:{1}", text, mailbox.MailboxGuid); ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceError((long)this.GetHashCode(), message); AssistantsLog.LogMailboxFailedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, ex, mailboxGuid, mailbox.DisplayName, this); throw new SkipException(new LocalizedString(value), ex); } catch (StorageTransientException ex2) { string message2 = string.Format("{0}: Could not open mailbox store session due to storage transient error: {1}", this, ex2.Message); ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceError((long)this.GetHashCode(), message2); AssistantsLog.LogMailboxFailedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, ex2, mailboxGuid, mailbox.DisplayName, this); Interlocked.Increment(ref this.mailboxesFailedToOpenStoreSessionCount); throw; } catch (Exception ex3) { string message3 = string.Format("{0}: Could not open mailbox store session due to error: {1}", this, ex3.Message); ExTraceGlobals.TimeBasedDatabaseJobTracer.TraceError((long)this.GetHashCode(), message3); AssistantsLog.LogMailboxFailedToOpenStoreSessionEvent(activityId, nonLocalizedName, assistant, ex3, mailboxGuid, mailbox.DisplayName, this); Interlocked.Increment(ref this.mailboxesFailedToOpenStoreSessionCount); throw; } return(result); }
// Token: 0x060008FA RID: 2298 RVA: 0x0003CBC0 File Offset: 0x0003ADC0 internal void UpdateAllUserSettings(IRecipientSession recipientSession, long cookie, Initiating.ActOnUserSettingsDelegate updateUserSettings, Predicate <ADRawEntry> validate) { QueryFilter filter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADMailboxRecipientSchema.Database, new ADObjectId(base.Context.Guid)), new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.RecipientType, RecipientType.UserMailbox) }); ADPagedReader <ADRawEntry> adpagedReader = recipientSession.FindPagedADRawEntry(null, QueryScope.SubTree, filter, null, 0, new PropertyDefinition[] { ADObjectSchema.Id, ADRecipientSchema.TextMessagingState, IADMailStorageSchema.ExchangeGuid }); using (IEnumerator <ADRawEntry> enumerator = adpagedReader.GetEnumerator()) { while (enumerator.MoveNext()) { ADRawEntry recipient = enumerator.Current; if (!base.ShouldContinue(cookie)) { break; } if (validate == null || validate(recipient)) { if (this.mailboxTable == null) { this.mailboxTable = base.Context.GetMailboxTable(ClientType.EventBased, new PropertyTagPropertyDefinition[0]); } if (!this.mailboxTable.Exists((MailboxInformation mbxInfo) => mbxInfo.MailboxGuid == (Guid)recipient[IADMailStorageSchema.ExchangeGuid])) { ADUser aduser = recipientSession.FindADUserByObjectId((ADObjectId)recipient[ADObjectSchema.Id]); if (aduser != null) { ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(aduser, null); MailboxSession mailboxSession = null; try { mailboxSession = base.Context.GetMailbox(exchangePrincipal, ClientType.EventBased, "UpdateAllUserSettings"); if (!base.ShouldContinue(cookie)) { break; } updateUserSettings(mailboxSession, recipientSession, aduser); } catch (NotSupportedException arg) { ExTraceGlobals.AssistantTracer.TraceError <string, NotSupportedException>((long)this.GetHashCode(), "Exception is caught during syncing text messaging settings to AD user object for {0}: {1}", exchangePrincipal.LegacyDn, arg); } catch (Exception ex) { if (!CalendarNotificationAssistant.TryHandleException((long)this.GetHashCode(), "Update all user's settings", exchangePrincipal.LegacyDn, ex)) { throw; } } finally { if (mailboxSession != null) { mailboxSession.Dispose(); mailboxSession = null; } } } } } } } }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); MailboxSession mailboxSession = null; try { mailboxSession = MailboxSession.OpenAsAdmin(this.principal, CultureInfo.InvariantCulture, "Client=Management;Action=Get-ActiveSyncDeviceStatistics"); DeviceInfo deviceInfo = MobileDeviceTaskHelper.GetDeviceInfo(mailboxSession, this.Identity); if (deviceInfo == null) { base.WriteError(new MobileDeviceNotExistException(this.Identity.ToString()), ErrorCategory.InvalidOperation, this.Identity); } using (SyncStateStorage syncStateStorage = SyncStateStorage.Bind(mailboxSession, deviceInfo.DeviceIdentity, null)) { if (syncStateStorage == null) { base.WriteError(new MobileDeviceNotExistException(this.Identity.ToString()), ErrorCategory.InvalidOperation, this.Identity); } using (CustomSyncState orCreateGlobalSyncState = AirSyncUtility.GetOrCreateGlobalSyncState(syncStateStorage)) { if (this.Cancel) { if (!DeviceInfo.CancelRemoteWipeFromMailbox(orCreateGlobalSyncState)) { this.WriteWarning(Strings.CannotCancelWipe(this.Identity.ToString())); } } else { DeviceInfo.StartRemoteWipeFromMailbox(syncStateStorage, orCreateGlobalSyncState, ExDateTime.UtcNow, this.validatedAddresses, this.wipeRequestorSMTP); } orCreateGlobalSyncState.Commit(); } } base.InternalProcessRecord(); } catch (FolderSaveException exception) { base.WriteError(exception, ErrorCategory.WriteError, this.Identity); } catch (CorruptSyncStateException ex) { TaskLogger.LogError(ex); base.WriteError(ex, ErrorCategory.ReadError, this.principal); } catch (InvalidSyncStateVersionException ex2) { TaskLogger.LogError(ex2); base.WriteError(ex2, ErrorCategory.ReadError, this.principal); } catch (StorageTransientException ex3) { TaskLogger.LogError(ex3); base.WriteError(ex3, ErrorCategory.ReadError, this.principal); } catch (StoragePermanentException ex4) { TaskLogger.LogError(ex4); base.WriteError(ex4, ErrorCategory.InvalidOperation, this.principal); } catch (InvalidOperationException ex5) { TaskLogger.LogError(ex5); base.WriteError(ex5, ErrorCategory.InvalidOperation, this.principal); } finally { if (mailboxSession != null) { mailboxSession.Dispose(); } TaskLogger.LogExit(); } }