Discussion Forum

Main >> General Web Development Discussions>> How to enable System.Data.OleDb in medium trust windows server

All Threads Register Login New Discussion
How to enable System.Data.OleDb in medium trust windows server

Thursday, January 06 2011 10:03 AM

I am setting up a shared hosting server under Windows 2003 and medium trust. By default Oledb is disabled. I?d like to allow connections via oledb to MS Access Files and for .Net connections to SQL server 2005 and above. I can?t find any good document on it

Post a Replyreply

Re:How to enable System.Data.OleDb in medium trust windows server

Thursday, January 06 2011 10:15 AM

You need to modify the medium trust config file usually located in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\ web_mediumtrust.config
It is different for MS Access and SQL 2005 server. You have two options:
First you need to have the following entry:
<SecurityClass Name="OleDbPermission" Description="System.Data.OleDb.OleDbPermission, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
Then you can:
1. Put the following entry under
<IPermission class="OleDbPermission" version="1" Unrestricted="true" />
In this case anyone can use OleDb and if users connect to MS Access then they can cross connect and read other users MS Access files if they are not password protected

2. Under <NamedPermissionSets> you can put the following:
<IPermission class="OleDbPermission" version="1" >
<add ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=$AppDir$\accessfiles\msaccess.mdb" KeyRestrictions="User ID=*;Password=*;" KeyRestrictionBehavior="AllowOnly"/>
<add ConnectionString="PROVIDER=SQLOLEDB;server=servername;Trusted_Connection=false;database=databasename;uid=username;pwd=password" KeyRestrictions="" KeyRestrictionBehavior="AllowOnly"/>

The concept is to add a connection string for each user. In MS access you can specify a generic location where everyone puts their files. For SQL you have to plug in the connection string. You can create a module to modify your config file but do not forget to backup.
I could not find any documentation on how to assign dynamic parameters to the SQL connection string.

Post a Replyreply

AT Integrated Inc. | 913 Ridgebrook Rd Suite 109, Sparks, MD 21152 | T: 410-472-2490
Copyright © 2024 AT Integrated Inc. All rights reserved.