C# 是否为SQL Server Reporting Service(SSRS)web服务提供域凭据?

C# 是否为SQL Server Reporting Service(SSRS)web服务提供域凭据?,c#,web-services,reporting-services,unauthorized,C#,Web Services,Reporting Services,Unauthorized,我正在尝试提供特定的域凭据以访问报表服务器上的报表。如果我使用默认凭证(不提供实际的信用),它可以正常工作,因为我可以访问我的报表服务器。只要我硬编码我的凭证(并禁用默认凭证),它就会给我一个401异常(请求失败,HTTP状态为401:Unauthorized) comboBox1(显然)是一个每个服务器都可用的组合框 urlText是web服务url的文本字段 comboBox1.Items.Clear(); var rs = new ReportingSer

我正在尝试提供特定的域凭据以访问报表服务器上的报表。如果我使用默认凭证(不提供实际的信用),它可以正常工作,因为我可以访问我的报表服务器。只要我硬编码我的凭证(并禁用默认凭证),它就会给我一个401异常(请求失败,HTTP状态为401:Unauthorized)

comboBox1(显然)是一个每个服务器都可用的组合框

urlText是web服务url的文本字段

        comboBox1.Items.Clear();

        var rs = new ReportingService2005
        {
            Url = urlText.Text,
            //any of those three work
            //Credentials = System.Net.CredentialCache.DefaultCredentials,
            //Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
            UseDefaultCredentials = true

            //This doesn't work
            //Credentials = new NetworkCredential("user", "pass", "domain")
        };

        // get catalog items from the report server database
        var items = rs.ListChildren("/", true);  <------exception on this line---------

        foreach (var item in items)
        {
            if (item.Type == ItemTypeEnum.Report)
                comboBox1.Items.Add(item.Path);
        }
comboBox1.Items.Clear();
var rs=新报告服务2005
{
Url=urlText.Text,
//这三种方法中的任何一种都有效
//凭据=System.Net.CredentialCache.DefaultCredentials,
//凭据=System.Net.CredentialCache.DefaultNetworkCredentials
UseDefaultCredentials=true
//这不管用
//凭据=新网络凭据(“用户”、“通过”、“域”)
};
//从报表服务器数据库获取目录项

var items=rs.ListChildren(“/”,true);类似的问题和答案在这里:。不过,您正在使用ReportingServices名称空间生成,但我相信凭据部分是相同的或非常相似的,谢谢。ReportingServices2005是ssrs web服务参考。另一个答案似乎不是我所需要的。您是对的,另一个答案看起来应该会有帮助,但关键部分(reportViewer.ServerReport.ReportServerCredentials.ImpersonationUser=(System.Security.Principal.WindowsIdentity)user;)似乎无法使用web服务引用完成。很抱歉,我认为会这样。不过,应该有类似的情况。我会查阅服务白皮书。您还可以从类似的服务报告service2010.asmx中获取更多凭据信息(如果您有SQL 2012,则类似的服务报告适用于早期版本的SQL)。线程在这里:
<Authentication>
    <AuthenticationTypes>
        <RSWindowsNegotiate/>
    </AuthenticationTypes>
    <RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel>
    <RSWindowsExtendedProtectionScenario>Proxy</RSWindowsExtendedProtectionScenario>
    <EnableAuthPersistence>true</EnableAuthPersistence>
</Authentication>