您好我的SSRS自定义身份验证有问题。我按照说明here但报告服务器收到此错误:
LogonUser未收到授权凭证
我正在调试代码,我发现错误在方法ReportServerProxy.GetWebResponse中:
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
Utilities.RelayCookieToClient(authCookie);
}
return response;
}
我将此代码称为:
private void InitializeComponent()
{
ReportServerProxy server = new ReportServerProxy();
string reportServer = ConfigurationManager.AppSettings["ReportServer"];
string instanceName = ConfigurationManager.AppSettings["ReportServerInstance"]; //this constants are null
// Get the server URL from the report server using WMI
server.Url = AuthenticationUtilities.GetReportServerUrl("PC065", "MSSQLSERVER");
server.LogonUser("user", "123", null); //throw exception
}
也许这是我的代码没有看到配置文件的第一个问题,这是null:
string reportServer = ConfigurationManager.AppSettings["ReportServer"];
string instanceName = ConfigurationManager.AppSettings["ReportServerInstance"];
这是我的配置
的ReportServer \ web.config中:
<authentication mode="Forms">
<forms loginUrl="Pages\Logon.aspx" name="sqlAuthCookie" timeout="60" path="/"></forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<identity impersonate="false" />
的ReportServer \ rsreportserver.config:
<Authentication>
<AuthenticationTypes>
<Custom />
</AuthenticationTypes>
<RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel>
<RSWindowsExtendedProtectionScenario>Proxy</RSWindowsExtendedProtectionScenario>
<EnableAuthPersistence>true</EnableAuthPersistence>
</Authentication>
<UI>
<CustomAuthenticationUI>
<loginUrl>/Pages/UILogon.aspx</loginUrl>
<UseSSL>True</UseSSL>
</CustomAuthenticationUI>
<ReportServerUrl>http://localhost/ReportServer</ReportServerUrl>
</UI>
<Security>
<Extension Name="Forms" Type="Microsoft.Samples.ReportingServices.CustomSecurity.Authorization, Microsoft.Samples.ReportingServices.CustomSecurity">
<Configuration>
<AdminConfiguration>
<UserName>username</UserName>
</AdminConfiguration>
</Configuration>
</Extension>
</Security>
<Authentication>
<Extension Name="Forms" Type="Microsoft.Samples.ReportingServices.CustomSecurity.AuthenticationExtension, Microsoft.Samples.ReportingServices.CustomSecurity"/>
</Authentication>
ReportManager \ web.config中:
<appSettings>
<add key="ReportServer" value="PC065" />
<add key="ReportServerInstance" value="MSSQLSERVER"/>
</appSettings>
请帮帮我。我解决了这个问题很长一段时间。我的SQL Server版本是:
Microsoft SQL Server 2008 R2(SP3-OD)(KB3144114) - 10.50.6542.0(X64)2016年2月22日18:07:23版权所有(c)Microsoft Corporation在Windows NT 6.1上的标准版(64位)(Build 7601:Service Pack 1)(管理程序)
答案 0 :(得分:0)
我认为身份验证的问题在于此代码,因为authCookie为null:
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
Utilities.RelayCookieToClient(authCookie);
}
return response;
}