Run all SSRS reports through a single report user that ignores the user's own domain

I have the following code that returns reports from my SSRS server, after which I then save the paths to each individual list, which allows users to run them from the application. The following works great.

NetworkCredential serviceCredentials = new NetworkCredential()
{
     UserName = username,
     SecurePassword = EncryptionManager.DecryptToSecureString(password),
     Domain = domain
};

reports = new ObservableCollection<object>(reportsManager.FindReports(reportsWebService, reportsFolderName, serviceCredentials));



//FindReports
ReportingService2005 rs = new ReportingService2005();
rs.Url = reportsWebService;
rs.Credentials = serviceCredentials;

CatalogItem[] catalogItems = rs.ListChildren(@"/" + reportsFolderName, false);

However, the problem is when the user selects a report to view, he shows the following error:

The permissions granted to the user are insufficient to perform this operation.

I understand that a quick solution to this would be to add the user domain to the security section of the report server, however this does not work.

, , , , ?

Windows.

: Reporting WinForms.

+4
1

Windows Forms

windows forms System.Net.NetworkCredential ServerReport.ReportServerCredentials.NetworkCredentials ReportViewer. , :

reportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials =
    new System.Net.NetworkCredential("username", "password", "domain");

-

- . Web Forms ReportViewer IReportServerCredentials. ServerReport.ReportServerCredentials ReportViewer. , .

. , :

using System;
using System.Net;
using System.Security.Principal;
using Microsoft.Reporting.WebForms;
[Serializable]
public sealed class MyReportServerCredentials : IReportServerCredentials
{
    public WindowsIdentity ImpersonationUser { get { return null; } }
    public ICredentials NetworkCredentials
    {
        get
        {
            return new NetworkCredential("username", "password", "domain");
        }
    }
    public bool GetFormsCredentials(out Cookie authCookie, out string userName,
        out string password, out string authority)
    {
        authCookie = null;
        userName = password = authority = null;
        return false;
    }
}

Page_Load :

protected void Page_Load(object sender, EventArgs e)
{
    if(!IsPostBack)
        this.ReportViewer1.ServerReport.ReportServerCredentials = 
            new Sample.MyReportServerCredentials();
}

, ReportViewer , IReportServerConnection. appsettings , :

<add key="ReportViewerServerConnection" value="YourNameSpace.YourClass, YourAssemply" />

Page_Load, . .

+3

Source: https://habr.com/ru/post/1661223/


All Articles