1

UPDATE

So, the reason why I tried to do ajax is the login form, which display when user open SSRS reports in the application. I have frame with reports (two different servers) and want make authorization invisible for user in application. For the first server - kuybit I have it, but the SSRS has the other auth form type and I have a trouble with it. If anybody knows better way, except ajax request it can helps.

OLD Q VERSION

I have application and microsoft server for BI report in iframe. I am trying send cross domain ajax request to report server and it doesn't work, because the first request for cross domain is OPTIONS. And my ajax has never worked. My ajax request:

var path = route + ':444/ReportServer/Pages/ReportViewer.aspx' + reportName + '&rs:Command=Render&rc:stylesheet=HideToolBar';
 $.ajax({
   url: path,
   type: 'GET',
   headers: {
      'Access-Control-Allow-Headers': 'Authorization',
      'Content-Type':'application/xml',
      'Authorization' : 'Basic ' + btoa(ssrs_login + ":" + ssrs_password)}
 }).success(function (data) {
     //todo smth
 });

Can anybody helps, please.

Nataly
  • 15
  • 1
  • 8
  • 2
    Does the server accept cross domain requests? Is CORS enabled on the server? What is the response you get from the server? – Adam D Aug 22 '18 at 18:14
  • @AdamD I have '401 unauthorized' response. About server - not sure after your question – Nataly Aug 22 '18 at 18:24
  • [CORS is Cross-Origin Resource Sharing](https://enable-cors.org/index.html) can be determined by looking at the headers. You can view those headers in chrome or internet explorer by looking at the the developer tools. I don't know much about SSRS, but based on this stackoverflow post [Enable CORS for Reporting Services](https://stackoverflow.com/questions/32326892/enable-cors-for-reporting-services) it seems like SSRS isn't API friendly. – jeffld Aug 22 '18 at 19:16
  • @jeffld Thanx. Maybe you know how I can solve it (see updated question) without cors ajax? – Nataly Aug 23 '18 at 10:56
  • I think maybe identity impersonation might be a possibility. This [post](https://stackoverflow.com/questions/18772349/how-to-implement-user-impersonation-in-reporting-services) has some info about impersonation for reporting services. – jeffld Aug 23 '18 at 13:49

1 Answers1

0

To enable CORS to SSRS:

  1. Open Microsoft SQL Server Studio
  2. Connect to Server -> Server type (set it to "Reporting Services")
  3. Login -> right click on the server root node -> Properties
  4. From the Server Properties window select, "Advanced" find "User-defined" and under this heading all CORS settings.

Set - AccessControlAllowCredentials to true <- to allow passing cookies - AccessControlAllowOrigin to the URL of your other server so the OPTION request can pass

et3rnal
  • 322
  • 4
  • 17
  • Is there a way to add these settings if they're not listed in that section? – strattonn Mar 09 '22 at 03:45
  • 1
    There might be away, I read about it somewhere I think it was referring to an older version but it never worked for me, Just make sure you select Reporting before you connect they will be there – et3rnal Mar 09 '22 at 07:38