Saturday, August 2, 2008

Forms Authentication in SQL Server 2005 Reporting Services

Form authentication extension can be easily implemented. Here's how...
http://msdn.microsoft.com/en-us/library/ms160724.aspx


You can find all the extensions for RS2005 at http://msdn.microsoft.com/en-us/library/ms160911.aspx


So once you have sample projects then you need to compile it and get the required custom security dll.
Above output dll needs to be placed at two places.
1. <system-drive>:/<path to reportingservices>/reportserver/bin
2. <system-drive>:/<path to reportingservices>/reportmanager/bin
you also need to place two .aspx files for creating cutom interface in reporting services. These two files should be placed as following:
1. <system-drive>:/<path to reportingservices>/reportserver/logon.aspx
2. <system-drive>:/<path to reportingservices>/reportmanager/pages/UILogon.aspx
After placing above files at desired locations. We need to edit RS configuration files to make them start using our custom dll extension. These editings should be done at both ReportServer and ReportManager as follows:
Important : Dont forget to take backup of all config files before making changes. Otherwise in case of errors, RS will be corrupt and you need to re-install reporting services
- Report Server
1. rsreportserver.config
- your custom report server url should be given with instead of 'localhost':
http://EXTREME-MACHINE/ReportServer
- Authentication and Authorization should be modified as :
<Security>
<Extension Name="Forms" Type="ReportingServices.CustomSecurity.Authorization,ReportingServices.CustomSecurity" >
<Configuration>
<AdminConfiguration>
<UserName>testuser
</AdminConfiguration>
</Configuration>
</Extension>
</Security>


<Authentication>

<Extension Name="Forms" Type="ReportingServices.CustomSecurity.AuthenticationExtension, ReportingServices.CustomSecurity">
<Configuration>
<ConnectionString>server=localhost;user id=sa;password=123;database=BenmarkIS
</Configuration>
</Extension>
</Authentication>

2. rssrvpolicy.config
- Trust levels should be defined as highlighted:
class="FirstMatchCodeGroup"
version="1"
PermissionSetName="FullTrust"
Description="This code group grants MyComputer code Execution permission. ">
<IMembershipCondition
class="ZoneMembershipCondition"
version="1"
Zone="MyComputer" />
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="Microsoft_Strong_Name"
Description="This code group grants code signed with the Microsoft strong name full trust. ">
- A new Code Group should be inserted for security extenstion as given:

<CodeGroup
class="UnionCodeGroup"
version="1"
Name="SecurityExtensionCodeGroup"
Description="Code group for the sample security extension"
PermissionSetName="FullTrust">
<IMembershipCondition
class="UrlMembershipCondition"
version="1"
Url="C:\Program Files\Microsoft SQL Server\MSSQL.4\Reporting Services\ReportServer\bin\ReportingServices.CustomSecurity.dll"
/>
</CodeGroup>
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="SharePoint_Server_Strong_Name"
3. Web.config
- Following highlighted changes should be made:
<authentication mode="Forms">
<forms loginUrl="logon.aspx" name="sqlAuthCookie" timeout="60" slidingExpiration="true" path="/"></forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
<identity impersonate="false" />


- Report Manager
1. rsmgrpolicy.config
- Trust levels should be changed in rsmgrpolicy.config as highlighted
class="FirstMatchCodeGroup"
version="1"
PermissionSetName="FullTrust"
Description="This code group grants MyComputer code Execution permission. ">
<IMembershipCondition
class="ZoneMembershipCondition"
version="1"
Zone="MyComputer" />
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="Microsoft_Strong_Name"
Description="This code group grants code signed with the Microsoft strong name full trust. ">

2. RSWebApplication.config
- Basic report manager redirection to the custome made .aspx page
*Note: Use instead of 'localhost' in the ReportServerUrl
<CustomAuthenticationUI>
<loginUrl>/Pages/UILogon.aspx</loginUrl>
<UseSSL>False</UseSSL>
</CustomAuthenticationUI>
<ReportServerUrl>http://extreme-machine/ReportServer</ReportServerUrl>
</UI>

Once you are done with above changes then you need to setup IIS for anonymous access. So in the 'security' tab of 'reportserver' and 'reports' web folders, set security level as 'anonymous'.
Here you go, you are done with the settings.
:) Happy Reporting!!


No comments: