private void CreateDefaultFolders()
        {
            int num = 0;

            foreach (DefaultFolderType defaultFolderType in this.mailboxSession.DefaultFolders)
            {
                if (!GroupMailboxPermissionHandler.IsFolderToBeIgnored(defaultFolderType))
                {
                    this.TraceDebug("Getting DefaultFolderId, DefaultFolderType={0}", new object[]
                    {
                        defaultFolderType
                    });
                    if (this.mailboxSession.GetDefaultFolderId(defaultFolderType) == null)
                    {
                        this.TraceDebug("Creating Folder {0}", new object[]
                        {
                            defaultFolderType
                        });
                        this.mailboxSession.CreateDefaultFolder(defaultFolderType);
                        num++;
                    }
                }
            }
            this.report.FoldersCreatedCount = num;
        }
Пример #2
0
        private bool FolderMembershipUpdate()
        {
            ArgumentValidator.ThrowIfNull("previousExternalMemberUser", this.previousExternalMemberUser);
            ArgumentValidator.ThrowIfNull("currentExternalMemberUser", this.currentExternalMemberUser);
            ArgumentValidator.ThrowIfNull("currentExternalOwnerUser", this.currentExternalOwnerUser);
            PermissionSecurityPrincipal userSecurityPrincipal  = new PermissionSecurityPrincipal(this.previousExternalMemberUser);
            PermissionSecurityPrincipal userSecurityPrincipal2 = new PermissionSecurityPrincipal(this.currentExternalMemberUser);
            PermissionSecurityPrincipal userSecurityPrincipal3 = new PermissionSecurityPrincipal(this.currentExternalOwnerUser);
            List <PermissionEntry>      list = new List <PermissionEntry>(3);
            int  num    = 0;
            int  num2   = 0;
            bool result = true;

            foreach (DefaultFolderType defaultFolderType in this.mailboxSession.DefaultFolders)
            {
                list.Clear();
                if (!GroupMailboxPermissionHandler.IsFolderToBeIgnored(defaultFolderType) && defaultFolderType != DefaultFolderType.MailboxAssociation)
                {
                    if (this.mailboxSession.GetDefaultFolderId(defaultFolderType) != null)
                    {
                        DefaultFolderType defaultFolderType2 = defaultFolderType;
                        MemberRights      memberRights;
                        MemberRights      userRights;
                        if (defaultFolderType2 != DefaultFolderType.Calendar)
                        {
                            switch (defaultFolderType2)
                            {
                            case DefaultFolderType.Configuration:
                                memberRights = GroupMailboxPermissionHandler.DefaultFolderPermission;
                                userRights   = GroupMailboxPermissionHandler.ConfigurationFolderPermission;
                                break;

                            case DefaultFolderType.SearchFolders:
                                memberRights = GroupMailboxPermissionHandler.SearchFolderPermission;
                                userRights   = (memberRights | GroupMailboxPermissionHandler.OwnerSpecificPermission);
                                break;

                            default:
                                memberRights = GroupMailboxPermissionHandler.DefaultFolderPermission;
                                userRights   = (memberRights | GroupMailboxPermissionHandler.OwnerSpecificPermission);
                                break;
                            }
                        }
                        else
                        {
                            memberRights = GroupMailboxPermissionHandler.CalendarFolderPermission;
                            userRights   = GroupMailboxPermissionHandler.CalendarFolderPermission;
                        }
                        list.Add(new PermissionEntry(userSecurityPrincipal, MemberRights.None));
                        list.Add(new PermissionEntry(userSecurityPrincipal3, userRights));
                        list.Add(new PermissionEntry(userSecurityPrincipal2, memberRights));
                        if (defaultFolderType == DefaultFolderType.Calendar)
                        {
                            list.Add(new PermissionEntry(new PermissionSecurityPrincipal(PermissionSecurityPrincipal.SpecialPrincipalType.Default), MemberRights.FreeBusySimple));
                        }
                        else
                        {
                            list.Add(new PermissionEntry(new PermissionSecurityPrincipal(PermissionSecurityPrincipal.SpecialPrincipalType.Default), MemberRights.None));
                        }
                        if (!GroupMailboxPermissionHandler.AssignMemberRight(this.mailboxSession, list, defaultFolderType, out num2))
                        {
                            result = false;
                            break;
                        }
                        num += num2;
                    }
                    else
                    {
                        GroupMailboxMembershipUpdater.Tracer.TraceError <DefaultFolderType, string>((long)this.GetHashCode(), "MembershipUpdate: Found a folder {0} that is not in group mailbox {1}", defaultFolderType, this.mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString());
                    }
                }
            }
            GroupMailboxMembershipUpdater.Tracer.TraceDebug <int, string>((long)this.GetHashCode(), "MembershipUpdate: {0} folders had been modified for the group mailbox {1}", num, this.mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString());
            return(result);
        }