Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# asp.net webapp连接到ssrs 2012_C#_Asp.net_Reporting Services - Fatal编程技术网

C# asp.net webapp连接到ssrs 2012

C# asp.net webapp连接到ssrs 2012,c#,asp.net,reporting-services,C#,Asp.net,Reporting Services,在我深入讨论这个问题之前,我想概述一下我正在尝试做什么。我们正在尝试使用Windows Auth将我们的webapp连接到2012 SSRS实例,并获得未经授权的401证书 然而,如果我浏览到我尝试执行服务的URL,并使用我在LogonUser方法中传递的凭据,我就可以很好地获得wsdl。因此,我认为问题出在代码端,而不是服务器端。(浏览和webapp测试都发生在我的机器上,所以我不认为这是一个域问题或类似的问题) 好的,一些细节 目前,我们有一个旧的2008实例,它使用了一些我们想要远离的自定

在我深入讨论这个问题之前,我想概述一下我正在尝试做什么。我们正在尝试使用Windows Auth将我们的webapp连接到2012 SSRS实例,并获得未经授权的401证书

然而,如果我浏览到我尝试执行服务的URL,并使用我在LogonUser方法中传递的凭据,我就可以很好地获得wsdl。因此,我认为问题出在代码端,而不是服务器端。(浏览和webapp测试都发生在我的机器上,所以我不认为这是一个域问题或类似的问题)

好的,一些细节

目前,我们有一个旧的2008实例,它使用了一些我们想要远离的自定义身份验证。但是,我仍然认为我可以使用它作为连接到2012执行服务(或者我认为是这样)的模型,只需使用WindowsAuth凭据即可

我们的旧模型有一个对服务的web引用,并且有一个类扩展了该引用。这个类实现了GetWebRequest和GetWebResponse,就像我认为的那样。因此,我获得了对2012执行服务的web引用,并设置了一个类似的代理类,并对其进行了扩展

public class ReportExecutionService2012Proxy : ReportExecution2012.ReportExecutionService
{
    /// <summary>
    /// Override the GetWebRequest method to attach the auth cookie.
    /// </summary>
    /// <param name="uri"></param>
    /// <returns></returns>
    protected override WebRequest GetWebRequest(Uri uri)
    {
        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
        request.CookieContainer = new CookieContainer(); ;
        // if the client already has an auth cookie
        // place it in the request's cookie container
        if (AuthCookie != null)
            request.CookieContainer.Add(AuthCookie);
        request.Timeout = -1;
        request.Headers.Add("Accept-Language", HttpContext.Current.Request.Headers["Accept-Language"]);
        return request;
    }

    /// <summary>
    /// Override GetWebResponse to check for the auth cookie.
    /// </summary>
    /// <param name="request"></param>
    /// <returns></returns>
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes")]
    protected override WebResponse GetWebResponse(WebRequest request)
    {
        WebResponse response = base.GetWebResponse(request);
        string cookieName = response.Headers["RSAuthenticationHeader"];
        // If the response contains an auth header, store the cookie
        if (cookieName != null)
        {
            Utilities.CustomAuthCookieName = cookieName;
            HttpWebResponse webResponse = (HttpWebResponse)response;
            Cookie authCookie = webResponse.Cookies[cookieName];
            // If the auth cookie is null, throw an exception
            if (authCookie == null)
            {
                throw new Exception(
                    "Authorization ticket not received by LogonUser");
            }
            // otherwise save it for this request
            AuthCookie = authCookie;
            // and send it to the client
            // TCK 7/25/2011: This was causing MKO to switch auth keys and force logout. I'm not sure if I'm just
            // hitting the most obvious problem and the root problem is deeper, but this does appear to fix it.
            //Utilities.RelayCookieToClient(authCookie);
        }

        if ((response is HttpWebResponse) && ((HttpWebResponse)response).StatusCode == HttpStatusCode.InternalServerError)
        {
            var stream = new StreamReader(response.GetResponseStream());
            var content = stream.ReadToEnd();
        }
        return response;
    }

    /// <summary>
    /// Private property used to store the Auth Cookie.
    /// </summary>
    private Cookie AuthCookie
    {
        get
        {
            if (m_Authcookie == null)
                m_Authcookie = Utilities.TranslateCookie(Utilities.AuthSource.GetCookie(Utilities.CustomAuthCookieName));
            return m_Authcookie;
        }
        set
        {
            m_Authcookie = value;
        }
    }
    private Cookie m_Authcookie = null;
}
因此,我们从配置中获取服务的URL和凭据,并尝试进入服务,但没有骰子


我一直在读这方面的文章,只是对这个问题的理解不够深入。任何想法都值得赞赏。

因此,首先,当您拥有自定义安全扩展(即,不只是使用普通Windows/basic身份验证)时,您只能使用LogonUser,并且因为您使用的是自定义安全,所以只能针对SSL连接调用它

那么,您的2012实例是否有安全扩展?如果没有,只需实例化该服务,在其上设置Credentials属性,然后对其发出请求


这是我的建议,但到2012年基本保持不变。

谢谢。我的一位同事昨天下午意识到了这一点,他只是在没有自定义垃圾的服务上实现了一个“代理”,并设置了URL和凭据。似乎它是在开发环境中工作的。
    private reporting.proxy.ReportExecutionService2012Proxy _rsExec2012Proxy = null;
    public virtual reporting.proxy.ReportExecutionService2012Proxy RsExec2012Proxy
    {
        get
        {
            if (_rsExec2012Proxy == null)
            {
                _rsExec2012Proxy = new reporting.proxy.ReportExecutionService2012Proxy();

                    _rsExec2012Proxy.Url = reporting.ReportConfiguration.ReportExecutionSevice2012Url;

                    ReportServerCredentials creds =
                    new ReportServerCredentials(reporting.ReportConfiguration.ReportService2012Username,
                        reporting.ReportConfiguration.ReportService2012Password,
                        reporting.ReportConfiguration.ReportService2012Domain);
                    _rsExec2012Proxy.Credentials = creds.NetworkCredentials;




                    _rsExec2012Proxy.LogonUser(
                        reporting.ReportConfiguration.ReportService2012Username,
                        reporting.ReportConfiguration.ReportService2012Password,
                        reporting.ReportConfiguration.ReportService2012Domain); 

            }
            return _rsExec2012Proxy;
        }
    }