internal override bool InternalProcessPermissions(Folder folder) { PermissionSet permissionSet = folder.GetPermissionSet(); Permission targetPermission = base.GetTargetPermission(permissionSet); if (targetPermission == null) { throw new UserNotFoundInPermissionEntryException(base.MailboxFolderUserId.ToString()); } MemberRights memberRights = (MemberRights)MailboxFolderAccessRight.CalculateMemberRights(this.AccessRights, folder.ClassName == "IPF.Appointment"); if (targetPermission.MemberRights == memberRights) { this.WriteWarning(Strings.WarningMailboxFolderPermissionUnchanged(this.DataObject.Identity.ToString())); return(false); } try { targetPermission.MemberRights = memberRights; } catch (ArgumentOutOfRangeException exception) { base.WriteError(exception, (ErrorCategory)1003, this.Identity); } return(true); }
internal override bool InternalProcessPermissions(Folder folder) { MemberRights memberRights = (MemberRights)MailboxFolderAccessRight.CalculateMemberRights(this.AccessRights, folder.ClassName == "IPF.Appointment"); PermissionSet permissionSet = folder.GetPermissionSet(); Permission permission = null; try { if (base.MailboxFolderUserId.UserType == MailboxFolderUserId.MailboxFolderUserType.Default) { if (permissionSet.DefaultPermission != null && permissionSet.DefaultPermission.MemberRights != MemberRights.None) { throw new UserAlreadyExistsInPermissionEntryException(base.MailboxFolderUserId.ToString()); } permissionSet.SetDefaultPermission(memberRights); permission = permissionSet.DefaultPermission; } else if (base.MailboxFolderUserId.UserType == MailboxFolderUserId.MailboxFolderUserType.Anonymous) { if (permissionSet.AnonymousPermission != null && permissionSet.AnonymousPermission.MemberRights != MemberRights.None) { throw new UserAlreadyExistsInPermissionEntryException(base.MailboxFolderUserId.ToString()); } permissionSet.SetAnonymousPermission(memberRights); permission = permissionSet.AnonymousPermission; } else { PermissionSecurityPrincipal securityPrincipal = base.MailboxFolderUserId.ToSecurityPrincipal(); Permission entry = permissionSet.GetEntry(securityPrincipal); if (entry != null) { throw new UserAlreadyExistsInPermissionEntryException(base.MailboxFolderUserId.ToString()); } permission = permissionSet.AddEntry(securityPrincipal, memberRights); } } catch (ArgumentOutOfRangeException exception) { base.WriteError(exception, (ErrorCategory)1003, this.Identity); return(false); } base.WriteObject(MailboxFolderPermission.FromXsoPermission(folder.DisplayName, permission, this.ResolvedObjectId)); return(true); }