I'm trying to figure out how to conditionally set different combinations of DeniedPermissions and AllowedPermissions based on user role:
- If a user is an admin user, I want to allow printing and downloading.
- If a user is an auditor user, I want to allow printing, but deny downloading
- If a user is NOT an admin or auditor user, I want deni.
There doesn't seem to be a way to pass variables into a method that builds the DocumentViewer for conditionally setting the allowed and denied permissions.
var documentViewer = new DocumentViewer().
If (user.IsAdmin){
documentViewer.AddAllowedPermission(DocumentViewerPermission.Print);
documentViewer.AddAllowedPermission(DocumentViewerPermission.Download);
} else if (user.IsAuditor){
documentViewer.AddAllowedPermission(DocumentViewerPermission.Print);
documentViewer.AddDeniedPermission(DocumentViewerPermission.Download);
} else {
documentViewer.AddDeniedPermission(DocumentViewerPermission.Print);
documentViewer.AddDeniedPermission(DocumentViewerPermission.Download);
}
The bitwise OR seems to indicate that I'm going to have to build numerous sets of allowed and denied permissions and maintain that forever based on new and changing user roles.
Thoughts? Advice?
Thanks in advance.