Quantcast
Viewing all articles
Browse latest Browse all 3636

Impersonation winform VB2010 unable to open the crystal report viewer

Dear all,

 

i am having the following code to impersonate the windows authentication in my winform program. The code runs well for the MS SQL Server login during runtime. But it has the problem to pass the impersonated windows login credential to crystal report viewer.

 

        DimtokenHandle AsNewIntPtr(0)

        Try

            IfLogonUser("un", "DOMAINNAME", "pw", 2, 0, tokenHandle) Then

                DimnewId AsNewWindowsIdentity(tokenHandle)

                Using impersonatedUser AsWindowsImpersonationContext = newId.Impersonate()

                   

    rpt = New ReportDocument

    rpt.Load(Application.StartupPath & "\Reports\appendixB.rpt")

    crvPreview.ReportSource = rpt

 

                EndUsing

                CloseHandle(tokenHandle)

            Else

                'logon failed

            EndIf

        Catchex AsException

            'exception

        EndTry

 

when i start the impersonate and want to open the report using crystal report viewer. It gives me the following message. I have confirmed nothing to do with the runtime. As the moment i add the PC user as a SQL server login. Then the report shown.

 

The impersonated ID during the runtime has the access to the SQL server as well. Hope someone could help

 

Image may be NSFW.
Clik here to view.
error.png


Viewing all articles
Browse latest Browse all 3636

Trending Articles