예제 #1
0
        private void AddPermissions(CalendarFolderPermissionSet permissions, PermissionSet fbPermissions)
        {
            List <ADRecipient> list = new List <ADRecipient>(this.policyMembersToAddPermission.Count + this.delegatesToAddPermission.Count);

            foreach (string legacyExchangeDN in this.policyMembersToAddPermission)
            {
                list.Add(base.TenantGlobalCatalogSession.FindByLegacyExchangeDN(legacyExchangeDN));
            }
            foreach (ADObjectId entryId in this.delegatesToAddPermission)
            {
                list.Add(base.TenantGlobalCatalogSession.Read(entryId));
            }
            foreach (ADRecipient adrecipient in list)
            {
                if (adrecipient != null && adrecipient.IsValidSecurityPrincipal && (adrecipient.RecipientType == RecipientType.UserMailbox || adrecipient.RecipientType == RecipientType.MailUser || adrecipient.RecipientType == RecipientType.MailUniversalSecurityGroup))
                {
                    PermissionSecurityPrincipal securityPrincipal        = new PermissionSecurityPrincipal(adrecipient);
                    CalendarFolderPermission    calendarFolderPermission = permissions.GetEntry(securityPrincipal);
                    bool flag = this.delegatesToAddPermission.Contains(adrecipient.Id);
                    if (calendarFolderPermission == null)
                    {
                        calendarFolderPermission = permissions.AddEntry(securityPrincipal, PermissionLevel.None);
                    }
                    calendarFolderPermission.FreeBusyAccess = FreeBusyAccess.Details;
                    if (flag)
                    {
                        calendarFolderPermission.PermissionLevel = PermissionLevel.Editor;
                        calendarFolderPermission.DeleteItems     = ItemPermissionScope.AllItems;
                        calendarFolderPermission.IsFolderVisible = true;
                    }
                }
            }
        }
예제 #2
0
        private void RemovePermissions(CalendarFolderPermissionSet permissions, PermissionSet fbPermissions)
        {
            List <ADRecipient> list = new List <ADRecipient>(this.policyMembersToRemovePermission.Count + this.delegatesToRemovePermission.Count);

            foreach (string legacyExchangeDN in this.policyMembersToRemovePermission)
            {
                list.Add(base.TenantGlobalCatalogSession.FindByLegacyExchangeDN(legacyExchangeDN));
            }
            foreach (ADObjectId entryId in this.delegatesToRemovePermission)
            {
                list.Add(base.TenantGlobalCatalogSession.Read(entryId));
            }
            foreach (ADRecipient adrecipient in list)
            {
                if (adrecipient != null && adrecipient.IsValidSecurityPrincipal)
                {
                    PermissionSecurityPrincipal securityPrincipal = new PermissionSecurityPrincipal(adrecipient);
                    CalendarFolderPermission    entry             = permissions.GetEntry(securityPrincipal);
                    bool flag  = this.delegatesToRemovePermission.Contains(adrecipient.Id);
                    bool flag2 = this.policyMembersToRemovePermission.Contains(adrecipient.LegacyExchangeDN);
                    if (entry != null)
                    {
                        if (flag)
                        {
                            if (!this.newPolicyMembers.Contains(adrecipient.LegacyExchangeDN))
                            {
                                permissions.RemoveEntry(securityPrincipal);
                            }
                            else
                            {
                                entry.PermissionLevel = PermissionLevel.None;
                            }
                        }
                        if (flag2 && entry.PermissionLevel != PermissionLevel.Editor)
                        {
                            entry.FreeBusyAccess = FreeBusyAccess.None;
                            if (entry.PermissionLevel == PermissionLevel.None)
                            {
                                permissions.RemoveEntry(securityPrincipal);
                            }
                        }
                    }
                    if (flag)
                    {
                        Permission entry2 = fbPermissions.GetEntry(securityPrincipal);
                        if (entry2 != null)
                        {
                            fbPermissions.RemoveEntry(securityPrincipal);
                        }
                    }
                }
            }
        }