Managing User Roles in Admin Mode

Dotnet Report Builder allows Admins or Developers to easily create and manage Reports for other Users. You can easily define roles to view, edit and manage reports.

During initializing reports 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
      .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 then dotnet Report allows you to activate “Admin Mode”:


In Admin Mode, the list of all Reports for any user or role for the account will be available. 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 reports

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 *