// Token: 0x06000C3A RID: 3130 RVA: 0x0004F5C4 File Offset: 0x0004D7C4 private bool TryFindUser(MapiEvent mapiEvent, MailboxSession itemStore, out ADUser user) { IRecipientSession adrecipientSession = itemStore.GetADRecipientSession(false, ConsistencyMode.IgnoreInvalid); user = (adrecipientSession.FindByExchangeGuid(mapiEvent.MailboxGuid) as ADUser); return(user != null); }
private LocalAssociationStore GetAssociationStore(MailboxSession adminMailboxSession, IMailboxAssociationPerformanceTracker performanceTracker) { IRecipientSession adrecipientSession = adminMailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid); IMailboxLocator mailboxLocator = new GroupMailboxLocator(adrecipientSession, this.groupMailboxToLogon.ExternalDirectoryObjectId, this.groupMailboxToLogon.LegacyDn); return(new LocalAssociationStore(mailboxLocator, adminMailboxSession, false, new XSOFactory(), performanceTracker, MailboxAssociationDiagnosticsFrameFactory.Default.CreateLogger(this.groupMailboxToLogon.MailboxInfo.MailboxGuid, this.organizationId))); }
protected override PerformInvitationResults InternalPerformInvitation(MailboxSession mailboxSession, SharingContext context, ValidRecipient[] recipients, IFrontEndLocator frontEndLocator) { if (recipients.Length != 1) { throw new InvalidOperationException("Only single recipient is allowed."); } ValidRecipient validRecipient = recipients[0]; string folderId = context.FolderId.ToBase64String(); ExternalUser externalUser = this.ApplyPermission(mailboxSession, new SmtpAddress(validRecipient.SmtpAddress), context); IRecipientSession adrecipientSession = mailboxSession.GetADRecipientSession(false, ConsistencyMode.FullyConsistent); ADUser aduser = (ADUser)adrecipientSession.Read(mailboxSession.MailboxOwner.ObjectId); string text = aduser.SharingAnonymousIdentities.FindExistingUrlId(SharingDataType.ReachCalendar.PublishResourceName, folderId); Uri owaVdirUrl = OwaAnonymousVdirLocater.Instance.GetOwaVdirUrl(mailboxSession.MailboxOwner, frontEndLocator); SmtpAddress primarySmtpAddress = mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress; ObscureUrl obscureUrl = ObscureUrl.CreatePublishReachCalendarUrl(owaVdirUrl.ToString(), mailboxSession.MailboxGuid, primarySmtpAddress.Domain, text, externalUser.Sid); if (string.IsNullOrEmpty(text)) { aduser.SharingAnonymousIdentities.AddOrUpdate(SharingDataType.ReachCalendar.PublishResourceName, obscureUrl.Identity, folderId); adrecipientSession.Save(aduser); } context.BrowseUrl = obscureUrl.ToString() + ".html"; context.ICalUrl = obscureUrl.ToString() + ".ics"; return(new PerformInvitationResults(recipients)); }
// Token: 0x06001517 RID: 5399 RVA: 0x00078898 File Offset: 0x00076A98 protected override void InvokeInternal(InvokeArgs invokeArgs, List <KeyValuePair <string, object> > customDataToLog) { MailboxSession mailboxSession = invokeArgs.StoreSession as MailboxSession; mailboxSession.Mailbox.Load(GroupMailboxAssistantType.ExtendedProperties); if (mailboxSession.MailboxOwner.RecipientTypeDetails != RecipientTypeDetails.GroupMailbox) { GroupMailboxAssistant.Tracer.TraceError((long)this.GetHashCode(), "ActivityId : {0} ; Mailbox : TypeDetail {1} , SmtpAddress {2}, ExchangeGuid {3} cannot be processed by GroupMailboxAssistant, Parameters {4}", new object[] { invokeArgs.ActivityId, mailboxSession.MailboxOwner.RecipientTypeDetails, mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(), mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, invokeArgs.Parameters }); customDataToLog.Add(new KeyValuePair <string, object>("GroupMailboxAssistantInfo", "Mailbox cannot be processed by GroupMailboxAssistant")); return; } this.UpdateGroupMailboxMembership(mailboxSession); IRecipientSession adrecipientSession = mailboxSession.GetADRecipientSession(false, ConsistencyMode.FullyConsistent); ADUser adUser = adrecipientSession.FindADUserByObjectId(mailboxSession.MailboxOwner.ObjectId); this.UploadDefaultPhoto(adrecipientSession, adUser, invokeArgs, customDataToLog); this.PublishExchangeResourcesToAAD(adrecipientSession, adUser, invokeArgs, customDataToLog); }
// Token: 0x060014F1 RID: 5361 RVA: 0x00078148 File Offset: 0x00076348 private void SendSignalsForMailbox(MailboxSession session, ILogger logger) { SharePointFlighted sharePointFlighted = new SharePointFlighted(logger); ISharePointUrl sharePointUrl = this.SharePointUrlFactory.CreateADWithDictFallbackSharePointUrl(new ADSharePointUrl(), new DictSharePointUrl(), logger); ADUser aduser = (ADUser)DirectoryHelper.ReadADRecipient(session.MailboxOwner.MailboxInfo.MailboxGuid, session.MailboxOwner.MailboxInfo.IsArchive, session.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)); ICredentials credentials = this.GetCredentials(aduser); if (sharePointFlighted.IsUserFlighted(aduser)) { string url = sharePointUrl.GetUrl(session.MailboxOwner, session.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)); if (string.IsNullOrEmpty(url)) { return; } using (Folder folder = Folder.Bind(session, DefaultFolderType.Inbox, new PropertyDefinition[] { FolderSchema.OfficeGraphLocation })) { string value = folder.TryGetProperty(FolderSchema.OfficeGraphLocation) as string; if (string.IsNullOrEmpty(value)) { folder[FolderSchema.OfficeGraphLocation] = url; folder.Save(); } } SharePointSignalRestSender sharePointSignalRestSender = new SharePointSignalRestSender(credentials, url, logger); SharePointSignalRestDataProvider sharePointSignalRestDataProvider = new SharePointSignalRestDataProvider(); sharePointSignalRestDataProvider.AddAnalyticsSignalSource(new RecipientCacheSignalSource(session)); sharePointSignalRestDataProvider.ProvideDataFor(sharePointSignalRestSender); if (sharePointSignalRestDataProvider.AnyDataProvided()) { sharePointSignalRestDataProvider.PrintProviderReport(logger); try { sharePointSignalRestSender.Send(); } catch (WebException ex) { if (SharePointSignalStoreAssistant.IsWebExceptionUnauthorized(ex)) { throw; } throw new SharePointSignalStoreException("Failed to send signals to SharePoint", ex); } logger.LogInfo("Successfully sent signals", new object[0]); return; } logger.LogInfo("No Recipient Cache retrieved for mailbox.", new object[0]); } }
private void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { if (StoreDriverConfig.Instance.IsAutoAcceptForGroupAndSelfForwardedEventEnabled) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; if ((ObjectClass.IsMeetingRequest(storeDriverDeliveryEventArgsImpl.MessageClass) || ObjectClass.IsMeetingResponse(storeDriverDeliveryEventArgsImpl.MessageClass)) && !this.IsEHAMigrationMeetingMessage(storeDriverDeliveryEventArgsImpl.MailItem)) { MailboxSession mailboxSession = storeDriverDeliveryEventArgsImpl.MailboxSession; if (mailboxSession == null || storeDriverDeliveryEventArgsImpl.ReplayItem == null) { MeetingMessageProcessingAgent.tracer.TraceError((long)this.GetHashCode(), "MeetingMessageProcessingAgent::OnPromotedMessageHandler() MailboxSession or StoreDriverDeliveryEventArgsImpl.ReplayItem is null"); return; } if (ObjectClass.IsMeetingRequest(storeDriverDeliveryEventArgsImpl.MessageClass) && !mailboxSession.IsGroupMailbox()) { MeetingRequest meetingRequest = null; try { meetingRequest = (Item.ConvertFrom(storeDriverDeliveryEventArgsImpl.ReplayItem, mailboxSession) as MeetingRequest); if (meetingRequest != null && MeetingMessageProcessing.IsSentToSelf(meetingRequest, mailboxSession)) { MeetingMessageProcessingAgent.tracer.TraceDebug <string, IExchangePrincipal>((long)this.GetHashCode(), "Attempting to deliver self forwarded message {0} to mailbox {1} to Deleted Items", meetingRequest.InternetMessageId, mailboxSession.MailboxOwner); this.DeliverToDeletedItems(mailboxSession, meetingRequest, storeDriverDeliveryEventArgsImpl); } } finally { if (meetingRequest != null) { Item.SafeDisposeConvertedItem(storeDriverDeliveryEventArgsImpl.ReplayItem, meetingRequest); } } } if (ObjectClass.IsMeetingResponse(storeDriverDeliveryEventArgsImpl.MessageClass) && mailboxSession.IsGroupMailbox()) { MeetingResponse meetingResponse = Item.ConvertFrom(storeDriverDeliveryEventArgsImpl.ReplayItem, mailboxSession) as MeetingResponse; if (meetingResponse != null && meetingResponse.IsSilent) { ADRecipient adrecipient = null; if (meetingResponse.From.TryGetADRecipient(mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), out adrecipient) && adrecipient != null && adrecipient.RecipientDisplayType != RecipientDisplayType.ConferenceRoomMailbox && adrecipient.RecipientDisplayType != RecipientDisplayType.SyncedConferenceRoomMailbox && adrecipient.RecipientDisplayType != RecipientDisplayType.EquipmentMailbox && adrecipient.RecipientDisplayType != RecipientDisplayType.SyncedEquipmentMailbox && !meetingResponse.IsCounterProposal) { MeetingMessageProcessingAgent.tracer.TraceDebug <string, IExchangePrincipal>((long)this.GetHashCode(), "Attempting to deliver empty response {0} to mailbox {1} to Deleted Items", meetingResponse.InternetMessageId, mailboxSession.MailboxOwner); this.DeliverToDeletedItems(mailboxSession, meetingResponse, storeDriverDeliveryEventArgsImpl); } } } } } }
public override void Apply(MrsPSHandler psHandler, MailboxSession mailboxSession) { JunkEmailRule junkEmailRule = mailboxSession.JunkEmailRule; if (this.TrustedSenderDomain != null) { this.AddEntriesToCollection(junkEmailRule.TrustedSenderDomainCollection, "TrustedSenderDomainCollection", mailboxSession.MailboxGuid, this.TrustedSenderDomain); } if (this.TrustedSenderEmail != null) { this.AddEntriesToCollection(junkEmailRule.TrustedSenderEmailCollection, "TrustedSenderEmailCollection", mailboxSession.MailboxGuid, this.TrustedSenderEmail); } if (this.BlockedSenderDomain != null) { this.AddEntriesToCollection(junkEmailRule.BlockedSenderDomainCollection, "BlockedSenderDomainCollection", mailboxSession.MailboxGuid, this.BlockedSenderDomain); } if (this.BlockedSenderEmail != null) { this.AddEntriesToCollection(junkEmailRule.BlockedSenderEmailCollection, "BlockedSenderEmailCollection", mailboxSession.MailboxGuid, this.BlockedSenderEmail); } if (this.TrustedRecipientDomain != null) { this.AddEntriesToCollection(junkEmailRule.TrustedRecipientDomainCollection, "TrustedRecipientDomainCollection", mailboxSession.MailboxGuid, this.TrustedRecipientDomain); } if (this.TrustedRecipientEmail != null) { this.AddEntriesToCollection(junkEmailRule.TrustedRecipientEmailCollection, "TrustedRecipientEmailCollection", mailboxSession.MailboxGuid, this.TrustedRecipientEmail); } if (this.TrustedContactsEmail != null) { IRecipientSession adrecipientSession = mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid); if (adrecipientSession == null) { string itemList = this.TrustedContactsEmail.Aggregate((string result, string email) => result + ", " + email); throw new MailboxSettingsJunkMailErrorPermanentException("TrustedContactsEmail", itemList, "error getting RecipientSession"); } junkEmailRule.SynchronizeContactsCache(); foreach (string email2 in this.TrustedContactsEmail) { junkEmailRule.AddTrustedContact(email2, adrecipientSession); } } if (this.SendAsEmail != null) { this.AddEntriesToCollection(junkEmailRule.TrustedSenderEmailCollection, "TrustedSenderEmailCollection", mailboxSession.MailboxGuid, this.SendAsEmail); } junkEmailRule.Save(); }
private MailboxFolderUserId CreateMailboxFolderUserId(MailboxSession mailboxSession) { bool flag = !string.IsNullOrEmpty(this.rawIdentity) && SmtpAddress.IsValidSmtpAddress(this.rawIdentity); if (flag) { MailboxFolderUserId mailboxFolderUserId = MailboxFolderUserId.TryCreateFromSmtpAddress(this.rawIdentity, mailboxSession); if (mailboxFolderUserId != null) { return(mailboxFolderUserId); } } IRecipientSession adrecipientSession = mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid); IEnumerable <ADRecipient> objects = this.RecipientIdParameter.GetObjects <ADRecipient>(null, adrecipientSession); using (IEnumerator <ADRecipient> enumerator = objects.GetEnumerator()) { if (enumerator.MoveNext()) { ADRecipient recipient = enumerator.Current; if (enumerator.MoveNext()) { throw new ManagementObjectAmbiguousException(Strings.ErrorManagementObjectAmbiguous(this.RecipientIdParameter.ToString())); } bool allowInvalidSecurityPrincipal = !flag; MailboxFolderUserId mailboxFolderUserId = MailboxFolderUserId.TryCreateFromADRecipient(recipient, allowInvalidSecurityPrincipal); if (mailboxFolderUserId != null) { return(mailboxFolderUserId); } if (!flag) { throw new InvalidInternalUserIdException(this.RecipientIdParameter.ToString()); } } } if (flag) { throw new InvalidExternalUserIdException(this.rawIdentity); } return(MailboxFolderUserId.CreateFromUnknownUser(this.rawIdentity)); }
// Token: 0x06000848 RID: 2120 RVA: 0x0003A2AC File Offset: 0x000384AC private bool SyncFolder(MailboxSession mailboxSession, FolderRow folderRow, PublishingSubscriptionData subscriptionData, Deadline deadline, CalendarSyncPerformanceCountersInstance counters, CalendarSyncFolderOperationLogEntry folderOpLogEntry) { List <LocalizedString> list = new List <LocalizedString>(); bool result = true; bool flag = false; ExDateTime utcNow = ExDateTime.UtcNow; using (CalendarFolder calendarFolder = CalendarFolder.Bind(mailboxSession, folderRow.FolderId)) { ImportCalendarResults importCalendarResults = null; try { TimeSpan timeLeft = deadline.TimeLeft; if (timeLeft > TimeSpan.Zero) { calendarFolder.LastAttemptedSyncTime = utcNow; TimeSpan timeout = (timeLeft > SynchronizableFolderType.MaxSyncTimePerFolder) ? SynchronizableFolderType.MaxSyncTimePerFolder : timeLeft; HttpWebRequest httpWebRequest = this.CreateWebRequest(subscriptionData, timeout, mailboxSession, folderOpLogEntry); if (httpWebRequest == null) { SynchronizableFolderType.Tracer.TraceWarning <Uri>((long)this.GetHashCode(), "Unable to get web request for subscription. {0}", subscriptionData.PublishingUrl); return(true); } using (ImportCalendarStream importCalendarStream = new ImportCalendarStream()) { int num = -1; using (WebResponse response = httpWebRequest.GetResponse()) { using (Stream responseStream = response.GetResponseStream()) { num = importCalendarStream.CopyFrom(responseStream); SynchronizableFolderType.Tracer.TraceDebug <object, int, PublishingSubscriptionData>((long)this.GetHashCode(), "{0}: Read data ({1} bytes ) into memory stream from subscription source {2}.", TraceContext.Get(), num, subscriptionData); responseStream.Close(); } response.Close(); } if (num < 0) { folderOpLogEntry.AddErrorToLog("SubscriptionOverSizeLimit", null); } else { ExDateRange importWindow = InternetCalendarType.GetImportWindow(subscriptionData.PublishingUrl); importCalendarResults = ICalSharingHelper.ImportCalendar(importCalendarStream, "utf-8", new InboundConversionOptions(mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), mailboxSession.ServerFullyQualifiedDomainName), mailboxSession, calendarFolder, deadline, importWindow.Start, importWindow.End); if (importCalendarResults.Result != ImportCalendarResultType.Success) { list.AddRange(importCalendarResults.Errors); foreach (LocalizedString value in importCalendarResults.Errors) { folderOpLogEntry.AddErrorToLog("ImportCalendarException", value); } } flag = (importCalendarResults.Result != ImportCalendarResultType.Failed); } } SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: iCal to folder {1} with id {2} for mailbox {3} with subscription {4}. Results: {5}", new object[] { TraceContext.Get(), folderRow.DisplayName, folderRow.FolderId, mailboxSession.DisplayName, subscriptionData, (importCalendarResults != null) ? importCalendarResults.ToString() : "iCal over the size limit" }); if (importCalendarResults == null) { folderOpLogEntry.AddErrorToLog("iCalOverSizeLimit", null); } } result = (importCalendarResults != null && !importCalendarResults.TimedOut); } catch (WebException ex) { list.Add(new LocalizedString(ex.ToString())); result = (ex.Status != WebExceptionStatus.Timeout); folderOpLogEntry.AddExceptionToLog(ex); } catch (SystemException ex2) { list.Add(new LocalizedString(ex2.ToString())); folderOpLogEntry.AddExceptionToLog(ex2); } catch (Exception ex3) { SynchronizableFolderType.Tracer.TraceError((long)this.GetHashCode(), "{0}: InternetCalendarType.SyncFolder for folder {1} with id {2} for mailbox {3} had the following exception: {4}. Subscription data: {5}", new object[] { TraceContext.Get(), folderRow.DisplayName, folderRow.FolderId, mailboxSession.DisplayName, ex3, subscriptionData }); this.SaveLocalFolder(mailboxSession, calendarFolder, subscriptionData, folderRow); list.Add(new LocalizedString(ex3.ToString())); folderOpLogEntry.AddExceptionToLog(ex3); throw; } if (flag) { calendarFolder.LastSuccessfulSyncTime = utcNow; } this.SaveLocalFolder(mailboxSession, calendarFolder, subscriptionData, folderRow); } if (list != null) { foreach (LocalizedString localizedString in list) { SynchronizableFolderType.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: InternetCalendarType.SyncFolder for folder {1} with id {2} for mailbox {3} had the following error: {4}. Subscription data: {5}", new object[] { TraceContext.Get(), folderRow.DisplayName, folderRow.FolderId, mailboxSession.DisplayName, localizedString, subscriptionData }); } } return(result); }
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 static ADUser GetADUser(MailboxSession mailboxSession) { ADUser aduser = DirectoryHelper.ReadADRecipient(mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, mailboxSession.MailboxOwner.MailboxInfo.IsArchive, mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)) as ADUser; if (aduser == null) { SharingEngine.Tracer.TraceDebug <IExchangePrincipal>(0L, "{0}: cannot locate user object in AD", mailboxSession.MailboxOwner); throw new ADUserNotFoundException(); } return(aduser); }
private static bool ShouldSetupNotificationManagerForUser(MailboxSession userMailboxSession) { SyncUtilities.ThrowIfArgumentNull("userMailboxSession", userMailboxSession); try { IExchangePrincipal mailboxOwner = userMailboxSession.MailboxOwner; ADUser aduser = DirectoryHelper.ReadADRecipient(mailboxOwner.MailboxInfo.MailboxGuid, mailboxOwner.MailboxInfo.IsArchive, userMailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)) as ADUser; if (aduser != null) { AggregatedAccountHelper aggregatedAccountHelper = new AggregatedAccountHelper(userMailboxSession, aduser); List <AggregatedAccountInfo> listOfAccounts = aggregatedAccountHelper.GetListOfAccounts(); if (listOfAccounts != null) { return(listOfAccounts.Count > 0); } } } catch (LocalizedException arg) { ExTraceGlobals.ConnectedAccountsTracer.TraceError <Guid, SmtpAddress, LocalizedException>((long)userMailboxSession.GetHashCode(), "MrsConnectedAccountsNotificationManager.ShouldSetupNotificationManagerForUser failed for User (MailboxGuid:{0}, PrimarySmtpAddress:{1}), with error:{2}. We will assume that user has active connected accounts.", userMailboxSession.MailboxGuid, userMailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress, arg); } return(false); }
protected override SubscribeResults InternalPerformSubscribe(MailboxSession mailboxSession, SharingContext context) { ADRecipient mailboxOwner = DirectoryHelper.ReadADRecipient(mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, mailboxSession.MailboxOwner.MailboxInfo.IsArchive, mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)); SharedFolderData matchingSharedFolderData = this.GetMatchingSharedFolderData(context, mailboxOwner); if (context.InitiatorSmtpAddress == null) { throw new InvalidSharingDataException("InitiatorSmtpAddress", string.Empty); } IdAndName idAndName = null; StoreObjectId storeObjectId = null; using (SharingSubscriptionManager sharingSubscriptionManager = new SharingSubscriptionManager(mailboxSession)) { SharingSubscriptionData sharingSubscriptionData = this.CreateSubscriptionData(mailboxOwner, context, matchingSharedFolderData); SharingFolderManager sharingFolderManager = new SharingFolderManager(mailboxSession); SharingSubscriptionData existing = sharingSubscriptionManager.GetExisting(sharingSubscriptionData.Key); if (existing != null) { existing.CopyFrom(sharingSubscriptionData); } SharingSubscriptionData sharingSubscriptionData2 = existing ?? sharingSubscriptionData; idAndName = sharingFolderManager.EnsureFolder(sharingSubscriptionData2); if (sharingSubscriptionData2.LocalFolderId == null || !sharingSubscriptionData2.LocalFolderId.Equals(idAndName.Id)) { storeObjectId = (sharingSubscriptionData2.LocalFolderId = idAndName.Id); } SharingSubscriptionData sharingSubscriptionData3 = sharingSubscriptionManager.CreateOrUpdate(sharingSubscriptionData2, false); if (!sharingSubscriptionData2.LocalFolderId.Equals(sharingSubscriptionData3.LocalFolderId)) { idAndName = sharingFolderManager.GetFolder(sharingSubscriptionData3); } } return(new SubscribeResultsExternal(context.DataType, context.InitiatorSmtpAddress, context.InitiatorName, context.FolderName, matchingSharedFolderData.FolderId, idAndName.Id, storeObjectId != null, idAndName.Name)); }
public override void Apply(MailboxSession session, Item item) { if (string.IsNullOrEmpty(this.ICalContents)) { return; } InboundConversionOptions scopedInboundConversionOptions = MapiUtils.GetScopedInboundConversionOptions(session.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)); ItemConversion.ConvertICalToItem(item, scopedInboundConversionOptions, this.ICalContents); }
protected override PerformInvitationResults InternalPerformInvitation(MailboxSession mailboxSession, SharingContext context, ValidRecipient[] recipients, IFrontEndLocator frontEndLocator) { ExternalAuthentication current = ExternalAuthentication.GetCurrent(); if (!current.Enabled) { ExTraceGlobals.SharingTracer.TraceError <string>((long)this.GetHashCode(), "{0}: The organization is not federated for external sharing.", context.InitiatorSmtpAddress); return(new PerformInvitationResults(new InvalidSharingRecipientsException(ValidRecipient.ConvertToStringArray(recipients), new OrganizationNotFederatedException()))); } SharedFolderDataEncryption sharedFolderDataEncryption = new SharedFolderDataEncryption(current); string text = StoreId.StoreIdToEwsId(mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, context.FolderId); PerformInvitationResults result; using (ExternalUserCollection externalUsers = mailboxSession.GetExternalUsers()) { PerformInvitationResults performInvitationResults = null; EncryptionResults encryptionResults = null; Exception ex = null; try { encryptionResults = sharedFolderDataEncryption.Encrypt(mailboxSession.MailboxOwner, mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), externalUsers, recipients, context.InitiatorSmtpAddress, context.FolderClass, text, frontEndLocator); } catch (UserWithoutFederatedProxyAddressException ex2) { ex = ex2; } catch (InvalidFederatedOrganizationIdException ex3) { ex = ex3; } catch (StoragePermanentException ex4) { ex = ex4; } if (ex != null) { ExTraceGlobals.SharingTracer.TraceError <string, Exception>((long)this.GetHashCode(), "{0}: Error occurred when trying to encrypt. Exception = {1}", context.InitiatorSmtpAddress, ex); result = new PerformInvitationResults(new InvalidSharingRecipientsException(ValidRecipient.ConvertToStringArray(recipients), ex)); } else { if (encryptionResults.InvalidRecipients != null && encryptionResults.InvalidRecipients.Length > 0) { InvalidSharingRecipientsException exception = new InvalidSharingRecipientsException(encryptionResults.InvalidRecipients); if (encryptionResults.InvalidRecipients.Length == recipients.Length) { return(new PerformInvitationResults(exception)); } performInvitationResults = new PerformInvitationResults(recipients, exception); recipients = performInvitationResults.SucceededRecipients; } else { performInvitationResults = new PerformInvitationResults(recipients); } PermissionLevel permissionLevel = this.GetPermissionLevel(context); FreeBusyAccess? freeBusy = this.GetFreeBusy(context); using (FolderPermissionContext current2 = FolderPermissionContext.GetCurrent(mailboxSession, context)) { foreach (ValidRecipient validRecipient in recipients) { PermissionSecurityPrincipal principal = this.CreatePermissionSecurityPrincipal(validRecipient.SmtpAddress, externalUsers); current2.AddOrChangePermission(principal, permissionLevel, freeBusy); ExternalUser externalUser = externalUsers.FindReachUserWithOriginalSmtpAddress(new SmtpAddress(validRecipient.SmtpAddress)); if (externalUser != null) { current2.RemovePermission(new PermissionSecurityPrincipal(externalUser)); } } } context.FolderEwsId = text; context.EncryptedSharedFolderDataCollection = encryptionResults.EncryptedSharedFolderDataCollection; result = performInvitationResults; } } return(result); }
private void SaveSharingPartnership(MailboxSession mailboxSession) { if (mailboxSession == null) { return; } IRecipientSession recipientSession = null; ADUser aduser = null; foreach (Permission permission in this.permissions.Values) { if (permission.Principal.Type == PermissionSecurityPrincipal.SecurityPrincipalType.ExternalUserPrincipal && !permission.Principal.ExternalUser.IsReachUser) { if (aduser == null) { recipientSession = mailboxSession.GetADRecipientSession(false, ConsistencyMode.FullyConsistent); ADRecipient adrecipient = recipientSession.Read(mailboxSession.MailboxOwner.ObjectId); if (adrecipient == null) { throw new ObjectNotFoundException(ServerStrings.ADUserNotFound); } aduser = (adrecipient as ADUser); if (aduser == null) { ExTraceGlobals.StorageTracer.TraceDebug <ADRecipient>((long)this.GetHashCode(), "PermissionTable::SaveSharingParterner. This is not an ADUser so SharingPartnerIdentities doesn't apply. Recipient = {0}.", adrecipient); return; } } string externalId = permission.Principal.ExternalUser.ExternalId; if (!aduser.SharingPartnerIdentities.Contains(externalId)) { try { aduser.SharingPartnerIdentities.Add(externalId); } catch (InvalidOperationException ex) { ExTraceGlobals.StorageTracer.TraceError <ADUser, InvalidOperationException>((long)this.GetHashCode(), "PermissionTable::SaveSharingParterner. Failed to add SharingPartnerIdentities on user {0} due to exception {1}.", aduser, ex); throw new InvalidObjectOperationException(new LocalizedString(ex.Message), ex); } } } } if (aduser != null && aduser.SharingPartnerIdentities.Changed) { try { recipientSession.Save(aduser); } catch (DataValidationException innerException) { throw new CorruptDataException(ServerStrings.ExCannotSaveInvalidObject(aduser), innerException); } catch (DataSourceOperationException ex2) { throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex2, null, "PermissionTable::SaveSharingParterner(): Failed due to directory exception {0}.", new object[] { ex2 }); } catch (DataSourceTransientException ex3) { throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex3, null, "PermissionTable::SaveSharingParterner(): Failed due to directory exception {0}.", new object[] { ex3 }); } } }
private static TeamMailbox GetTeamMailbox(MailboxSession session, out IRecipientSession recipientSession) { TeamMailbox result; try { ADUser aduser = DirectoryHelper.ReadADRecipient(session.MailboxOwner.MailboxInfo.MailboxGuid, session.MailboxOwner.MailboxInfo.IsArchive, session.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)) as ADUser; if (aduser == null) { throw new StorageTransientException(new LocalizedString("Failed to find the Site Mailbox")); } recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, null, CultureInfo.InvariantCulture.LCID, true, ConsistencyMode.IgnoreInvalid, null, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(session.MailboxOwner.MailboxInfo.OrganizationId), 382, "GetTeamMailbox", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\LinkedFolder\\TeamMailboxNotificationHelper.cs"); result = TeamMailbox.FromDataObject(aduser); } catch (ADTransientException innerException) { throw new StorageTransientException(new LocalizedString("Failed to get the Site Mailbox because of AD error"), innerException); } catch (ADExternalException innerException2) { throw new StorageTransientException(new LocalizedString("Failed to get the Site Mailbox because of AD error"), innerException2); } catch (ADOperationException innerException3) { throw new StorageTransientException(new LocalizedString("Failed to get the Site Mailbox because of AD error"), innerException3); } catch (DataValidationException innerException4) { throw new StorageTransientException(new LocalizedString("Failed to get the Site Mailbox because of AD error"), innerException4); } return result; }
// Token: 0x06000E48 RID: 3656 RVA: 0x00055A2C File Offset: 0x00053C2C protected override void InvokeInternal(InvokeArgs invokeArgs, List <KeyValuePair <string, object> > customDataToLog) { MailboxSession mailboxSession = invokeArgs.StoreSession as MailboxSession; if (mailboxSession == null) { return; } ADUser aduser = SharingPolicyAssistant.GetADUser(mailboxSession.MailboxOwner, mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)); if (aduser == null) { return; } if (ADRecipient.IsSystemMailbox(aduser.RecipientTypeDetails)) { SharingPolicyAssistant.Tracer.TraceDebug <IExchangePrincipal, RecipientTypeDetails>((long)this.GetHashCode(), "{0}: Skipping the mailbox processing as it is a system mailbox. RecipientTypeDetails {1}.", mailboxSession.MailboxOwner, aduser.RecipientTypeDetails); return; } SharingPolicyAssistant.Tracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: Begin process mailbox", mailboxSession.MailboxOwner); SharingPolicyCache sharingPolicyCache = SharingPolicyCache.Get(aduser); bool flag = false; if (sharingPolicyCache != null) { if (!this.IsMailboxNeedingPolicyUpdate(mailboxSession, sharingPolicyCache)) { return; } flag = this.ApplyPolicy(mailboxSession, sharingPolicyCache.Policy); } if (flag) { SharingPolicyAssistant.Tracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: Storing applied policy to mailbox table.", mailboxSession.MailboxOwner); SharingPolicyAssistant.UpdateMailboxData(mailboxSession.Mailbox, (aduser.SharingPolicy == null && !sharingPolicyCache.BelongsToDehydratedContainer) ? SharingPolicyCache.DynamicDefaultPolicy.ObjectGuid.ToByteArray() : sharingPolicyCache.Policy.Id.ObjectGuid.ToByteArray(), sharingPolicyCache.Hash); } else { SharingPolicyAssistant.Tracer.TraceWarning <IExchangePrincipal>(0L, "{0}: Unable to find sharing policy for this mailbox.", mailboxSession.MailboxOwner); ExDateTime?exDateTime = mailboxSession.Mailbox.TryGetProperty(MailboxSchema.LastSharingPolicyAppliedTime) as ExDateTime?; byte[] array = mailboxSession.Mailbox.TryGetProperty(MailboxSchema.LastSharingPolicyAppliedHash) as byte[]; if (exDateTime == null || array != null) { SharingPolicyAssistant.UpdateMailboxData(mailboxSession.Mailbox, null, null); } else { TimeSpan retryTimeSpan = ExDateTime.UtcNow.Subtract(exDateTime.Value); if (ExDateTime.UtcNow.Subtract(exDateTime.Value) > SharingPolicyAssistant.RetryThresholdLimit) { SharingPolicyAssistant.SubmitInformationalWatson(mailboxSession.MailboxOwner, retryTimeSpan); SharingPolicyAssistant.UpdateMailboxData(mailboxSession.Mailbox, null, null); } } } SharingPolicyAssistant.Tracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: End process mailbox", mailboxSession.MailboxOwner); }
// Token: 0x06001678 RID: 5752 RVA: 0x0007EC98 File Offset: 0x0007CE98 protected override void HandleEventInternal(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item, List <KeyValuePair <string, object> > customDataToLog) { if (this.InternalIsEventInteresting(mapiEvent) && itemStore != null && item != null) { MessageItem messageItem = item as MessageItem; if (messageItem == null) { RecipientDLExpansionEventBasedAssistant.Tracer.TraceWarning((long)this.GetHashCode(), "The item being processed is not a message item."); return; } RecipientDLExpansionEventBasedAssistant.Tracer.TraceDebug <Guid, StoreObjectId, string>((long)this.GetHashCode(), "Processing mailbox guid: {0} and message id: {1} with subject: '{2}'", itemStore.MailboxGuid, messageItem.StoreObjectId, messageItem.Subject); StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_RecipientDLExpansionIsProcessing, null, new object[] { messageItem.StoreObjectId, messageItem.Subject, itemStore.MailboxGuid }); bool flag = false; bool flag2 = true; try { ADUser adUser = DirectoryHelper.ReadADRecipient(itemStore.MailboxOwner.MailboxInfo.MailboxGuid, itemStore.MailboxOwner.MailboxInfo.IsArchive, itemStore.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)) as ADUser; bool flag3 = this.IsFlightingFeatureEnabled(adUser) || RecipientDLExpansionEventBasedAssistantHelper.IsRecipientDLExpansionTestHookEnabled(); RecipientDLExpansionEventBasedAssistantHelper.GetComplianceMaxExpansionDGRecipientsAndNestedDGs(itemStore.OrganizationId, out this.maxDGExpansionRecipients, out this.maxExpansionNestedDGs); if (flag3 && this.maxDGExpansionRecipients != 0U) { flag2 = false; this.PerformDLExpansionOnItemRecipients(itemStore, messageItem, ref flag2); } else { RecipientDLExpansionEventBasedAssistant.Tracer.TraceDebug <StoreObjectId, Guid, OrganizationId>((long)this.GetHashCode(), "Per tenant configuration or flighting framework, DL expansion is disabled, skip processing message id: {0}, mailbox guid: {1}, tenant: {2}", messageItem.StoreObjectId, itemStore.MailboxGuid, itemStore.OrganizationId); StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_RecipientDLExpansionSkipped, null, new object[] { messageItem.StoreObjectId, itemStore.MailboxGuid, itemStore.OrganizationId }); } } catch (Exception ex) { RecipientDLExpansionEventBasedAssistant.Tracer.TraceError((long)this.GetHashCode(), "Exception when updating the item with id: {0}, mailbox guid: {1}, tenant: {2}.\n\nThe exception is : {3}", new object[] { messageItem.StoreObjectId, itemStore.MailboxGuid, itemStore.OrganizationId, ex }); StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_RecipientDLExpansionFailed, null, new object[] { messageItem.StoreObjectId, itemStore.MailboxGuid, itemStore.OrganizationId, ex }); this.PublishMonitoringResults(itemStore, ex); flag = true; if (!(ex is StorageTransientException) && !(ex is StoragePermanentException)) { throw; } } if (!flag && !flag2) { this.PublishMonitoringResults(itemStore, null); } } }
// Token: 0x0600163F RID: 5695 RVA: 0x0007DAA0 File Offset: 0x0007BCA0 protected override void HandleEventInternal(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item, List <KeyValuePair <string, object> > customDataToLog) { ArgumentValidator.ThrowIfNull("mapiEvent", mapiEvent); ArgumentValidator.ThrowIfNull("itemStore", itemStore); ArgumentValidator.ThrowIfNull("customDataToLog", customDataToLog); ExTraceGlobals.GeneralTracer.TraceDebug <MapiEvent>((long)this.GetHashCode(), "RemindersAssistant.HandleEventInternal event: {0}", mapiEvent); string value = string.Empty; try { VariantConfigurationSnapshot variantConfigurationSnapshot = this.GetVariantConfigurationSnapshot(itemStore.MailboxOwner, itemStore.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)); if (variantConfigurationSnapshot != null) { bool flag = Globals.IsItemInDumpster(itemStore, item); if (flag) { ExTraceGlobals.GeneralTracer.TraceDebug((long)this.GetHashCode(), "RemindersAssistant.HandleEventInternal running on a dumpster item"); } bool flag2 = false; foreach (IEventProcessor eventProcessor in this.EventProcessors) { if (eventProcessor.IsEnabled(variantConfigurationSnapshot) && eventProcessor.IsEventInteresting(mapiEvent)) { ExTraceGlobals.GeneralTracer.TraceDebug <string>((long)this.GetHashCode(), "Calling HandleEventInternal for event processor {0}", eventProcessor.Name); eventProcessor.HandleEvent(mapiEvent, itemStore, item, flag, customDataToLog); flag2 = true; } } if (!flag2) { value = "FlightNotEnabled"; } } else { value = "UserNotFound"; } } catch (CorruptDataException e) { this.Log.LogEntry(itemStore, e, false, "CorruptDataException occurred in HandleEvent", new object[0]); return; } catch (Exception e2) { this.Log.LogEntry(itemStore, e2, false, "Exception occurred in HandleEvent", new object[0]); throw; } customDataToLog.Add(new KeyValuePair <string, object>("SkipEventReason", value)); }
private void EnforceSharingPolicy(MailboxSession mailboxSession, ICollection <MapiAclTableRestriction.ExternalUserPermission> externalUserPermissions) { Util.ThrowOnNullArgument(mailboxSession, "mailboxSession"); if (externalUserPermissions == null || externalUserPermissions.Count == 0) { return; } List <RightsNotAllowedRecipient> list = new List <RightsNotAllowedRecipient>(externalUserPermissions.Count); SharingPolicy sharingPolicy = null; foreach (MapiAclTableRestriction.ExternalUserPermission externalUserPermission in externalUserPermissions) { if (sharingPolicy == null) { IMailboxInfo mailboxInfo = mailboxSession.MailboxOwner.MailboxInfo; sharingPolicy = DirectoryHelper.ReadSharingPolicy(mailboxInfo.MailboxGuid, mailboxInfo.IsArchive, mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)); if (sharingPolicy == null) { ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: No policy assigned means no external sharing is allowed for this user.", mailboxSession.MailboxOwner); throw new NotAllowedExternalSharingByPolicyException(); } } if (!sharingPolicy.Enabled) { ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: A disabled policy means no external sharing is allowed for this user.", mailboxSession.MailboxOwner); throw new NotAllowedExternalSharingByPolicyException(); } SharingPolicyAction sharingPolicyAction = externalUserPermission.Principal.ExternalUser.IsReachUser ? sharingPolicy.GetAllowedForAnonymousCalendarSharing() : sharingPolicy.GetAllowed(externalUserPermission.Principal.ExternalUser.SmtpAddress.Domain); if (sharingPolicyAction == (SharingPolicyAction)0) { ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal, PermissionSecurityPrincipal>((long)this.GetHashCode(), "{0}: Policy does not allow granting permissions to {1}.", mailboxSession.MailboxOwner, externalUserPermission.Principal); throw new PrincipalNotAllowedByPolicyException(externalUserPermission.Principal); } MemberRights allowed = PolicyAllowedMemberRights.GetAllowed(sharingPolicyAction, this.FolderInfo.StoreObjectType); MemberRights memberRights = ~allowed & externalUserPermission.MemberRights; if (memberRights != MemberRights.None) { ExTraceGlobals.StorageTracer.TraceDebug((long)this.GetHashCode(), "{0}: Policy does not allow granting permission {1} to {2} on {3} folder '{4}'.", new object[] { mailboxSession.MailboxOwner, memberRights, externalUserPermission.Principal, this.FolderInfo.StoreObjectType, this.FolderInfo.DisplayName }); list.Add(new RightsNotAllowedRecipient(externalUserPermission.Principal, memberRights)); } } if (list.Count > 0) { throw new RightsNotAllowedByPolicyException(list.ToArray(), this.FolderInfo.StoreObjectType, this.FolderInfo.DisplayName); } }