首页 > 解决方案 > Crystal Reports 中的模拟

问题描述

我一直在尝试更新与 Crystal Reports 交互的 WCF 项目,以使其通过 Windows 身份验证连接到 MS SQL Server。它是一个 WCF 项目,但作为 Windows 服务而不是通过 IIS 运行。

我正在使用SimpleImpersonation来执行模拟步骤。本质上,如果传入的 SOAP 请求中提供了正确的值,包括 IntegratedSecurity=true,它会模拟另一个用户并尝试使用 IntegratedSecurity 登录。

我的代码看起来像这样:

using (Impersonation.LogonUser(domain, username, password, LogonType.NewCredentials)) {
    reportDocument.Execute();
}

我知道模拟是有效的,因为我System.Security.Principal.WindowsIdentity.GetCurrent().Name在声明之前和之后都打印了,using并且看到用户名在using.

我已经尝试了每个不同LogonType的 s,但我得到了相同的结果。

Database logon failed从调用中收到一条错误消息Execute()但是,如果我以我试图模拟的帐户启动 Web 服务,我就能够正确连接到数据库。

我的问题是:

标签: .netwindowswcfcrystal-reportsimpersonation

解决方案


事实证明,我的问题不在于模仿,而在于数据库驱动程序。我在https://archive.sap.com/discussions/thread/3621859上找到了一条评论:

请检查服务器中是否存在“sqlncli.dll”文件?..不确定这个文件或其他一些dll。

我在服务器上安装了https://www.microsoft.com/en-us/download/confirmation.aspx?id=50402并且我的代码开始自动运行。

我希望从 Crystal Reports 返回的错误消息更具描述性,但是哦,好吧,至少它可以正常工作。


推荐阅读