我有一个ASP.NET(v2.0)Web应用程序,它使用对SQL Server Reporting Services 208 R2实例的引用(使用ReportService2010.asmx服务端点)。 Web应用程序托管在ServerA上,Reporting Services实例托管在ServerB上。 ServerA运行的是Windows Server 2003(IIS6),ServerB运行的是Windows Server 2008 R2。
Web应用程序配置为使用Windows身份验证并启用模拟。当我在ServerA上本地运行Web应用程序(使用远程桌面连接)时,它可以工作,但是当我从台式机(Windows XP)运行时,我收到以下错误:
服务器错误。请求失败,HTTP状态为401:未经授权。描述: 在执行当前期间发生了未处理的异常 网络请求。请查看堆栈跟踪以获取更多信息 错误以及它在代码中的起源。
异常详细信息:System.Net.WebException:请求失败 HTTP状态401:未经授权。
来源错误:
执行期间生成了未处理的异常 当前的网络请求。有关的来源和位置的信息 可以使用下面的异常堆栈跟踪来识别异常。
堆栈追踪:
[WebException:请求失败,HTTP状态为401:未经授权。] System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage 消息,WebResponse响应,流responseStream,布尔值 asyncCall)+431289
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(字符串 methodName,Object []参数)+204
ReportingServices.ReportingService2010.ListChildren(String ItemPath, Boolean递归)+81 Default.LoadReports()+54
Default.Page_Load(Object sender,EventArgs e)+224
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,Object o,对象t,EventArgs e)+14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)+35 System.Web.UI.Control.OnLoad(EventArgs e)+99
System.Web.UI.Control.LoadRecursive()+50
System.Web.UI.Page.ProcessRequestMain(布尔 includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) 627
版本信息:Microsoft .NET Framework版本:2.0.50727.3634; ASP.NET版本:2.0.50727.3634
LoadReports方法:
private void LoadReports()
{
ReportingService2010 rService = new ReportingService2010();
rService.Credentials = System.Net.CredentialCache.DefaultCredentials;
CatalogItem[] catalogItems;
catalogItems = rService.ListChildren(ReportPath, true);
BuildTree(catalogItems);
}
ServerA上的应用程序事件日志包含以下其他详细信息:
Event Type: Warning
Event Source: ASP.NET 2.0.50727.0
Event Category: Web Event
Event ID: 1309
Date: 28/06/2012
Time: 11:25:16
User: N/A
Computer: ServerA
Description:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 28/06/2012 11:25:16
Event time (UTC): 28/06/2012 10:25:16
Event ID: 11f6bec3e91045229f4e34a5d2de78e9
Event sequence: 4
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/Root/MyWebApp-1-129853527126453497
Trust level: Full
Application Virtual Path: /MyWebApp
Application Path: c:\inetpub\wwwroot\MyWebApp\
Machine name: ServerA
Process information:
Process ID: 1180
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception information:
Exception type: WebException
Exception message: The request failed with HTTP status 401: Unauthorized.
Request information:
Request URL: http://ServerA/MyWebApp/Default.aspx
Request path: /MyWebApp/Default.aspx
User host address: 192.168.100.130
User: DOMAIN\mylogin
Is authenticated: True
Authentication Type: Negotiate
Thread account name: NT AUTHORITY\NETWORK SERVICE
Thread information:
Thread ID: 1
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace:
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at ReportingServices.ReportingService2010.ListChildren(String ItemPath, Boolean Recursive)
at Default.LoadReports()
at Default.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHe.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
答案 0 :(得分:4)
使用Active Directory用户和计算机Microsoft管理控制台(开始>运行>“dsa.msc”),打开ServerA服务器条目的属性。在“委派”下,选择信任此计算机以委派任何服务(仅限Kerberos)。
使用以下命令注册服务主体名称(SPN):
setspn -S http/ServerB ReportingServicesServiceAccount
setspn -S http/ServerB.domain.com ReportingServicesServiceAccount
其中ReportingServicesServiceAccount
是用于在ServerB上运行Reporting Services服务的服务帐户。