Click here to Skip to main content
15,906,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I am facing a problem with respect to SSRS(Sql Server Reporting Server) 2019 Custom security Exception in windows server 2019.

Running report using Winforms source code and sending WebRequest to SSRS server with necessary details like server url,username ,password, DBName etc, with response back using webResponse need to get authentication cookie for the User

Getting error as sqlAuthCookie is null, also getting an error as Custom security exception is not enabled

Anything solution/help would be highly appreciated

Attached the Piece of code which sending from and getting response from SSRS server.

Protected Overrides Function GetWebResponse(ByVal request As WebRequest) As WebResponse
        Dim response As WebResponse = MyBase.GetWebResponse(request)
        Dim cookieName As String = response.Headers("RSAuthenticationHeader")
        ' If the response contains an auth header, store the cookie
        If Not (cookieName Is Nothing) Then
            Dim webResponse As HttpWebResponse = CType(response, HttpWebResponse)
            Dim authCookie As Cookie = webResponse.Cookies(cookieName)
            ' If the auth cookie is null, throw an exception
            If authCookie Is Nothing Then
                Throw New Exception("Unable to generate report - the Reporting Services Custom Security Extension is expected to be enabled in XB")
            End If
            ' otherwise save it for this request
            Me.AuthCookie = authCookie
            ' and send it to the client
        End If
        Return response

    End Function

SSRS service code
//adding new GetUserInfo method for IAuthenticationExtension2
       public void GetUserInfo(IRSRequestContext requestContext, out IIdentity userIdentity, out IntPtr userId)
           userIdentity = null;
           if (requestContext.User != null)
               userIdentity = requestContext.User;

           // initialize a pointer to the current user id to zero
           userId = IntPtr.Zero;

What I have tried:

1.Web.Config files checked whether details has been passed correctly
Updated 3-Feb-23 2:39am
Andre Oosthuizen 3-Feb-23 8:43am    
As per MS - If you're on hosted env., then <authentication mode="Windows"> might not work correctly. I'm guessing you're under medium trust and you can do a lot under medium trust, but not everything.

Difficult when you don't have any source code that generates the error, but modify your web.config until you don't hit the errors, then check up on how to get it working under your trust level.
Member 12259080 27-Feb-23 22:35pm    
Hi @Andre Oosthuizen

Thanks for your comment, also bringing to your notice that, already installed custom security exception, unfortunately still authentication error persisting.

For more clarity on the problem statement, here by requesting to go through another forum link which I had created.

Thanks for your support and appreciate your time and patience.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900