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.
Dim
tokenHandle
As
New
IntPtr(0)
Try
If
LogonUser(
"un"
,
"DOMAINNAME"
,
"pw"
, 2, 0, tokenHandle)
Then
Dim
newId
As
New
WindowsIdentity(tokenHandle)
Using impersonatedUser
As
WindowsImpersonationContext = newId.Impersonate()
rpt = New ReportDocument
rpt.Load(Application.StartupPath & "\Reports\appendixB.rpt")
crvPreview.ReportSource = rpt
End
Using
CloseHandle(tokenHandle)
Else
'logon failed
End
If
Catch
ex
As
Exception
'exception
End
Try
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