Managing Reports for Other Users and User Roles in Admin Mode

dotnet Report Builder allows Admins or Developers to easily create and manage Reports for other Users and set rights as well. You can setup a Report to only show for certain users, and also control if they get view only access or if they can edit/update it as well. You can also setup the same for User Roles, instead of just users.

When initializing dotnet Report, developers can pass all the users and roles list to the Reporting System, in addition to specifying the current user and their role. The default code tries to populate the Users and Roles using the standard MVC Web Security. If it’s not being used, then the developer can populate it manually. The code is in DotNetReport/index.html file:

@if (Roles.Enabled && User.Identity.IsAuthenticated) { 
   // try to populate roles using MVC web security if available
   @Html.Raw("userId: '" + User.Identity.Name + "',\n")
   @Html.Raw("users: [" + string.Join(",", Roles.GetAllRoles()
      .Select(x => string.Join(",", Roles.GetUsersInRole(x)))) + "],\n")
   @Html.Raw("userRoles: [" + string.Join(",", Roles.GetAllRoles()
      .Select(x => string.Format("'{0}'", x))) + "],\n")
   @Html.Raw("currentUserRole: [" + string.Join(", ", Roles
      .GetRolesForUser(User.Identity.Name)
      .Select(x => string.Format("'{0}'", x))) + "]\n")
 } else
 {
   // You can pass your current authenticated user id here 
   //   to track their reports and folders
   @Html.Raw("userId: '',\n") , // all reports can be viewed/managed if blank
   @Html.Raw("users: [],\n") // Populate all your application's user
   @Html.Raw("userRoles: ['Admin', 'Normal'],\n") // Populate all your application's user roles
   @Html.Raw("currentUserRole: ['Admin']\n") // Populate your current authenticated user's roles
 }

If the current user has Admin access, or a specific user is not assigned, dotnet Report allows you to activate “Admin Mode”:

 

Once “Admin Mode” is turned on, the list of all Reports for any user or role for the account will be available, and each Report will show how the current user and roles access is setup for the Report.

When you Edit or Create a Report in Admin Mode, you will be able to setup View and Manage rights for the Report:

 

When you turn off Admin Mode, only the reports the current user or the current user role has access to will show up.

Note: This is an optional feature that is not required, and is activated only if you specify Users and Roles at initialization. If you don’t apply access restrictions by a user or role, the report will be shown to all users by default. Also, if the current UserId is empty at initialization, all reports can be edited or deleted.

 

Leave a Reply

Your email address will not be published. Required fields are marked *