internal SharingContext(Folder folderToShare, SharingProvider sharingProvider) : this() { Util.ThrowOnNullArgument(folderToShare, "folderToShare"); MailboxSession mailboxSession = folderToShare.Session as MailboxSession; IExchangePrincipal mailboxOwner = mailboxSession.MailboxOwner; if (sharingProvider == null) { SharingProvider[] compatibleProviders = SharingProvider.GetCompatibleProviders(folderToShare); if (compatibleProviders.Length == 0) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId>((long)this.GetHashCode(), "{0}: Cannot share folder {1}: no compatible provider was found.", mailboxOwner, folderToShare.Id); throw new CannotShareFolderException(ServerStrings.NoProviderSupportShareFolder); } for (int i = 0; i < compatibleProviders.Length; i++) { ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal, SharingProvider, VersionedId>((long)this.GetHashCode(), "{0}: Find compatible provider {1} for folder {2}.", mailboxOwner, compatibleProviders[i], folderToShare.Id); this.AvailableSharingProviders.Add(compatibleProviders[i], null); } } else if (!sharingProvider.IsCompatible(folderToShare)) { ExTraceGlobals.SharingTracer.TraceError <IExchangePrincipal, VersionedId, SharingProvider>((long)this.GetHashCode(), "{0}: Cannot share folder {1} with sharing provider: {2}.", mailboxOwner, folderToShare.Id, sharingProvider); if (sharingProvider == SharingProvider.SharingProviderPublish) { throw new FolderNotPublishedException(); } throw new CannotShareFolderException(ServerStrings.NoProviderSupportShareFolder); } else { this.AvailableSharingProviders.Add(sharingProvider, null); if (sharingProvider == SharingProvider.SharingProviderPublish) { this.PopulateUrls(folderToShare); } } this.InitiatorName = mailboxOwner.MailboxInfo.DisplayName; this.InitiatorSmtpAddress = mailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(); this.InitiatorEntryId = AddressBookEntryId.MakeAddressBookEntryID(mailboxOwner); this.FolderClass = folderToShare.ClassName; this.FolderId = folderToShare.StoreObjectId; this.IsPrimary = (mailboxSession.IsDefaultFolderType(this.FolderId) != DefaultFolderType.None); this.FolderName = (this.IsPrimary ? this.DataType.DisplayName.ToString(mailboxSession.InternalPreferedCulture) : folderToShare.DisplayName); this.MailboxId = StoreEntryId.ToProviderStoreEntryId(mailboxOwner); this.SharingMessageType = SharingMessageType.Invitation; this.SharingPermissions = SharingContextPermissions.Reviewer; if (StringComparer.OrdinalIgnoreCase.Equals(folderToShare.ClassName, "IPF.Appointment")) { this.SharingDetail = (this.IsPrimary ? SharingContextDetailLevel.AvailabilityOnly : SharingContextDetailLevel.FullDetails); } this.SetDefaultCapabilities(); this.UserLegacyDN = mailboxOwner.LegacyDn; }
internal static UpgradeStatus UpgradeElcFolder(bool userIsOnRetentionPolcyTags, MailboxSession mailboxSession, Folder folder, Dictionary <Guid, AdTagData> allAdTags) { UpgradeStatus result = UpgradeStatus.None; AdTagData adTagData = null; if (allAdTags != null) { object obj = folder.TryGetProperty(FolderSchema.ELCPolicyIds); if (obj is string) { string g = obj as string; Guid empty = Guid.Empty; if (GuidHelper.TryParseGuid(g, out empty)) { foreach (AdTagData adTagData2 in allAdTags.Values) { if (adTagData2.Tag != null && adTagData2.Tag.LegacyManagedFolder != null && adTagData2.Tag.LegacyManagedFolder.Value == empty) { ElcMailboxHelper.Tracer.TraceDebug <IExchangePrincipal, string, string>(0L, "Mailbox:{0}. Folder {1} was upgraded to tag {2} because they were linked match.", (mailboxSession != null) ? mailboxSession.MailboxOwner : null, (folder != null) ? folder.DisplayName : null, (adTagData != null && adTagData.Tag != null) ? adTagData.Tag.Name : null); adTagData = adTagData2; } } } } } mailboxSession.IsDefaultFolderType(folder.Id); ElcMailboxHelper.DeleteElcFolderProperties(folder); if (adTagData != null && adTagData.Tag.Type != ElcFolderType.All) { foreach (ContentSetting contentSetting in adTagData.ContentSettings.Values) { if (contentSetting.RetentionEnabled) { folder[StoreObjectSchema.RetentionPeriod] = (int)contentSetting.AgeLimitForRetention.Value.TotalDays; break; } } folder[StoreObjectSchema.PolicyTag] = adTagData.Tag.RetentionId.ToByteArray(); folder[StoreObjectSchema.RetentionFlags] = 1; result = UpgradeStatus.AppliedFolderTag; } return(result); }
private MailboxFolderConfiguration GetFolderInformation(int folderIndex, List <object[]> allFolderRows, MailboxSession mailboxSession, IConfigurationSession adConfigSession) { MailboxFolderConfiguration mailboxFolderConfiguration = null; object[] array = allFolderRows[folderIndex]; if (GetMailboxFolderStatistics.PropertyExists(array[1]) && GetMailboxFolderStatistics.PropertyExists(array[15])) { mailboxFolderConfiguration = new MailboxFolderConfiguration(); string folderPath = (string)array[15]; mailboxFolderConfiguration.FolderPath = folderPath; mailboxFolderConfiguration.SetIdentity(new MailboxFolderId(this.Identity.ToString(), mailboxFolderConfiguration.FolderPath)); mailboxFolderConfiguration.Date = (DateTime)((ExDateTime)array[10]); if (GetMailboxFolderStatistics.PropertyExists(array[0])) { mailboxFolderConfiguration.Name = (string)array[0]; } else { this.WriteWarning(Strings.UnableToRetrieveFolderName(mailboxFolderConfiguration.FolderPath)); } StoreObjectId objectId = ((VersionedId)array[1]).ObjectId; mailboxFolderConfiguration.FolderId = objectId.ToBase64String(); long num = 0L; if (GetMailboxFolderStatistics.PropertyExists(array[6])) { num = (long)array[6]; } mailboxFolderConfiguration.FolderSize = ByteQuantifiedSize.FromBytes(checked ((ulong)num)); if (GetMailboxFolderStatistics.PropertyExists(array[4])) { mailboxFolderConfiguration.ItemsInFolder = (int)array[4]; mailboxFolderConfiguration.ItemsInFolderAndSubfolders = mailboxFolderConfiguration.ItemsInFolder; } if (GetMailboxFolderStatistics.PropertyExists(array[5])) { mailboxFolderConfiguration.ItemsInFolder += (int)array[5]; mailboxFolderConfiguration.ItemsInFolderAndSubfolders += (int)array[5]; } if (GetMailboxFolderStatistics.PropertyExists(array[11])) { mailboxFolderConfiguration.DeletedItemsInFolder = (int)array[11]; mailboxFolderConfiguration.DeletedItemsInFolderAndSubfolders = mailboxFolderConfiguration.DeletedItemsInFolder; } if (GetMailboxFolderStatistics.PropertyExists(array[12])) { mailboxFolderConfiguration.DeletedItemsInFolder += (int)array[12]; mailboxFolderConfiguration.DeletedItemsInFolderAndSubfolders += mailboxFolderConfiguration.DeletedItemsInFolder; } int num2 = -1; if (GetMailboxFolderStatistics.PropertyExists(array[3])) { num2 = (int)array[3]; } if (GetMailboxFolderStatistics.PropertyExists(array[2]) && (bool)array[2]) { bool flag = false; bool flag2 = false; for (int i = folderIndex + 1; i < allFolderRows.Count; i++) { object[] array2 = allFolderRows[i]; if (GetMailboxFolderStatistics.PropertyExists(array2[15]) && GetMailboxFolderStatistics.PropertyExists(array2[3])) { int num3 = (int)array2[3]; if (num3 <= num2) { break; } if (GetMailboxFolderStatistics.PropertyExists(array2[6])) { long num4 = (long)array2[6]; if (num4 > 0L) { num += num4; } } else { flag2 = true; } if (GetMailboxFolderStatistics.PropertyExists(array2[4])) { mailboxFolderConfiguration.ItemsInFolderAndSubfolders += (int)array2[4]; } else { flag = true; } if (GetMailboxFolderStatistics.PropertyExists(array2[5])) { mailboxFolderConfiguration.ItemsInFolderAndSubfolders += (int)array2[5]; } else { flag = true; } if (GetMailboxFolderStatistics.PropertyExists(array2[11])) { mailboxFolderConfiguration.DeletedItemsInFolderAndSubfolders += (int)array2[11]; } if (GetMailboxFolderStatistics.PropertyExists(array2[12])) { mailboxFolderConfiguration.DeletedItemsInFolderAndSubfolders += (int)array2[12]; } } } if (flag) { this.WriteWarning(Strings.TotalFolderCount(mailboxFolderConfiguration.FolderPath)); } if (flag2) { this.WriteWarning(Strings.TotalFolderSize(mailboxFolderConfiguration.FolderPath)); } } mailboxFolderConfiguration.FolderAndSubfolderSize = ByteQuantifiedSize.FromBytes(checked ((ulong)num)); if (GetMailboxFolderStatistics.PropertyExists(array[7])) { bool flag3 = ((int)array[7] & 1) != 0; mailboxFolderConfiguration.FolderType = (flag3 ? ElcFolderType.ManagedCustomFolder.ToString() : null); } if (mailboxFolderConfiguration.FolderType == null) { VersionedId folderId = (VersionedId)array[1]; DefaultFolderType defaultFolderType = mailboxSession.IsDefaultFolderType(folderId); if (defaultFolderType == DefaultFolderType.None) { if (GetMailboxFolderStatistics.PropertyExists(array[9])) { StoreObjectId folderId2 = (StoreObjectId)array[9]; defaultFolderType = mailboxSession.IsDefaultFolderType(folderId2); } switch (defaultFolderType) { case DefaultFolderType.AdminAuditLogs: case DefaultFolderType.Audits: mailboxFolderConfiguration.FolderType = defaultFolderType.ToString(); break; default: mailboxFolderConfiguration.FolderType = Strings.UserCreatedFolder; break; } } else { mailboxFolderConfiguration.FolderType = defaultFolderType.ToString(); } } if (GetMailboxFolderStatistics.PropertyExists(array[8])) { Guid guid = new Guid((string)array[8]); ADObjectId valueToSearch = new ADObjectId(guid.ToByteArray()); List <ELCFolder> list = ELCTaskHelper.FindELCFolder(adConfigSession, valueToSearch, FindByType.FolderAdObjectId); if (list == null || list.Count != 1) { this.WriteWarning(Strings.UnableToRetrieveManagedFolder); } else { mailboxFolderConfiguration.ManagedFolder = new ELCFolderIdParameter(list[0].Id); } } IConfigurationSession configurationSession = null; if (GetMailboxFolderStatistics.PropertyExists(array[13])) { byte[] array3 = (byte[])array[13]; if (array3 != null) { Guid tagGuid = new Guid(array3); configurationSession = this.CreateConfigurationSession(mailboxSession); List <RetentionPolicyTag> list2 = ELCTaskHelper.FindRetentionPolicyTag(configurationSession, tagGuid); if (list2 == null || list2.Count != 1) { this.WriteWarning(Strings.UnableToRetrieveDeletePolicyTag); } else { mailboxFolderConfiguration.DeletePolicy = new RetentionPolicyTagIdParameter(list2[0].Id); } } } if (GetMailboxFolderStatistics.PropertyExists(array[14])) { byte[] array4 = (byte[])array[14]; if (array4 != null) { Guid tagGuid2 = new Guid(array4); if (configurationSession == null) { configurationSession = this.CreateConfigurationSession(mailboxSession); } List <RetentionPolicyTag> list3 = ELCTaskHelper.FindRetentionPolicyTag(configurationSession, tagGuid2); if (list3 == null || list3.Count != 1) { this.WriteWarning(Strings.UnableToRetrieveArchivePolicyTag); } else { mailboxFolderConfiguration.ArchivePolicy = new RetentionPolicyTagIdParameter(list3[0].Id); } } } } return(mailboxFolderConfiguration); }
internal static IDictionary <string, string> ExtractDeliveryDetails(StoreSession session, Item item) { IDictionary <string, string> customProperties = null; ActivityLogHelper.CatchNonFatalExceptions(delegate { MessageItem messageItem = item as MessageItem; if (messageItem == null) { return; } bool flag = false; bool flag2 = false; string value = null; ConversationId conversationId = null; string value2 = null; bool?flag3 = null; if (((IDirectPropertyBag)messageItem.PropertyBag).IsLoaded(InternalSchema.InferenceClassificationResult)) { InferenceClassificationResult?valueAsNullable = messageItem.GetValueAsNullable <InferenceClassificationResult>(InternalSchema.InferenceClassificationResult); flag3 = new bool?(valueAsNullable != null && valueAsNullable.Value.HasFlag(InferenceClassificationResult.IsClutterFinal)); } string value3 = string.Empty; if (flag3 != null) { value3 = (flag3.Value ? bool.TrueString : bool.FalseString); } bool?flag4 = new bool?(messageItem.IsGroupEscalationMessage); string value4 = string.Empty; if (flag4 != null) { value4 = (flag4.Value ? bool.TrueString : bool.FalseString); } StoreObjectId parentId = messageItem.ParentId; DefaultFolderType defaultFolderType = DefaultFolderType.None; bool flag5 = false; if (parentId != null) { StoreObjectId defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.Inbox); flag = parentId.Equals(defaultFolderId); StoreObjectId defaultFolderId2 = session.GetDefaultFolderId(DefaultFolderType.Clutter); flag2 = (defaultFolderId2 != null && parentId.Equals(defaultFolderId2)); MailboxSession mailboxSession = session as MailboxSession; if (mailboxSession != null) { defaultFolderType = mailboxSession.IsDefaultFolderType(parentId); flag5 = true; } } value = messageItem.InternetMessageId; ConversationIndex index; if (ConversationIndex.TryCreate(messageItem.ConversationIndex, out index)) { conversationId = ConversationId.Create(index); } string value5 = string.Empty; if (((IDirectPropertyBag)messageItem.PropertyBag).IsLoaded(InternalSchema.InferenceMessageIdentifier)) { value5 = messageItem.GetValueAsNullable <Guid>(InternalSchema.InferenceMessageIdentifier).ToString(); } if (messageItem.Sender != null) { value2 = messageItem.Sender.SmtpEmailAddress; } List <string> list = null; List <string> list2 = null; foreach (Recipient recipient in messageItem.Recipients) { if (recipient.Participant != null) { if (recipient.IsDistributionList() == true) { if (list == null) { list = new List <string>(2); } list.Add(recipient.SmtpAddress()); } else if (recipient.IsGroupMailbox() == true) { if (list2 == null) { list2 = new List <string>(2); } list2.Add(recipient.SmtpAddress()); } } } Dictionary <string, string> dictionary = new Dictionary <string, string> { { "IsClutter", value3 }, { "DeliveredToInbox", flag ? bool.TrueString : bool.FalseString }, { "DeliveredToClutter", flag2 ? bool.TrueString : bool.FalseString }, { "IsGroupEscalationMessage", value4 }, { "InternetMessageId", value }, { "ConversationId", (conversationId == null) ? string.Empty : conversationId.ToString() }, { "MessageGuid", value5 }, { "SenderSmtpAddress", value2 } }; if (list != null && list.Count > 0) { dictionary.Add("DLRecipients", string.Join(";", list)); } if (list2 != null) { dictionary.Add("GMRecipients", string.Join(";", list2)); } if (flag5) { Dictionary <string, string> dictionary2 = dictionary; string key = "DeliveredFolderType"; int num = (int)defaultFolderType; dictionary2.Add(key, num.ToString()); if (defaultFolderType == DefaultFolderType.None && parentId != null) { dictionary.Add("DeliveredFolderId", parentId.ToString()); } } customProperties = dictionary; }, null); return(customProperties); }
// Token: 0x060006CE RID: 1742 RVA: 0x00025F84 File Offset: 0x00024184 private void FillFidMapping(GetSyncStateResult results, MailboxSession session) { foreach (DeviceData deviceData in results.Devices) { foreach (SyncStateFolderData syncStateFolderData in deviceData.SyncFolders) { if (syncStateFolderData != null && !string.IsNullOrEmpty(syncStateFolderData.SyncStateBlob)) { syncStateFolderData.FolderMapping = new List <FolderMappingData>(); using (PooledMemoryStream pooledMemoryStream = new PooledMemoryStream(102400)) { byte[] array = Convert.FromBase64String(syncStateFolderData.SyncStateBlob); pooledMemoryStream.Write(array, 0, array.Length); pooledMemoryStream.Flush(); pooledMemoryStream.Position = 0L; int num; int num2; long num3; long num4; Dictionary <string, bool> dictionary; GenericDictionaryData <ConstStringData, string, DerivedData <ICustomSerializableBuilder> > genericDictionaryData = SyncState.InternalDeserializeData(pooledMemoryStream, out num, out num2, out num3, out num4, out dictionary); FolderIdMapping folderIdMapping = genericDictionaryData.Data["IdMapping"].Data as FolderIdMapping; IDictionaryEnumerator syncIdIdEnumerator = folderIdMapping.SyncIdIdEnumerator; while (syncIdIdEnumerator.MoveNext()) { string shortId = syncIdIdEnumerator.Key as string; ISyncItemId syncItemId = syncIdIdEnumerator.Value as ISyncItemId; StoreObjectId storeObjectId = syncItemId.NativeId as StoreObjectId; try { using (Folder folder = Folder.Bind(session, storeObjectId, new PropertyDefinition[] { FolderSchema.DisplayName })) { DefaultFolderType defaultFolderType = session.IsDefaultFolderType(folder.Id); syncStateFolderData.FolderMapping.Add(new FolderMappingData { ShortId = shortId, LongId = storeObjectId.ToString(), Name = folder.DisplayName, DefaultFolderType = defaultFolderType.ToString(), Exception = null }); } } catch (Exception ex) { syncStateFolderData.FolderMapping.Add(new FolderMappingData { ShortId = shortId, LongId = "[Error]", Name = "[Error]", DefaultFolderType = "[Error]", Exception = ex.ToString() }); } } } } } } }
// Token: 0x06000133 RID: 307 RVA: 0x000079F8 File Offset: 0x00005BF8 internal static void HandleEventInternal(MapiEvent mapiEvent, MailboxSession session, StoreObject storeItem, MailboxData mailboxData, List <KeyValuePair <string, object> > customDataToLog) { InferenceProcessor.Log(customDataToLog, "InferenceDiagnostics", mapiEvent.ToString()); Exception ex = null; try { ArgumentValidator.ThrowIfNull("session", session); if (storeItem == null) { InferenceProcessor.Log(customDataToLog, "InferenceDiagnostics", "NullStoreItem"); } else { MessageItem messageItem = storeItem as MessageItem; if (messageItem == null) { InferenceProcessor.Log(customDataToLog, "InferenceDiagnostics", "StoreItemIsNotMessageItem"); } else { if (InferenceProcessor.IsInferenceProcessingNeeded(mapiEvent)) { InferenceProcessor.Log(customDataToLog, "InferenceDiagnostics", "InferenceProcessingNeeded"); if (!messageItem.GetValueOrDefault <bool>(ItemSchema.InferenceProcessingNeeded, false)) { return; } try { messageItem.DeleteProperties(new PropertyDefinition[] { ItemSchema.InferenceProcessingNeeded }); InferenceProcessingActions valueOrDefault = (InferenceProcessingActions)messageItem.GetValueOrDefault <long>(ItemSchema.InferenceProcessingActions, 0L); messageItem.DeleteProperties(new PropertyDefinition[] { ItemSchema.InferenceProcessingActions }); if (valueOrDefault.HasFlag(InferenceProcessingActions.ProcessImplicitMarkAsNotClutter)) { InferenceProcessor.HandleImplicitMarkAsNotClutter(mapiEvent, session, messageItem, customDataToLog); goto IL_1C6; } throw new ArgumentException("No actionable flag is set on InferenceProcessingActions, but InferenceProcessingNeeded is true"); } finally { if (messageItem.IsDirty) { messageItem.Save(SaveMode.ResolveConflicts); } } } if (InferenceProcessor.IsOutlookActivityProcessingNeeded(mapiEvent, mailboxData)) { InferenceProcessor.Log(customDataToLog, "InferenceDiagnostics", "ProcessOutlookActivity"); if (session.IsDefaultFolderType(messageItem.ParentId) != DefaultFolderType.Inbox) { InferenceProcessor.Log(customDataToLog, "InferenceDiagnostics", "ActivityItemNotInExpectedFolder"); return; } try { int num = OutlookActivityProcessor.Process(session, messageItem); InferenceProcessor.Log(customDataToLog, "NumOfOutlookActivityItemsProcessed", num); } catch (OutlookActivityParsingException value) { InferenceProcessor.Log(customDataToLog, "OutlookActivityParsingException", value); } using (Folder folder = Folder.Bind(session, DefaultFolderType.Inbox)) { folder.DeleteObjects(DeleteItemFlags.HardDelete, new StoreId[] { messageItem.Id }); goto IL_1C6; } } throw new ArgumentException("We should not get an event that's not interested by InferenceProcessor" + mapiEvent.ToString()); IL_1C6 :; } } } catch (Exception ex2) { ex = ex2; } finally { if (ex != null) { InferenceProcessor.Log(customDataToLog, "Exception", ex.ToString()); } InferenceProcessor.Log(customDataToLog, "InferenceDiagnostics", (ex == null) ? "InvokeSucceeded" : "InvokeFailed"); } }
internal static string GetDefaultFolderName(MailboxSession session, StoreObjectId folderId) { DefaultFolderType defaultFolderType = session.IsDefaultFolderType(folderId); return(XsoUtil.GetDefaultFolderName(defaultFolderType)); }
// Token: 0x06000384 RID: 900 RVA: 0x00018884 File Offset: 0x00016A84 internal static DefaultFolderType GetParentDefaultFolderType(UserRetentionPolicyCache mailboxState, MailboxSession mailboxSession, StoreObjectId parentId) { bool flag = false; StoreObjectId storeObjectId = parentId; DefaultFolderType defaultFolderType = DefaultFolderType.None; Folder folder = null; try { while (!flag) { if (!mailboxState.FolderTypeDictionary.TryGetValue(storeObjectId, out defaultFolderType)) { defaultFolderType = mailboxSession.IsDefaultFolderType(storeObjectId); if (defaultFolderType != DefaultFolderType.None || ArrayComparer <byte> .Comparer.Equals(storeObjectId.ProviderLevelItemId, mailboxState.RootFolderId)) { break; } Exception ex = null; try { folder = Folder.Bind(mailboxSession, storeObjectId); } catch (ObjectNotFoundException ex2) { ex = ex2; } catch (ConversionFailedException ex3) { ex = ex3; } catch (VirusMessageDeletedException ex4) { ex = ex4; } if (ex != null) { TagAssistantHelper.Tracer.TraceDebug <Exception>(0L, "Problems loading a folder. It will not be processed. Exception: {0}", ex); } if (folder == null || ArrayComparer <byte> .Comparer.Equals(storeObjectId.ProviderLevelItemId, folder.ParentId.ProviderLevelItemId)) { break; } storeObjectId = folder.ParentId; folder.Dispose(); folder = null; } else { flag = true; } } if (storeObjectId != null && !ArrayComparer <byte> .Comparer.Equals(storeObjectId.ProviderLevelItemId, parentId.ProviderLevelItemId)) { mailboxState.FolderTypeDictionary.Add(parentId, defaultFolderType); } } finally { if (folder != null) { folder.Dispose(); } } return(defaultFolderType); }