internal static Folder CreateELCRootFolder(MailboxSession mailboxSession, string elcRootUrl) { string arg = mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(); ProvisionedFolderCreator.Tracer.TraceDebug <string>(0L, "'{0}': Attempting to create the ELC Root Folder.", arg); if (mailboxSession.CreateDefaultFolder(DefaultFolderType.ElcRoot) == null) { throw new ELCRootFailureException(Strings.descFailedToCreateELCRoot(mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()), null); } Folder folder = Folder.Bind(mailboxSession, DefaultFolderType.ElcRoot, new PropertyDefinition[] { FolderSchema.FolderHomePageUrl }); if (!string.IsNullOrEmpty(elcRootUrl)) { ProvisionedFolderCreator.Tracer.TraceDebug <string, string>(0L, "'{0}': Attempting to set the ELC Root Folder URL to '{1}'.", arg, elcRootUrl); ElcMailboxHelper.SetPropAndTrace(folder, FolderSchema.FolderHomePageUrl, elcRootUrl); folder.ClassName = Globals.ElcRootFolderClass; FolderSaveResult folderSaveResult = folder.Save(); if (folderSaveResult.OperationResult != OperationResult.Succeeded) { ProvisionedFolderCreator.Tracer.TraceError <SmtpAddress>(0L, "{0}: Unable to set the ELC Root Folder home page. Will attempt this again on the next run.", mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress); } folder.Load(); } return(folder); }
internal static void TryGetExistingHoldDurationInStore(IExchangePrincipal exchangePrincipal, string clientString, out Unlimited <EnhancedTimeSpan> existingHoldDuration, out ElcMailboxHelper.ConfigState state, out Exception exception) { Func <string, KeyValuePair <Unlimited <EnhancedTimeSpan>, ElcMailboxHelper.ConfigState> > valueFunction = delegate(string value) { Unlimited <EnhancedTimeSpan> key = default(Unlimited <EnhancedTimeSpan>); ElcMailboxHelper.ConfigState value2; double value3; if (string.Compare(value, Globals.UnlimitedHoldDuration, StringComparison.OrdinalIgnoreCase) == 0) { key = Unlimited <EnhancedTimeSpan> .UnlimitedValue; value2 = ElcMailboxHelper.ConfigState.Found; } else if (double.TryParse(value.ToString(), out value3)) { EnhancedTimeSpan fromValue = EnhancedTimeSpan.FromMilliseconds(value3); key = fromValue; value2 = ElcMailboxHelper.ConfigState.Found; } else { value2 = ElcMailboxHelper.ConfigState.Corrupt; } return(new KeyValuePair <Unlimited <EnhancedTimeSpan>, ElcMailboxHelper.ConfigState>(key, value2)); }; ElcMailboxHelper.TryGetExistingValueInStore <Unlimited <EnhancedTimeSpan> >(exchangePrincipal, clientString, "LitigationHoldDuration", valueFunction, out existingHoldDuration, out state, out exception); }
internal static void TryGetEHAHiddenFolderCleanupWatermarkInStore(IExchangePrincipal exchangePrincipal, string clientString, out ElcMailboxHelper.ConfigState state, out Exception exception) { Func <string, KeyValuePair <string, ElcMailboxHelper.ConfigState> > valueFunction = delegate(string value) { ElcMailboxHelper.ConfigState value2; if (!string.IsNullOrEmpty(value)) { if (!value.Equals("EHAHiddenFolderCleanupWatermark")) { value2 = ElcMailboxHelper.ConfigState.Invalid; } else { value2 = ElcMailboxHelper.ConfigState.Found; } } else { value2 = ElcMailboxHelper.ConfigState.Empty; } return(new KeyValuePair <string, ElcMailboxHelper.ConfigState>(value, value2)); }; string text = null; ElcMailboxHelper.TryGetExistingValueInStore <string>(exchangePrincipal, clientString, "EHAHiddenFolderCleanupWatermark", valueFunction, out text, out state, out exception); }
internal static void UpgradeElcFolder(bool userIsOnRetentionPolcyTags, MailboxSession mailboxSession, StoreId folderId, Dictionary <Guid, AdTagData> allAdTags) { using (Folder folder = Folder.Bind(mailboxSession, folderId, ProvisionedFolderReader.ElcFolderProps)) { ElcMailboxHelper.UpgradeElcFolder(userIsOnRetentionPolcyTags, mailboxSession, folder, allAdTags); ProvisionedFolderCreator.SaveELCFolder(folder, false); } }
internal static bool RemoveElcFolder(bool userIsOnRetentionPolcyTags, MailboxSession mailboxSession, StoreId folderId, Dictionary <Guid, AdTagData> allAdTags, out UpgradeStatus status) { status = UpgradeStatus.None; Stack <ElcMailboxHelper.FolderNode> stack = new Stack <ElcMailboxHelper.FolderNode>(50); ElcMailboxHelper.FolderNode folderNode = new ElcMailboxHelper.FolderNode(folderId, null); stack.Push(folderNode); while (stack.Count > 0) { ElcMailboxHelper.FolderNode folderNode2 = stack.Peek(); if (folderNode2.ChildCount == -1) { using (Folder folder = Folder.Bind(mailboxSession, folderNode2.FolderId, ProvisionedFolderReader.ElcFolderProps)) { folderNode2.ChildCount = folder.ItemCount + folder.SubfolderCount; using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.None, null, null, ProvisionedFolderReader.ElcFolderProps)) { for (;;) { object[][] rows = queryResult.GetRows(100); if (rows.Length <= 0) { break; } foreach (object[] array in rows) { stack.Push(new ElcMailboxHelper.FolderNode((VersionedId)array[0], folderNode2)); } } } if (ElcMailboxHelper.IsElcFolder(folder)) { status |= ElcMailboxHelper.UpgradeElcFolder(userIsOnRetentionPolcyTags, mailboxSession, folder, allAdTags); ProvisionedFolderCreator.SaveELCFolder(folder, false); } continue; } } if (folderNode2.ChildCount == 0) { if (folderNode2.Parent != null) { folderNode2.Parent.ChildCount--; } mailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[] { folderNode2.FolderId }); } stack.Pop(); } return(folderNode.ChildCount == 0); }
internal static bool IsElcFolder(object[] folderProps) { if (ElcMailboxHelper.Exists(folderProps[3])) { return(true); } if (ElcMailboxHelper.Exists(folderProps[5]) && folderProps[5] is int?) { int num = (int)folderProps[5]; if ((num & 1) != 0) { return(true); } } return(false); }
private static bool ScrubElcMailbox(bool userIsOnRetentionPolcyTags, MailboxSession mailboxSession, Dictionary <Guid, AdTagData> allAdTags, out UpgradeStatus status) { status = UpgradeStatus.None; bool result = true; StoreObjectId elcRootFolderId = ElcMailboxHelper.GetElcRootFolderId(mailboxSession); if (elcRootFolderId != null) { result = ElcMailboxHelper.RemoveElcFolder(userIsOnRetentionPolcyTags, mailboxSession, elcRootFolderId, allAdTags, out status); } object[] array = null; using (Folder folder = Folder.Bind(mailboxSession, DefaultFolderType.Root, ProvisionedFolderReader.ElcFolderProps)) { array = folder.GetProperties(ProvisionedFolderReader.ElcFolderProps); using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.None, null, null, ProvisionedFolderReader.ElcFolderProps)) { for (;;) { object[][] rows = queryResult.GetRows(100); if (rows.Length <= 0) { break; } foreach (object[] array2 in rows) { if (ElcMailboxHelper.IsElcFolder(array2)) { ElcMailboxHelper.UpgradeElcFolder(userIsOnRetentionPolcyTags, mailboxSession, (VersionedId)array2[0], allAdTags); } } } } } if (ElcMailboxHelper.IsElcFolder(array)) { ElcMailboxHelper.UpgradeElcFolder(userIsOnRetentionPolcyTags, mailboxSession, (VersionedId)array[0], null); } StoreId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox); mailboxSession.UserConfigurationManager.DeleteFolderConfigurations(defaultFolderId, new string[] { "ELC" }); return(result); }
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); }
internal static bool IsElcFolder(Folder folder) { object[] properties = folder.GetProperties(new PropertyDefinition[] { FolderSchema.ELCPolicyIds, FolderSchema.AdminFolderFlags }); if (ElcMailboxHelper.Exists(properties[0])) { return(true); } if (ElcMailboxHelper.Exists(properties[1])) { int num = (int)properties[1]; if ((num & 1) != 0) { return(true); } } return(false); }
internal static void TryGetHoldCleanupWatermarkInStore(IExchangePrincipal exchangePrincipal, string clientString, out DefaultFolderType folderType, out string internetMessageId, out ElcMailboxHelper.ConfigState state, out Exception exception) { folderType = DefaultFolderType.None; internetMessageId = null; Func <string, KeyValuePair <string, ElcMailboxHelper.ConfigState> > valueFunction = delegate(string value) { ElcMailboxHelper.ConfigState value2; if (!string.IsNullOrEmpty(value)) { value2 = ElcMailboxHelper.ConfigState.Found; } else { value2 = ElcMailboxHelper.ConfigState.Empty; } return(new KeyValuePair <string, ElcMailboxHelper.ConfigState>(value, value2)); }; string text = null; ElcMailboxHelper.TryGetExistingValueInStore <string>(exchangePrincipal, clientString, "HoldCleanupWatermark", valueFunction, out text, out state, out exception); if (state == ElcMailboxHelper.ConfigState.Found) { string[] array = text.Split(new char[] { ':' }, 2); try { folderType = (DefaultFolderType)Enum.Parse(typeof(DefaultFolderType), array[0]); if (array.Length == 2) { internetMessageId = array[1]; } } catch (ArgumentException) { state = ElcMailboxHelper.ConfigState.Corrupt; } } }
internal static bool UpdateHoldCleanupWatermarkFAIMessage(DefaultFolderType folderType, string internetMessageId, string clientString, IExchangePrincipal principal, out Exception ex) { return(ElcMailboxHelper.UpdateFAIMessage("HoldCleanupWatermark", string.Format("{0}:{1}", folderType, internetMessageId), principal, clientString, out ex)); }
private static bool ScrubElcMailbox(bool userIsOnRetentionPolcyTags, MailboxSession mailboxSession, Dictionary <Guid, AdTagData> allAdTags) { UpgradeStatus upgradeStatus = UpgradeStatus.None; return(ElcMailboxHelper.ScrubElcMailbox(userIsOnRetentionPolcyTags, mailboxSession, allAdTags, out upgradeStatus)); }
internal static void TryGetExistingValueInStore <T>(IExchangePrincipal exchangePrincipal, string clientString, string userConfigKey, Func <string, KeyValuePair <T, ElcMailboxHelper.ConfigState> > valueFunction, out T existingValue, out ElcMailboxHelper.ConfigState state, out Exception exception) { existingValue = default(T); state = ElcMailboxHelper.ConfigState.Unknown; exception = null; try { using (MailboxSession mailboxSession = ElcMailboxHelper.OpenMailboxSessionAsSystemService(exchangePrincipal, clientString)) { if (mailboxSession == null) { state = ElcMailboxHelper.ConfigState.ErrorWhileFetching; } else { StoreId systemFolderId = mailboxSession.GetSystemFolderId(); if (systemFolderId != null) { using (UserConfiguration userConfiguration = ElcMailboxHelper.OpenFaiMessage(mailboxSession, "MRM", false, systemFolderId)) { if (userConfiguration == null) { state = ElcMailboxHelper.ConfigState.FAINotFound; } else { IDictionary dictionary = userConfiguration.GetDictionary(); if (dictionary != null && dictionary.Contains(userConfigKey)) { string text = dictionary[userConfigKey] as string; if (text != null) { KeyValuePair <T, ElcMailboxHelper.ConfigState> keyValuePair = valueFunction(text); existingValue = keyValuePair.Key; state = keyValuePair.Value; } else { state = ElcMailboxHelper.ConfigState.Empty; } } else { state = ElcMailboxHelper.ConfigState.Empty; } } goto IL_AE; } } state = ElcMailboxHelper.ConfigState.FAINotFound; } IL_AE :; } } catch (InvalidCastException ex) { state = ElcMailboxHelper.ConfigState.Corrupt; exception = ex; } catch (CorruptDataException ex2) { state = ElcMailboxHelper.ConfigState.Corrupt; exception = ex2; } catch (InvalidOperationException ex3) { state = ElcMailboxHelper.ConfigState.Invalid; exception = ex3; } catch (StorageTransientException ex4) { state = ElcMailboxHelper.ConfigState.ErrorWhileFetching; exception = ex4; } catch (StoragePermanentException ex5) { state = ElcMailboxHelper.ConfigState.ErrorWhileFetching; exception = ex5; } }
internal static bool RemoveElcInMailbox(MailboxSession mailboxSession) { return(ElcMailboxHelper.ScrubElcMailbox(false, mailboxSession, null)); }
internal static bool UpgradeElcMailbox(MailboxSession mailboxSession, Dictionary <Guid, AdTagData> allAdTags, out UpgradeStatus status) { return(ElcMailboxHelper.ScrubElcMailbox(true, mailboxSession, allAdTags, out status)); }
private static bool UpdateFAIMessage(string userConfigKey, string serializedValue, IExchangePrincipal principal, string clientString, out Exception ex) { ex = null; bool result = false; try { using (MailboxSession mailboxSession = ElcMailboxHelper.OpenMailboxSessionAsSystemService(principal, clientString)) { if (mailboxSession != null) { StoreId storeId = mailboxSession.GetSystemFolderId(); if (storeId == null) { storeId = mailboxSession.CreateSystemFolder(); } using (UserConfiguration userConfiguration = ElcMailboxHelper.OpenFaiMessage(mailboxSession, "MRM", true, storeId)) { if (userConfiguration != null) { IDictionary dictionary = userConfiguration.GetDictionary(); if (dictionary != null) { if (dictionary.Contains(userConfigKey)) { dictionary[userConfigKey] = serializedValue; } else { dictionary.Add(userConfigKey, serializedValue); } userConfiguration.Save(); result = true; } } } } } } catch (CorruptDataException ex2) { result = false; ex = ex2; } catch (InvalidOperationException ex3) { result = false; ex = ex3; } catch (ObjectNotFoundException ex4) { result = false; ex = ex4; } catch (StorageTransientException ex5) { result = false; ex = ex5; } catch (StoragePermanentException ex6) { result = false; ex = ex6; } return(result); }
internal static Dictionary <Guid, AdTagData> GetTagsInPolicy(MailboxSession session, ADUser aduser, Dictionary <Guid, AdTagData> allAdTags) { if (allAdTags == null || allAdTags.Count == 0 || aduser == null) { return(null); } string arg = session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(); ADObjectId adobjectId = aduser.RetentionPolicy; if (adobjectId == null && aduser.ShouldUseDefaultRetentionPolicy && aduser.OrganizationId != null && !OrganizationId.ForestWideOrgId.Equals(aduser.OrganizationId)) { IConfigurationSession scopedSession; if (SharedConfiguration.IsDehydratedConfiguration(aduser.OrganizationId)) { scopedSession = SharedConfiguration.CreateScopedToSharedConfigADSession(aduser.OrganizationId); } else { scopedSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(false, ConsistencyMode.FullyConsistent, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(aduser.OrganizationId), 149, "GetTagsInPolicy", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\ELC\\AdTagReader.cs"); } IList <RetentionPolicy> defaultRetentionPolicy = SharedConfiguration.GetDefaultRetentionPolicy(scopedSession, aduser, null, 1); if (defaultRetentionPolicy != null && defaultRetentionPolicy.Count > 0) { adobjectId = defaultRetentionPolicy[0].Id; } } if (adobjectId == null) { AdReader.Tracer.TraceDebug <string>(0L, "Mailbox '{0}' does not have an ELC Mailbox policy.", arg); return(null); } IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(false, ConsistencyMode.FullyConsistent, ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(adobjectId), 175, "GetTagsInPolicy", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\ELC\\AdTagReader.cs"); RetentionPolicy retentionPolicy = tenantOrTopologyConfigurationSession.Read <RetentionPolicy>(adobjectId); if (retentionPolicy == null) { AdReader.Tracer.TraceDebug <string, ADObjectId>(0L, "Mailbox '{0}' no matching ELC Mailbox policy for Template '{1}'.", arg, adobjectId); return(null); } MultiValuedProperty <ADObjectId> retentionPolicyTagLinks = retentionPolicy.RetentionPolicyTagLinks; Dictionary <Guid, AdTagData> dictionary = new Dictionary <Guid, AdTagData>(); List <AdTagData> list = new List <AdTagData>(); List <AdTagData> list2 = new List <AdTagData>(); int num = 0; Dictionary <Guid, AdTagData> dictionary2 = new Dictionary <Guid, AdTagData>(); foreach (Guid key in allAdTags.Keys) { AdTagData adTagData = allAdTags[key]; dictionary2[adTagData.Tag.Guid] = adTagData; } foreach (ADObjectId adobjectId2 in retentionPolicyTagLinks) { if (!dictionary2.ContainsKey(adobjectId2.ObjectGuid)) { AdReader.Tracer.TraceDebug <string, string>(0L, "Mailbox '{0}' has link '{1}' in policy to a tag that could not be found in the AD. Skipping user.", arg, adobjectId2.DistinguishedName); throw new IWTransientException(Strings.descTagNotInAD(adobjectId2.DistinguishedName)); } AdTagData adTagData2 = dictionary2[adobjectId2.ObjectGuid]; if (adTagData2.Tag.Type == ElcFolderType.All) { if (ElcMailboxHelper.IsArchiveTag(adTagData2, false)) { AdReader.Tracer.TraceDebug <string, string>(0L, "Mailbox '{0}'. Tag {1} is a default archive tag.", arg, adTagData2.Tag.Name); list2.Add(adTagData2); } else if (adTagData2.Tag.IsPrimary) { AdReader.Tracer.TraceDebug <string, string>(0L, "Mailbox '{0}'. Tag {1} is the primary default retention tag.", arg, adTagData2.Tag.Name); list.Insert(0, adTagData2); num++; } else { AdReader.Tracer.TraceDebug <string, string>(0L, "Mailbox '{0}'. Tag {1} is a default retention tag.", arg, adTagData2.Tag.Name); list.Add(adTagData2); } } else { dictionary[adobjectId2.ObjectGuid] = dictionary2[adobjectId2.ObjectGuid]; } } if (list2.Count > 0) { AdReader.Tracer.TraceDebug <string, string, int>(0L, "Mailbox '{0}' with policy '{1}' has {2} default MTA tags.", arg, retentionPolicy.Id.DistinguishedName, list2.Count); list2.Sort(delegate(AdTagData x, AdTagData y) { if (x.ContentSettings.Count != 1) { return(1); } if (y.ContentSettings.Count != 1) { return(-1); } return(x.ContentSettings.Single <KeyValuePair <Guid, ContentSetting> >().Value.MessageClass.Length - y.ContentSettings.Single <KeyValuePair <Guid, ContentSetting> >().Value.MessageClass.Length); }); AdTagData firstArchiveTag = new AdTagData(); firstArchiveTag.Tag = list2[0].Tag; firstArchiveTag.ContentSettings = new SortedDictionary <Guid, ContentSetting>(); list2.SelectMany((AdTagData x) => x.ContentSettings.Values).ForEach(delegate(ContentSetting x) { firstArchiveTag.ContentSettings[x.Guid] = x; }); dictionary[firstArchiveTag.Tag.Guid] = firstArchiveTag; } if (list.Count > 0) { if (num > 1) { AdReader.Tracer.TraceDebug <string, string>(0L, "Mailbox '{0}' has policy '{1}' with corrupted default tags (Primary default should be 1). Skipping user.", arg, retentionPolicy.Id.DistinguishedName); throw new IWPermanentException(Strings.descPrimaryDefaultCorrupted(retentionPolicy.Id.DistinguishedName, num)); } if (num == 0 && list.Count > 1) { list.Sort(delegate(AdTagData x, AdTagData y) { if (x.ContentSettings.Count != 1) { return(1); } if (y.ContentSettings.Count != 1) { return(-1); } return(x.ContentSettings.Single <KeyValuePair <Guid, ContentSetting> >().Value.MessageClass.Length - y.ContentSettings.Single <KeyValuePair <Guid, ContentSetting> >().Value.MessageClass.Length); }); } for (int i = 0; i < list.Count; i++) { Guid guid = list[i].Tag.Guid; dictionary[guid] = list[i]; } } return(dictionary); }
internal static UserConfiguration OpenFaiMessage(MailboxSession mailboxSession, string faiMessageClass, bool createIfMissing) { StoreId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox); return(ElcMailboxHelper.OpenFaiMessage(mailboxSession, faiMessageClass, createIfMissing, defaultFolderId)); }
internal static void ForeachQueryResult(QueryResult queryResult, ElcMailboxHelper.RowInvokeDelegate rowInvoke) { ElcMailboxHelper.ForeachQueryResult(queryResult, 100, rowInvoke); }
private static void SerializeStoreTags(Dictionary <Guid, StoreTagData> dictionary, Dictionary <Guid, StoreTagData> defaultArchiveTagData, List <Guid> deletedTags, RetentionHoldData retentionHoldData, Stream dataStream, IExchangePrincipal mailboxOwner, bool compactDefaultTagOnly, bool fullCrawlRequired) { MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal, int>(0L, "Mailbox:{0}. About to serialize tags to FAI. There are {1} items in the tag dictionary.", mailboxOwner, (dictionary == null) ? -1 : dictionary.Count); dataStream.SetLength(0L); using (XmlTextWriter xmlTextWriter = new XmlTextWriter(dataStream, null)) { xmlTextWriter.WriteStartElement("UserConfiguration"); xmlTextWriter.WriteStartElement("Info"); xmlTextWriter.WriteAttributeString("version", "Exchange.14"); xmlTextWriter.WriteStartElement("Data"); if (!compactDefaultTagOnly) { MrmFaiFormatter.Tracer.TraceDebug(0L, "Mailbox:{0}. About to write out hold info. HoldEnabled: {1}. Comment: {2}. Url: {3}", new object[] { mailboxOwner, retentionHoldData.HoldEnabled, retentionHoldData.Comment, retentionHoldData.Url }); xmlTextWriter.WriteStartElement("RetentionHold"); xmlTextWriter.WriteAttributeString("Enabled", retentionHoldData.HoldEnabled.ToString()); xmlTextWriter.WriteAttributeString("RetentionComment", retentionHoldData.Comment); xmlTextWriter.WriteAttributeString("RetentionUrl", retentionHoldData.Url); xmlTextWriter.WriteEndElement(); } xmlTextWriter.WriteStartElement("ArchiveSync"); xmlTextWriter.WriteAttributeString("FullCrawlRequired", fullCrawlRequired.ToString()); xmlTextWriter.WriteEndElement(); if (deletedTags != null) { foreach (Guid guid in deletedTags) { xmlTextWriter.WriteStartElement("DeletedTag"); xmlTextWriter.WriteAttributeString("Guid", guid.ToString()); xmlTextWriter.WriteEndElement(); } } foreach (StoreTagData storeTagData in dictionary.Values) { if (storeTagData == null) { MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal>(0L, "Mailbox:{0}. Store data Tag is null, so it will not be serialized.", mailboxOwner); } else { bool flag = storeTagData.Tag.IsArchiveTag || ElcMailboxHelper.IsArchiveTag(storeTagData, false); if (storeTagData.Tag.Type == ElcFolderType.All && flag) { MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal, string>(0L, "Mailbox:{0}. Tag {1} is a default Move To Archive tag. We don't serialize those.", mailboxOwner, storeTagData.Tag.Name); } else { MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal, string>(0L, "Mailbox:{0}. Starting to serialize tag {1}.", mailboxOwner, storeTagData.Tag.Name); if (compactDefaultTagOnly && storeTagData.Tag.Type != ElcFolderType.All) { MrmFaiFormatter.Tracer.TraceDebug <IExchangePrincipal, string>(0L, "Mailbox:{0}. compactDefaultTagOnly is true and tag {1} is not default, so skip.", mailboxOwner, storeTagData.Tag.Name); } else if (flag) { MrmFaiFormatter.SerializeStoreTagData("ArchiveTag", storeTagData, xmlTextWriter, mailboxOwner, compactDefaultTagOnly); } else { MrmFaiFormatter.SerializeStoreTagData("PolicyTag", storeTagData, xmlTextWriter, mailboxOwner, compactDefaultTagOnly); } } } } if (defaultArchiveTagData != null) { foreach (StoreTagData storeTagData2 in defaultArchiveTagData.Values) { MrmFaiFormatter.SerializeStoreTagData("DefaultArchiveTag", storeTagData2, xmlTextWriter, mailboxOwner, compactDefaultTagOnly); } } xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteEndElement(); } }
internal static bool ClearHoldCleanupWatermarkFAIMessage(string clientString, IExchangePrincipal principal, out Exception ex) { return(ElcMailboxHelper.UpdateFAIMessage("HoldCleanupWatermark", null, principal, clientString, out ex)); }
internal static string CreateOneELCFolderInMailbox(AdFolderData adFolderInfo, MailboxSession itemStore, Folder elcRootFolder) { Folder folder = null; ELCFolder folder2 = adFolderInfo.Folder; string text = itemStore.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(); string text2 = (folder2.FolderType == ElcFolderType.ManagedCustomFolder) ? folder2.FolderName : folder2.FolderType.ToString(); string result; try { if (folder2.FolderType != ElcFolderType.ManagedCustomFolder) { ProvisionedFolderCreator.Tracer.TraceDebug <string, string>(0L, "Need to provision a default folder '{0}' in mailbox '{1}'.", text2, text); try { folder = ElcMailboxHelper.GetDefaultFolder(itemStore, folder2); } catch (ObjectNotFoundException innerException) { ProvisionedFolderCreator.Tracer.TraceDebug <string, string>(0L, "Default folder '{0}' does not exist in mailbox '{1}'.", text2, text); throw new ELCDefaultFolderNotFoundException(text2, text, innerException); } ProvisionedFolderCreator.Tracer.TraceDebug <string, string>(0L, "Default folder '{0}' exists in mailbox '{1}' and will be provisioned.", text2, text); result = '/' + ProvisionedFolderCreator.NormalizeFolderName(text2); } else { ProvisionedFolderCreator.Tracer.TraceDebug <string, string>(0L, "Creating organizational folder '{0}' in mailbox '{1}'.", text2, text); folder = Folder.Create(itemStore, elcRootFolder.Id, StoreObjectType.Folder, folder2.FolderName, CreateMode.OpenIfExists); ProvisionedFolderCreator.SaveELCFolder(folder, true); folder.Load(); result = string.Concat(new object[] { '/', ProvisionedFolderCreator.NormalizeFolderName(elcRootFolder.DisplayName), '/', ProvisionedFolderCreator.NormalizeFolderName(text2) }); } ELCFolderFlags elcfolderFlags = ELCFolderFlags.None; ulong num = folder2.StorageQuota.IsUnlimited ? 0UL : folder2.StorageQuota.Value.ToKB(); if (folder2.FolderType == ElcFolderType.ManagedCustomFolder) { elcfolderFlags = ELCFolderFlags.Provisioned; if (adFolderInfo.LinkedToTemplate) { elcfolderFlags |= ELCFolderFlags.Protected; } if (folder.ItemCount == 0 && !folder.HasSubfolders) { elcfolderFlags |= ELCFolderFlags.TrackFolderSize; } if (num > 0UL) { elcfolderFlags |= ELCFolderFlags.Quota; } } if (folder2.MustDisplayCommentEnabled) { elcfolderFlags |= ELCFolderFlags.MustDisplayComment; } ElcMailboxHelper.SetPropAndTrace(folder, FolderSchema.AdminFolderFlags, elcfolderFlags); ElcMailboxHelper.SetPropAndTrace(folder, FolderSchema.ELCPolicyIds, folder2.Guid.ToString()); string localizedFolderComment = folder2.GetLocalizedFolderComment(itemStore.MailboxOwner.PreferredCultures); if (!string.IsNullOrEmpty(localizedFolderComment)) { ElcMailboxHelper.SetPropAndTrace(folder, FolderSchema.ELCFolderComment, localizedFolderComment); } else { ElcMailboxHelper.SetPropAndTrace(folder, FolderSchema.ELCFolderComment, Globals.BlankComment); } if (folder2.FolderType == ElcFolderType.ManagedCustomFolder && num > 0UL) { ElcMailboxHelper.SetPropAndTrace(folder, FolderSchema.FolderQuota, (int)num); } ProvisionedFolderCreator.SaveELCFolder(folder, true); if (folder2.FolderType == ElcFolderType.All) { ProvisionedFolderCreator.CreateAllOthersConfigMsg(adFolderInfo.Folder, itemStore); } ProvisionedFolderCreator.Tracer.TraceDebug <string, string>(0L, "Successfully created/provisioned folder '{0}' in mailbox '{1}'.", text2, text); } finally { if (folder != null) { folder.Dispose(); folder = null; } } return(result); }
internal static bool ClearEHAHiddenFolderCleanupWatermark(IExchangePrincipal principal, string clientString, out Exception ex) { return(ElcMailboxHelper.UpdateFAIMessage("EHAHiddenFolderCleanupWatermark", null, principal, clientString, out ex)); }