A community member has associated this post with a similar question:
SSRS Reporting Server 2019 CustomSecurity extension issue:RequestContext In GetUserInfo method coming blank while accessing from client Application

Only moderators can edit this content.

SSRS Sql Server Reporting Server Custom Security 2019 exception in Windows Server 2019

Guru dath 0 Reputation points
2023-02-03T12:56:39.3966667+00:00
Hello Friends

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

SSRS report works fine from winforms vb.net code in previous version of SQL Server (2016, 2014 and 2012) but not in 2019

Running report using Vb.net 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 vb.net and getting response from SSRS server. 

VB.NET Code
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;
       }

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,787 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,561 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 26,111 Reputation points Microsoft Vendor
    2023-02-08T06:07:54.54+00:00

    Hi @Guru dath ,

    To solve the error Custom security exception is not enabled, please check the following link.

    There are differents between SQL Server Reporting Services (2017 and later) and SQL Server Reporting Services (2016).

    How to install custom security extensions

    Best Regards.
    Jiachen Li
    ----------
    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments