internal static List <AdFolderData> GetUserElcFolders(MailboxSession session, ADUser aduser, List <ELCFolder> allAdFolders, bool getFoldersOnly, bool getOrgFoldersOnly) { if (allAdFolders == null || allAdFolders.Count == 0 || aduser == null) { return(null); } string arg = session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(); ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(session.MailboxOwner.MailboxInfo.OrganizationId); IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.FullyConsistent, sessionSettings, 258, "GetUserElcFolders", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\ELC\\AdFolderReader.cs"); ADObjectId managedFolderMailboxPolicy = aduser.ManagedFolderMailboxPolicy; if (managedFolderMailboxPolicy == null) { AdReader.Tracer.TraceDebug <string>(0L, "Mailbox '{0}' does not have an ELC Mailbox policy.", arg); return(null); } ManagedFolderMailboxPolicy managedFolderMailboxPolicy2 = tenantOrTopologyConfigurationSession.Read <ManagedFolderMailboxPolicy>(managedFolderMailboxPolicy); if (managedFolderMailboxPolicy2 == null) { AdReader.Tracer.TraceDebug <string, ADObjectId>(0L, "Mailbox '{0}' no matching ELC Mailbox policy for Template '{1}'.", arg, managedFolderMailboxPolicy); return(null); } MultiValuedProperty <ADObjectId> managedFolderLinks = managedFolderMailboxPolicy2.ManagedFolderLinks; List <AdFolderData> list = new List <AdFolderData>(); using (MultiValuedProperty <ADObjectId> .Enumerator enumerator = managedFolderLinks.GetEnumerator()) { while (enumerator.MoveNext()) { ADObjectId elcFolderId = enumerator.Current; ELCFolder elcfolder = allAdFolders.Find((ELCFolder adFolder) => elcFolderId.ObjectGuid == adFolder.Id.ObjectGuid); if (elcfolder == null) { throw new ELCNoMatchingOrgFoldersException(elcFolderId.DistinguishedName); } if (!getOrgFoldersOnly || elcfolder.FolderType == ElcFolderType.ManagedCustomFolder) { AdFolderData adFolderData = new AdFolderData(); adFolderData.LinkedToTemplate = true; adFolderData.Synced = false; adFolderData.Folder = elcfolder; if (!getFoldersOnly) { adFolderData.FolderSettings = AdFolderReader.FetchFolderContentSettings(elcfolder); } list.Add(adFolderData); } } } return(list); }
private List <AdFolderData> GetAdFoldersFromFolderNames(string[] folderNames) { OptInFolders.< > c__DisplayClassb CS$ < > 8__locals1 = new OptInFolders.< > c__DisplayClassb(); CS$ < > 8__locals1.folderNames = folderNames; List <AdFolderData> list = new List <AdFolderData>(); List <ELCFolder> allFolders = AdFolderReader.GetAllFolders(true, this.budget); int folderIndex; for (folderIndex = 0; folderIndex < CS$ < > 8__locals1.folderNames.GetLength(0); folderIndex++) { ELCFolder elcfolder = allFolders.Find((ELCFolder matchedFolder) => string.Compare(CS$ < > 8__locals1.folderNames[folderIndex], matchedFolder.FolderName, StringComparison.OrdinalIgnoreCase) == 0); if (elcfolder == null) { throw new ELCNoMatchingOrgFoldersException(CS$ < > 8__locals1.folderNames[folderIndex]); } list.Add(new AdFolderData { Folder = elcfolder }); } return(list); }
internal static ContentSetting[] FetchFolderContentSettings(ELCFolder elcFolder) { ElcContentSettings[] array = elcFolder.GetELCContentSettings().ReadAllPages(); List <ContentSetting> list = new List <ContentSetting>(); foreach (ElcContentSettings elcContentSettings in array) { ValidationError[] array3 = elcContentSettings.ValidateRead(); if (array3 != null && array3.Length > 0) { ValidationError[] array4 = array3; int num = 0; if (num < array4.Length) { ValidationError validationError = array4[num]; AdReader.Tracer.TraceError <Guid, LocalizedString>(0L, "The ElcContentSettings '{0}' has a validation error: {1}", elcContentSettings.Guid, validationError.Description); throw new DataValidationException(validationError); } } list.Add(new ContentSetting(elcContentSettings)); } return(list.ToArray()); }
internal static void CreateAllOthersConfigMsg(ELCFolder adFolder, MailboxSession session) { StoreId defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.Inbox); string localizedFolderComment = adFolder.GetLocalizedFolderComment(session.MailboxOwner.PreferredCultures); try { using (UserConfiguration userConfiguration = session.UserConfigurationManager.CreateFolderConfiguration("ELC", UserConfigurationTypes.Stream | UserConfigurationTypes.XML | UserConfigurationTypes.Dictionary, defaultFolderId)) { IDictionary dictionary = userConfiguration.GetDictionary(); dictionary["elcFlags"] = (adFolder.MustDisplayCommentEnabled ? 4 : 0); dictionary["elcComment"] = localizedFolderComment; dictionary["policyId"] = adFolder.Guid.ToString(); userConfiguration.Save(); } } catch (ObjectExistedException) { using (UserConfiguration folderConfiguration = session.UserConfigurationManager.GetFolderConfiguration("ELC", UserConfigurationTypes.Stream | UserConfigurationTypes.XML | UserConfigurationTypes.Dictionary, defaultFolderId)) { IDictionary dictionary2 = folderConfiguration.GetDictionary(); dictionary2["elcFlags"] = (adFolder.MustDisplayCommentEnabled ? 4 : 0); dictionary2["elcComment"] = localizedFolderComment; dictionary2["policyId"] = adFolder.Guid.ToString(); folderConfiguration.Save(); } } catch (SaveConflictException innerException) { throw new ELCOrgFolderCreationException(session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(), adFolder.FolderName, innerException); } catch (QuotaExceededException innerException2) { throw new ELCOrgFolderCreationException(session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(), adFolder.FolderName, innerException2); } }
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); }
// Token: 0x060009A7 RID: 2471 RVA: 0x00020FE9 File Offset: 0x0001F1E9 public ELCFolderIdParameter(ELCFolder elcFolder) : base(elcFolder.Id) { }
protected override void InternalValidate() { TaskLogger.LogEnter(); if (!base.Fields.Contains("Mailbox")) { SharedConfigurationTaskHelper.VerifyIsNotTinyTenant(base.CurrentOrgState, new Task.ErrorLoggerDelegate(base.WriteError)); } if (base.ParameterSetName == "ParameterSetMailboxTask") { return; } if (base.Fields.IsModified("LegacyManagedFolder")) { if (this.LegacyManagedFolder != null) { ELCFolder elcfolder = (ELCFolder)base.GetDataObject <ELCFolder>(this.LegacyManagedFolder, base.DataSession, null, new LocalizedString?(Strings.ErrorElcFolderNotFound(this.LegacyManagedFolder.ToString())), new LocalizedString?(Strings.ErrorAmbiguousElcFolderId(this.LegacyManagedFolder.ToString()))); this.DataObject.LegacyManagedFolder = elcfolder.Id; } else { this.DataObject.LegacyManagedFolder = null; } } base.InternalValidate(); if (this.contentSettingsObject.IsChanged(ElcContentSettingsSchema.RetentionAction)) { RetentionActionType[] source = new RetentionActionType[] { RetentionActionType.MoveToFolder }; if (source.Any((RetentionActionType x) => x == this.contentSettingsObject.RetentionAction)) { base.WriteError(new RetentionPolicyTagTaskException(Strings.ErrorRetentionActionNowAllowed), ErrorCategory.InvalidOperation, null); } if (this.DataObject.Type == ElcFolderType.RecoverableItems && !this.contentSettingsObject.RetentionAction.Equals(RetentionActionType.MoveToArchive)) { base.WriteError(new ArgumentException(Strings.ErrorDumpsterTagWrongRetentionAction), ErrorCategory.InvalidArgument, this); } if (this.DataObject.Type != ElcFolderType.All && this.DataObject.Type != ElcFolderType.Personal && this.DataObject.Type != ElcFolderType.RecoverableItems && this.RetentionAction == RetentionActionType.MoveToArchive) { base.WriteError(new RetentionPolicyTagTaskException(Strings.ErrorMoveToArchiveAppliedToSystemFolder), ErrorCategory.InvalidArgument, null); } } if (this.contentSettingsObject.IsChanged(ElcContentSettingsSchema.MessageClass) && this.DataObject.Type != ElcFolderType.All && !this.contentSettingsObject.MessageClass.Equals(ElcMessageClass.AllMailboxContent)) { base.WriteError(new RetentionPolicyTagTaskException(Strings.ErrorOnlyDefaultTagAllowCustomizedMessageClass), ErrorCategory.InvalidOperation, this.DataObject); } string tagName; if (this.DataObject.IsChanged(RetentionPolicyTagSchema.RetentionId) && !(base.DataSession as IConfigurationSession).CheckForRetentionTagWithConflictingRetentionId(this.DataObject.RetentionId, this.DataObject.Identity.ToString(), out tagName)) { base.WriteError(new RetentionPolicyTagTaskException(Strings.ErrorRetentionIdConflictsWithRetentionTag(this.DataObject.RetentionId.ToString(), tagName)), ErrorCategory.InvalidOperation, this.DataObject); } if (this.contentSettingsObject.IsChanged(ElcContentSettingsSchema.RetentionAction) || this.contentSettingsObject.IsChanged(ElcContentSettingsSchema.RetentionEnabled) || this.contentSettingsObject.IsChanged(ElcContentSettingsSchema.MessageClass)) { this.ValidateRetentionPolicy(); } if (base.Fields.IsModified("AddressForJournaling")) { if (this.AddressForJournaling != null) { ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(this.AddressForJournaling, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxAddressNotFound(this.AddressForJournaling.ToString())), new LocalizedString?(Strings.ErrorMailboxAddressNotUnique(this.AddressForJournaling.ToString()))); if (!this.DataObject.OrganizationId.Equals(OrganizationId.ForestWideOrgId)) { RecipientTaskHelper.CheckRecipientInSameOrganizationWithDataObject(this.DataObject, adrecipient, new Task.ErrorLoggerDelegate(base.WriteError)); } if (adrecipient.EmailAddresses == null || adrecipient.EmailAddresses.FindPrimary(ProxyAddressPrefix.Smtp) == null) { base.WriteError(new ArgumentException(Strings.SmtpAddressMissingForAutocopy(this.AddressForJournaling.ToString()), "AddressForJournaling"), ErrorCategory.InvalidData, this); } this.contentSettingsObject.AddressForJournaling = adrecipient.Id; } else { this.contentSettingsObject.AddressForJournaling = null; } } ValidationError[] array = this.contentSettingsObject.Validate(); if (array.Length > 0) { for (int i = 0; i < array.Length; i++) { this.WriteError(new DataValidationException(array[i]), (ErrorCategory)1003, this.contentSettingsObject.Identity, array.Length - 1 == i); } } if (base.HasErrors) { return; } TaskLogger.LogExit(); }
internal static Folder GetDefaultFolder(MailboxSession itemStore, ELCFolder elcFolder) { Folder result; if (elcFolder.FolderType == ElcFolderType.Inbox) { result = Folder.Bind(itemStore, DefaultFolderType.Inbox); } else if (elcFolder.FolderType == ElcFolderType.SentItems) { result = Folder.Bind(itemStore, DefaultFolderType.SentItems); } else if (elcFolder.FolderType == ElcFolderType.DeletedItems) { result = Folder.Bind(itemStore, DefaultFolderType.DeletedItems); } else if (elcFolder.FolderType == ElcFolderType.Calendar) { result = Folder.Bind(itemStore, DefaultFolderType.Calendar); } else if (elcFolder.FolderType == ElcFolderType.Contacts) { result = Folder.Bind(itemStore, DefaultFolderType.Contacts); } else if (elcFolder.FolderType == ElcFolderType.Drafts) { result = Folder.Bind(itemStore, DefaultFolderType.Drafts); } else if (elcFolder.FolderType == ElcFolderType.Outbox) { result = Folder.Bind(itemStore, DefaultFolderType.Outbox); } else if (elcFolder.FolderType == ElcFolderType.JunkEmail) { result = Folder.Bind(itemStore, DefaultFolderType.JunkEmail); } else if (elcFolder.FolderType == ElcFolderType.Tasks) { result = Folder.Bind(itemStore, DefaultFolderType.Tasks); } else if (elcFolder.FolderType == ElcFolderType.Journal) { result = Folder.Bind(itemStore, DefaultFolderType.Journal); } else if (elcFolder.FolderType == ElcFolderType.Notes) { result = Folder.Bind(itemStore, DefaultFolderType.Notes); } else if (elcFolder.FolderType == ElcFolderType.All) { result = Folder.Bind(itemStore, DefaultFolderType.Root); } else if (elcFolder.FolderType == ElcFolderType.SyncIssues) { result = Folder.Bind(itemStore, DefaultFolderType.SyncIssues); } else if (elcFolder.FolderType == ElcFolderType.RssSubscriptions) { result = Folder.Bind(itemStore, DefaultFolderType.RssSubscription); } else if (elcFolder.FolderType == ElcFolderType.ConversationHistory) { result = Folder.Bind(itemStore, DefaultFolderType.CommunicatorHistory); } else { if (elcFolder.FolderType != ElcFolderType.LegacyArchiveJournals) { throw new ELCUnknownDefaultFolderException(elcFolder.FolderName, itemStore.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()); } result = Folder.Bind(itemStore, DefaultFolderType.LegacyArchiveJournals); } return(result); }