Esempio n. 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;
                    }
                }
            }
        }
Esempio n. 2
0
 private void WorkWithPermissions(MailboxSession itemStore)
 {
     if (this.delegatesToAddPermission.Count > 0 || this.delegatesToRemovePermission.Count > 0 || this.policyMembersToAddPermission.Count > 0 || this.policyMembersToRemovePermission.Count > 0 || this.oldAllPolicy != this.newAllPolicy)
     {
         using (CalendarFolder calendarFolder = CalendarFolder.Bind(itemStore, DefaultFolderType.Calendar))
         {
             using (Folder folder = Folder.Create(itemStore, itemStore.GetDefaultFolderId(DefaultFolderType.Configuration), StoreObjectType.Folder, "Freebusy Data", CreateMode.OpenIfExists))
             {
                 CalendarFolderPermissionSet permissionSet = calendarFolder.GetPermissionSet();
                 PermissionSet permissionSet2 = folder.GetPermissionSet();
                 permissionSet.DefaultPermission.FreeBusyAccess = (this.newAllPolicy ? FreeBusyAccess.Details : FreeBusyAccess.Basic);
                 this.AddPermissions(permissionSet, permissionSet2);
                 this.RemovePermissions(permissionSet, permissionSet2);
                 FolderSaveResult folderSaveResult = folder.Save();
                 if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded)
                 {
                     base.ThrowTerminatingError(new FolderSaveException(Strings.CalendarSave, folderSaveResult), ErrorCategory.InvalidOperation, null);
                 }
                 folderSaveResult = calendarFolder.Save();
                 if (folderSaveResult != null && folderSaveResult.OperationResult != OperationResult.Succeeded)
                 {
                     base.ThrowTerminatingError(new FolderSaveException(Strings.CalendarSave, folderSaveResult), ErrorCategory.InvalidOperation, null);
                 }
             }
         }
         if (this.delegatesToAddPermission.Count > 0 || this.delegatesToRemovePermission.Count > 0)
         {
             this.DataObject.GrantSendOnBehalfTo = this.Instance.ResourceDelegates;
             base.DataSession.Save(this.DataObject);
         }
     }
 }
Esempio n. 3
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);
                        }
                    }
                }
            }
        }