Friday, February 24, 2012

Custom Code Error

I'm receiving an #ERROR where I've call a function created in the custom code section. The reports works fine in development debug mode, only errors after deploying to SSRS. Note the custom code contain code that access the database using the SYSTEMS.DATA.SQLCLIENT namespace classes. Is there a security access problem in SSRS reports server?I had the same problem..
I've created a custom assembly for that..

Imports System.Data.OracleClient
Imports System.IO

'Important to get it work within a report
<Assembly: System.Security.AllowPartiallyTrustedCallers()>

Public Class DB

'Write do Database
Public Shared Function writeBack(ByVal FehlerID As Integer) As String
Dim perm As New OraclePermission(Security.Permissions.PermissionState.Unrestricted)
perm.Assert()

Dim conn As New OracleConnection
conn.ConnectionString = "Data Source=DB;Unicode=True;user=scott;password=tiger;"
conn.Open()
Dim oracleCommand1 As New System.Data.OracleClient.OracleCommand
oracleCommand1.Connection = conn
oracleCommand1.CommandText = "update ben_mailversand set gesendet=1 where fehlerid=" & FehlerID
oracleCommand1.ExecuteScalar()
conn.Close()
writeBack = oracleCommand1.CommandText
End Function
End Class

Thats not exactly brilliant but I found no other way..

in rspolicy.conf you have to set this assembly to fulltrust..
|||

There is a reason why you will need to assert FullTrust permissions in the OracleClient case: If you read the MSDN documentation for the OraclePermission class and the SqlClientPermission class and compare them, you will notice the following statement:
"This class [i.e. OraclePermission] is intended for future use when the .NET
Framework Data Provider for Oracle is enabled for partial trust scenarios.
The provider currently requires FullTrust permission."
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataoracleclientoraclepermissionclasstopic.asp

Note: The managed provider for SQL Server is enabled for partial trust scenarios, therefore it
is sufficient (and advisable) to just assert the SqlClientPermission when using it in custom assemblies.

-- Robert

|||

Thanks for your post, it led me in the right direction. I struggled for awhile but I've finally gotten it to work.

These are the items that took me awhile to figure out:

1. Placement of custom assemby on ReportsServer:

Must be placed in this directory "prior" to deploying report.

C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\bin

2. rssrpolicy.config FullTrust entry:

There are two way to enter this for signed or unsigned assemblies, you need to enter the correct method.

Thanks again,

Mike

No comments:

Post a Comment