Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Customize User Access Denied Dialog

Is there a capability of customizing or creating a custom User Access denied dialog? We want to send unauthorized users to a specific corporate page or custom link.
  • hackcrr's avatar
    1 year ago

    Anonymous 

    Currently, the built-in features do not provide the functionality you describe directly, but you can check out the following posts with the same doubts to find a way to get closer to your idea:

    https://forum.enterprisedna.co/t/how-to-create-a-custom-popup-message-when-access-is-denied-to-a-reports-with-row-level-security/22387

    If you do not consider using the functions provided by the report server directly, you can use the following methods to implement your idea, provided that you are familiar with JavaScript or configure the reverse proxy of the website:

    JavaScript in a Custom Front-End Portal:

    If you have a custom front-end portal that users access before reaching Power BI Report Server, you can implement JavaScript to handle the redirection for unauthorized users. This approach assumes that your users log in via this custom portal.

    Detecting 401 Unauthorized Error and Redirecting:

    fetch('http://your-pbi-server/report')
      .then(response => {
        if (response.status === 401) {
          // Redirect to custom access denied page
          window.location.href = 'http://your-corporate-page.com/access-denied';
        } else {
          // Proceed with normal operations
          return response.text();
        }
      })
      .then(data => {
        // Process and display report data
        document.getElementById('report-container').innerHTML = data;
      })
      .catch(error => {
        console.error('Error fetching report:', error);
      });
    

    Reverse Proxy Setup:

    Using a reverse proxy allows you to intercept and modify HTTP requests and responses before they reach Power BI Report Server. This approach works well in environments where you want a centralized solution.

    If you are using Nginx as your reverse proxy, you can configure it to redirect users who receive a 401 Unauthorized response.

    Install and configure Nginx on your server.

    Edit your Nginx configuration file (e.g., /etc/nginx/sites-available/default) to include the following:

    server {
        listen 80;
        server_name your-pbi-server.com;
    
        location / {
            proxy_pass http://localhost:8080; # Your Power BI Report Server address
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
    
            # Intercept 401 responses and redirect to a custom page
            error_page 401 = @access_denied;
        }
    
        location @access_denied {
            return 302 http://your-corporate-page.com/access-denied;
        }
    }
    

    Restart Nginx to apply the changes:

    sudo systemctl restart nginx
    

     

    If I have answered your question, please mark my reply as solution and kudos to this post, thank you!