Code Access Security and OLEDB

Microsoft have devised a very sophisticated security model for .NET applications to allow fine grained control of permissions.  In theory you can grant an application just the permissions that it needs.

OleDbPermission Class is a good example of how well this has been implemented in practice.


This class is intended for future use when the .NET Framework Data Provider for OLE DB is enabled for partial trust scenarios. The .NET Framework Data Provider for OLE DB currently requires FullTrust permission. Currently, using the OleDbPermission class has no effect. For more information, see Code Access Security and ADO.NET.

This is the documentation for the 1.1, 2, 3 and 3.5 frameworks.
This would imply that there is no priority to getting this fixed.

This is a rather key ommision as this is the key component for accessing non-microsoft databases from, say Sharepoint.
I found this while trying to get the BDC to read data from a Sybase database via OLEDB.
At the time of writing (using Sharepoint 2007 which is the latest released version of the product) the tool support for the BDC is sadly lacking.  The tools that have been released do not cope with the OleDb option and the error results are far from impressive.  In order to prove that the problem is in the BDC and not a missing driver I have written a small web part that calls Syabase via OleDb using a connection string.  On my dev box (which I did not know was set to be permissive) this works just fine.  On a UAT environment (natuarlly locked down) the same web part fails.  It would appear that I need to give the web part full trust to allow me to call the database!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s