SSRS 2008 Security permissions for custom assembly connectiong to database
I am experiencing a similar problem to that detailed by DeveloperGuy last April - how I wish that post had been answered successfully!.I have a very simple custom assembly that connects to a local SQL Server database. When I try to render the report I get multiple error messages where I have tried to reference the dll:
Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
I have been trying to fix this for days and, like DeveloperGuy, can't find much in the way of examples that is up to date.I have this code in the single method to assert the permissions:
Dim
Permission As New System.Data.SqlClient.SqlClientPermission(System.Security.Permissions.PermissionState.Unrestricted)
Permission.Assert()I have referenced the dll in the report and placed it into the C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportServer\bin and theC:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies directories.I have placed the following into the rsPreviewPolicy.config and the rssrvpolicy.config files:<CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="TestPermissions" Name="TestCodeGroup" Description=""> <IMembershipCondition class="UrlMembershipCondition" version="1" Url="C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportServer\bin\MyLibrary.dll" /> </CodeGroup>This is at the end of the Code Groups section. i have also added:<PermissionSet class="NamedPermissionSet" version="1" Name="TestPermissions"> <IPermission class="SecurityPermission" version="1" Flags="Assertion, Execution"/> <IPermission class="SqlClientPermission" version="1" Unrestricted="true"/> </PermissionSet>This is at the end of the permission sets sectionI don't know what else to do, and this is just in the IDE, I haven't even tried it on the report server! - please can someone help me.Thanks
March 11th, 2010 4:24pm
Hi Rachel J,We also need to copy the assemly to C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportManager\Bin, and add the code group in rsmgrpolicy.config like this:<CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="TestPermissions" Name="TestCodeGroup" Description=""> <IMembershipCondition class="UrlMembershipCondition" version="1" Url="C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportManager\bin\MyLibrary.dll" /> </CodeGroup>Now, we should be able to call the assembly from Reporting Services.Furthermore, please also assign permissions for CodeGroup "This code group grants default permissions for code in report expressions and Code element." to execute the code.If you have any more questions, please feel free to ask.Thanks,Jin ChenJin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
March 15th, 2010 12:31pm
I have made the changes as suggested to no avail, still getting the same error.I am unsure as to what you mean exactly by "assign permissions for CodeGroup "This code group grants default permissions for code in report expressions and Code element." to execute the code." Could you clarify?I find now that although in Visual Studio I get the security permissions error, when I preview the report via Debug or by uploading to my local Reportmanager, it all works.I thought this meant that the entry in the RsPreviewPolicy.config file was not quite right, but I can't see anything wrong with it - could you help?
March 15th, 2010 9:24pm
Hi Rachel,In RSPreviewPolicy.config file, please replace the URL with C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\MyLibrary.dllThe expected CodeGroup is:<CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="TestPermissions" Name="TestCodeGroup" Description=""> <IMembershipCondition class="UrlMembershipCondition" version="1" Url="C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\MyLibrary.dll" /> </CodeGroup>For CodeGroup "This code group grants default permissions for code in report expressions and Code element.", we can find it from RSPreviewPolicy.config, rsmgrpolicy.config or rssrvpolicy.config: <CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="FullTrust" Name="Report_Expressions_Default_Permissions" Description="This code group grants default permissions for code in report expressions and Code element. "> <IMembershipCondition class="StrongNameMembershipCondition" version="1" PublicKeyBlob="0024000004800000940000000602000000240000525341310004000001000100512C8E872E28569E733BCB123794DAB55111A0570B3B3D4DE3794153DEA5EFB7C3FEA9F2D8236CFF320C4FD0EAD5F677880BF6C181F296C751C5F6E65B04D3834C02F792FEE0FE452915D44AFE74A0C27E0D8E4B8D04EC52A8E281E01FF47E7D694E6C7275A09AFCBFD8CC82705A06B20FD6EF61EBBA6873E29C8C0F2CAEDDA2" /> </CodeGroup>Please feel free to ask, if you have any more questions.Thanks,Jin ChenJin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
March 18th, 2010 12:05pm
Hi Jin,
I am facing same challenge that Rachle J had: I have a simple dll that parses RTF string to freetext, and when I tried to call the
function in the DLL from a SSRS report, I got error:
"Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed".
I modified the RSPreviewPolicy.config as you recommended , but the error still doesn't go away. IS there anything else I need to do to fix the issue besides modifing the config file?
Following are the changes I made inside RSPreviewPolicy.config:
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="Report_Expressions_Default_Permissions"
Description="This code group grants default permissions for code in report
expressions and Code element. ">
<IMembershipCondition
class="StrongNameMembershipCondition"
version="1"
PublicKeyBlob="0024000004800000940000000602000000240000525341310004000001000100512C8E872E28569E733BCB123794DAB55111A0570B3B3D4DE3794153DEA5EFB7C3FEA9F2D8236CFF320C4FD0EAD5F677880BF6C181F296C751C5F6E65B04D3834C02F792FEE0FE452915D44AFE74A0C27E0D8E4B8D04EC52A8E281E01FF47E7D694E6C7275A09AFCBFD8CC82705A06B20FD6EF61EBBA6873E29C8C0F2CAEDDA2"
/>
</CodeGroup>
<CodeGroup class="UnionCodeGroup"
version="1"
PermissionSetName="TestPermissions"
Name="TestCodeGroup"
Description="">
<IMembershipCondition class="UrlMembershipCondition"
version="1"
Url="C:\Program Files\Microsoft
Visual Studio 9.0\Common7\IDE\PrivateAssemblies\ParseRTF.dll"/>
</CodeGroup>
Thanks in advance for help!
January 7th, 2011 4:49pm