Example #1
0
        private DetailLevelEnumType?GetFreeBusyAccessLevel(PermissionSecurityPrincipal targetPrincipal)
        {
            DetailLevelEnumType?     result = null;
            CalendarFolderPermission calendarFolderPermission = null;

            using (CalendarFolder calendarFolder = (CalendarFolder)this.GetCalendarFolder())
            {
                CalendarFolderPermissionSet permissionSet = calendarFolder.GetPermissionSet();
                calendarFolderPermission = permissionSet.GetEntry(targetPrincipal);
                if (calendarFolderPermission != null)
                {
                    if ((calendarFolderPermission.MemberRights & MemberRights.ReadAny) == MemberRights.ReadAny)
                    {
                        result = new DetailLevelEnumType?(DetailLevelEnumType.FullDetails);
                    }
                    else if (calendarFolderPermission.FreeBusyAccess == FreeBusyAccess.Details)
                    {
                        result = new DetailLevelEnumType?(DetailLevelEnumType.LimitedDetails);
                    }
                    else if (calendarFolderPermission.FreeBusyAccess == FreeBusyAccess.Basic)
                    {
                        result = new DetailLevelEnumType?(DetailLevelEnumType.AvailabilityOnly);
                    }
                }
            }
            if (result == null)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <SmtpAddress, string>((long)this.GetHashCode(), "ReachUser ={0}, Not authroized to view published calendar.  Permissions:{1}", targetPrincipal.ExternalUser.OriginalSmtpAddress, (calendarFolderPermission == null) ? "No permission" : calendarFolderPermission.MemberRights.ToString());
            }
            return(result);
        }
Example #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);
         }
     }
 }