示例#1
0
        internal ValidationError AddManagedFolderToPolicy(IConfigurationSession session, ELCFolder elcFolderToAdd)
        {
            ValidationError result;

            if (elcFolderToAdd.FolderType != ElcFolderType.ManagedCustomFolder)
            {
                ADObjectId adobjectId = this.ManagedFolderLinks.Find(delegate(ADObjectId id)
                {
                    ELCFolder elcfolder = session.Read <ELCFolder>(id);
                    return(elcfolder != null && elcfolder.FolderType == elcFolderToAdd.FolderType);
                });
                if (adobjectId == null)
                {
                    try
                    {
                        this.ManagedFolderLinks.Add(elcFolderToAdd.Id);
                        return(null);
                    }
                    catch (InvalidOperationException ex)
                    {
                        return(new PropertyValidationError(DirectoryStrings.ErrorInvalidFolderLinksAddition(elcFolderToAdd.Name, ex.Message), ManagedFolderMailboxPolicySchema.ManagedFolderLinks, this));
                    }
                }
                if (adobjectId == elcFolderToAdd.Id)
                {
                    return(new PropertyValidationError(DirectoryStrings.ErrorDuplicateManagedFolderAddition(elcFolderToAdd.Name), ManagedFolderMailboxPolicySchema.ManagedFolderLinks, this));
                }
                return(new PropertyValidationError(DirectoryStrings.ErrorDefaultElcFolderTypeExists(elcFolderToAdd.Name, elcFolderToAdd.FolderType.ToString()), ManagedFolderMailboxPolicySchema.ManagedFolderLinks, this));
            }
            else
            {
                try
                {
                    this.ManagedFolderLinks.Add(elcFolderToAdd.Id);
                    result = null;
                }
                catch (InvalidOperationException ex2)
                {
                    result = new PropertyValidationError(new LocalizedString(ex2.Message), ManagedFolderMailboxPolicySchema.ManagedFolderLinks, this);
                }
            }
            return(result);
        }
示例#2
0
        internal bool AreDefaultManagedFolderLinksUnique(IConfigurationSession session)
        {
            List <ELCFolder> list = new List <ELCFolder>();

            foreach (ADObjectId entryId in this.ManagedFolderLinks)
            {
                ELCFolder elcFolderToCheck = session.Read <ELCFolder>(entryId);
                if (elcFolderToCheck != null && elcFolderToCheck.FolderType != ElcFolderType.ManagedCustomFolder)
                {
                    ELCFolder elcfolder = list.Find((ELCFolder folder) => folder.FolderType == elcFolderToCheck.FolderType);
                    if (elcfolder == null)
                    {
                        list.Add(elcFolderToCheck);
                    }
                    else if (elcfolder.Id.ObjectGuid != elcFolderToCheck.Id.ObjectGuid)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
示例#3
0
 protected override void ValidateWrite(List <ValidationError> errors)
 {
     base.ValidateWrite(errors);
     if (this.FolderType == ElcFolderType.ManagedCustomFolder && string.IsNullOrEmpty(this.FolderName))
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.ErrorELCFolderNotSpecified, ELCFolderSchema.FolderName, this));
     }
     if (!string.IsNullOrEmpty(this.Comment) && base.IsChanged(ELCFolderSchema.Comment) && !ELCFolder.FolderTypeAllowsComments(this.FolderType))
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.ErrorElcCommentNotAllowed, ELCFolderSchema.Comment, this));
     }
     if (this.MustDisplayCommentEnabled && string.IsNullOrEmpty(this.Comment))
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.ErrorComment, ELCFolderSchema.Comment, this));
     }
     this.BuildMap(ref this.locNameMap, this.LocalizedFolderName, delegate
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.ErrorDuplicateLanguage, ELCFolderSchema.LocalizedFolderName, this));
     }, delegate
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.ErrorBadLocalizedFolderName, ELCFolderSchema.LocalizedFolderName, this));
     });
     this.BuildMap(ref this.locCommentMap, this.LocalizedComment, delegate
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.ErrorDuplicateLanguage, ELCFolderSchema.LocalizedComment, this));
     }, delegate
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.ErrorBadLocalizedComment, ELCFolderSchema.LocalizedComment, this));
     });
 }