IIS web page converted from 1.1 to 2.0 Security Exception System.Data.SqlClient.SqlClientPermission

Hi all,

I have a working asp.net 1.1 application (VB.Net) that I attempted to convert to ASP.Net 2.0.  I have been able to eliminate all other issues except for the database error when I try and open a connection to the database.

I tried strong naming, - didn't work.  I looked at Security Permision - but I couldn't make much sence out of it.  Plus I know the account it will be running under is the IIS account. 

The application pool identity is "Network service".  (I'm not sure what "Network service" means; but I saw another post mentioning that this needed rights as well.  how would I go about checking for these rights.)

The IIS server that I am using is a Windows server 2003 on a development box (not a live server)  Hence the live ASP.net 1.1 and the development 2.0 box.

 The specific error is:

Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I know the username and password work as it is still working under 1.1. 

What permisions need to be checked (where to check them) as I will  need to forward these suggestion to either the Database administratior or the Network administrator.

If any other information is needed I will check back later.

 Thanks in advance,

Mike

PS - I hope this is in the correct forum - if not will a moderator please move it to a correct one - Thanks.

0
MJenck
1/11/2008 10:43:31 PM
asp.net.security 27051 articles. 1 followers. Follow

17 Replies
815 Views

Similar Articles

[PageSpeed] 37

 Are u using the windows authentication to connect to database. if yes can u try and use Sql authentication once?


Vikram
www.vikramlakhotia.com


Please mark the answer if it helped you
0
vik20000in
1/12/2008 8:53:27 AM

Thanks for the reply. The connection string is like the following except the ***** are replaced with the correct values.

Connection string is: Data Source=*****;Initial Catalog=*****;packet size=4096;User Id=*****;Password=*****;

 Mike

0
MJenck
1/12/2008 5:49:03 PM

MJenck:

I have a working asp.net 1.1 application (VB.Net) that I attempted to convert to ASP.Net 2.0.  I have been able to eliminate all other issues except for the database error when I try and open a connection to the database.

Hi

By default, the 'System.Data.SqlClient.SqlClientPermission" allow connect to access a data source, I wonder if you are running website on a shared host, so web admin changed the security policy and restricted connection for SQL server.

If you are running website on your local machine, please define a custom security policy in %windir%/Microsoft.NET\Framework\v2.0.50727\Config\  ,edit the SqlClientPermission section, set Unrestricted to true, as shown in the following example.

    <IPermission class="SqlClientPermission" version="1" Unrestricted="true" />  

For more information about custom trust level, please view this link http://msdn2.microsoft.com/en-us/library/0x4t63kb.aspx


Best Regards
XiaoYong Dai
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
0
XiaoYong
1/15/2008 6:18:40 AM

Thanks for the reply.

The development website is physically on a different machine ( I have remote access to it to make changes)  I remoted into the webserver and did caspol -machine -listspset

The localIntranet does not have SqlClient permissions (as expected).  However I see a different policy already set up and was wondering how do I configure my application to run under a custom policy?  Please give step by step instruction (I'm way out of my comfort zone on this). 

Will I need to use Caspol for this or is there a different tool?

Thanks in advance,

Mike

 

0
MJenck
1/15/2008 7:55:26 AM

MJenck:

However I see a different policy already set up and was wondering how do I configure my application to run under a custom policy?  Please give step by step instruction

Hi

You can open the %windir%/Microsoft.NET\Framework\v2.0.50727\web.config file, and use a custom security policy file which tailored to your specific requirements by changing the securityPolicy section like this example.

<securityPolicy>
                <trustLevel name="Full" policyFile="internal"/>
                <trustLevel name="High" policyFile="web_hightrust.config"/>
                <trustLevel name="Medium" policyFile="web_mediumtrust.config"/>
                <trustLevel name="Low" policyFile="web_lowtrust.config"/>
                <trustLevel name="Minimal" policyFile="web_minimaltrust.config"/>
                <trustLevel name="HighCustom"  policyFile="web_highcustom.config"/>
</securityPolicy>
<trust level="HighCustom" originUrl=""/>

 


Best Regards
XiaoYong Dai
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
0
XiaoYong
1/15/2008 12:13:35 PM

Both the Devmachine and my local machine we.config look like

<system.web>

   <securityPolicy>

      <trustLevel name="Full" policyFile="internal" />

      <trustLevel name="High" policyFile="web_hightrust.config" />

      <trustLevel name="Medium" policyFile="web_mediumtrust.config" />

      <trustLevel name="Low" policyFile="web_lowtrust.config" />

      <trustLevel name="Minimal" policyFile="web_minimaltrust.config" />

   </securityPolicy>

   <trust level="Full" originUrl="" />

</system.web>

 Doesn't this give Full rights to the application?

0
MJenck
1/18/2008 7:23:56 PM

Yes, this will specify unrestricted permissions, grant the ASP.NET application permissions to access any resource that is subject to operating system security and all privileged operations are supported.


Best Regards
XiaoYong Dai
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
0
XiaoYong
1/21/2008 4:08:11 AM

So both machines specify unrestricted permissions - why am I getting this error?

Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Is there a network policy in addition to the web.config that could be affecting the permissions? 

Mike

0
MJenck
1/21/2008 4:32:05 AM

Hmm, you may check if it's a match version of config file for v2.0.50727. Another possibility is that applications in a more local Web.config file overrides the trust level settings. this can be find out using the following code

 
1            Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
2    
3            TrustSection configSections = (TrustSection)config.GetSection("system.web/trust");
4            Response.Write("ASP.NET Configuration Info<br>");
5    
6                 // Display Config details.
7            Response.Write("File Path: "+ config.FilePath+"&lt;BR>");
8            Response.Write("Section Path: "+ configSections.SectionInformation.Name + "&lt;BR>");
9    
10           // Display Level property.
11           Response.Write("Level: "+ configSections.Level + "&lt;BR>");
12   
13           string[] roles= Roles.GetRolesForUser("aaa");
14           foreach (string role in roles)
15           {
16               Response.Write(role+"&lt;BR>");
17           
18           }
19   
 
 
Best Regards
XiaoYong Dai
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
0
XiaoYong
1/21/2008 5:56:03 AM

I received the following exception

The Role Manager feature has not been enabled.

I tweaked the code for VB.Net (included 1 - to verify and 2 so other if they need it it's here)

 Before the error

 config.FilePath "\\devmachine\CourseGuidePreview\web.config" String

configSections.Level "Full" String

configSections.SectionInformation.Name "trust" String

configSections.SectionInformation.Type "System.Web.Configuration.TrustSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" String

----------------------------------------------------------------------------------------------------------------------------------------

Dim config As Configuration = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)

Dim configSections As TrustSection = DirectCast(config.GetSection("system.web/trust"), TrustSection)

Response.Write("ASP.NET Configuration Info<br>")

' Display Config details.

Response.Write("File Path: " + config.FilePath + "&lt;BR>"

Response.Write("Section Path: " + configSections.SectionInformation.Name + "&lt;BR>")

' Display Level property.

Response.Write("Level: " + configSections.Level + "&lt;BR>")

Dim myRoles() As String = Roles.GetRolesForUser("aaa")

For i As Integer = LBound(myRoles) To UBound(myRoles)

Response.Write(myRoles(i) + "&lt;BR>")

Next

0
MJenck
1/21/2008 4:59:45 PM

Hi

Just remove the line 13,14,15,16,17,18 in my above code (such code didn't make any differenceto the final outcome)

or add this line into your web.config

<roleManager enabled="true" />


Best Regards
XiaoYong Dai
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
0
XiaoYong
1/22/2008 2:10:41 AM

The output was: 

ASP.NET Configuration Info
File Path: \\devmachine\CourseGuidePreview\web.config<BR>Section Path: trust<BR>Level: Full<BR>

Mike

 

I tried to get the

<roleManager enabled="true"></roleManager>

 to work but it caused a error:

Line 129:    <roleManager>
Line 130:      <providers>
Line 131:        <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Line 132:        <add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Line 133:      </providers>

Don't know if this helps or not...

Mike

0
MJenck
1/22/2008 11:32:18 PM

MJenck:

The output was: 

ASP.NET Configuration Info
File Path: \\devmachine\CourseGuidePreview\web.config<BR>Section Path: trust<BR>Level: Full<BR>

Mike

There are several kinds of solution in this article which may help you work out.

http://blogs.msdn.com/shawnfa/archive/2003/06/20/57023.aspx


Best Regards
XiaoYong Dai
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
0
XiaoYong
1/23/2008 6:04:02 AM

After attempting to configure the .net 2.0 on my local machine I terminal into the server and realized that it does not have the configuration installed.  I have put a work request in and will reply if this worked.

 

Mike

0
MJenck
2/1/2008 8:41:02 PM

The SDK was installed on the IIS devmachine.  When I try and create a code group I get the following error

"The import failed.  The assembly does not appear to be valid."

However, when I import it from my local machine it imports fine.  The files appear to be identical.  I checked version and file size on the three file (.dll, .pbx, .xml).

Any other ideas?

 Mike

0
MJenck
2/5/2008 4:00:32 AM

Hi all,

As an update to my previous post I modified the ASP.Net configuration to use impersonation. 

I entered my username and password and - IT WORKED.  This led me to try "caspol -all -reset".  I removed the impersonation and now my application is working.

Thanks to ALL for your help

 Mike 

 

0
MJenck
2/8/2008 10:43:05 PM

MJenck:

I entered my username and password and - IT WORKED.  This led me to try "caspol -all -reset".  I removed the impersonation and now my application is working.

Cool, so kind of you to share solution with us, This can be beneficial to other community members meet the same problem. thanks.


Best Regards
XiaoYong Dai
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
0
XiaoYong
2/11/2008 7:02:40 AM
Reply:

Similar Artilces:

System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed
All, I would be most grateful for any help, ideas or pointers as it's been 15 hours I been working on this without any luck, and I'll leave this in the competent hands of the .NET forum gurus before getting some sleep. My ASP.NET 2.0 Ajax website works fine on my local machine. When I copy the files across to my shared host (Fasthosts - UK) I get the following exception:[SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.] MyGeneration.dOOdad...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0 #2
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! There are too many differences for one email - - from 1.0 to 1.1 (not a whole lot of real change, other than fixes, at least compared to 1.1 to 2.0) With 2.0, there were many new declarative controls, with many new ideas added in With 3.0, it's a superset of 2.0 - instead of replacing the installation completely, it just 'added on' new functionality - I would...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! Have a look into this links http://en.wikipedia.org/wiki/.NET_Framework http://blogs.msdn.com/mohammadakif/archive/2006/12/03/net-3-0-different-versions-of-the-net-framework.aspx http://www.codeproject.com/aspnet/ComparisonASP1xASP20.aspAshok Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that m...

Can a .NET 1.1 page execute in a .NET 2.0 web site?
I've got a ASP.NET 1.1 web site to which I would like to add some ASP.NET 2.0 web pages. Could I just change the web site to point to the 2.0 .NET version and still have the .NET 1.1 web pages work so that both versions are in the same web site? Have you some of you approached this? Thanks. The official answer is maybe It's not officially supported, but most ASP.NET 1.1 pages will run fine under ASP.NET 2.0.  Officially you should run the upgrade wizard on your 1.1 pages. This is a  pretty good blog entry.      JamesMy Blog: http://www.wintersfamily.plus.c...

Converting System.Exception to System.Web.HttpCompileException in global.asax Application_Error
Hello.  I am capturing an exception in the above event handler using Server.GetLastError().  I would like to access the Results and SourceCode properties of an inner exception of type System.Web.HttpCompileException, but cannot do so, and am unable to implicitly convert a general exception to System.Web.HttpCompileException.  Any ideas?  Thank you in advance, Chris. Solved my own problem via the following code.  Feeling kind of embarrassed over the simple fix. if (lastErr.InnerException.GetType().ToString() == "System.Web.HttpCompileException") { ...

Firefox 1.5.0.9, Firefox 2.0.0.1 and Thunderbird 1.5.0.9 Security & Stability Updates
As part of Mozilla Corporation�s ongoing stability and security update process, Firefox 1.5.0.9, Firefox 2.0.0.1 and Thunderbird 1.5.0.9 are now available for Windows, Mac, and Linux for free download from getfirefox.com (http://www.getfirefox.com) & getthunderbird.com (http://www.getthunderbird.com). We strongly recommend that all Firefox users upgrade to this latest release. This update is available immediately in 41 languages including Spanish, Japanese, Arabic, Hungarian and more. Note: Firefox 1.5.0.x will be maintained with security and stability updates until Apr...

Firefox 1.5.0.9, Firefox 2.0.0.1 and Thunderbird 1.5.0.9 Security & Stability Updates
As part of Mozilla Corporation�s ongoing stability and security update process, Firefox 1.5.0.9, Firefox 2.0.0.1 and Thunderbird 1.5.0.9 are now available for Windows, Mac, and Linux for free download from getfirefox.com (http://www.getfirefox.com) & getthunderbird.com (http://www.getthunderbird.com). We strongly recommend that all Firefox users upgrade to this latest release. This update is available immediately in 41 languages including Spanish, Japanese, Arabic, Hungarian and more. Note: Firefox 1.5.0.x will be maintained with security and stability updates until Apr...

i ve got System.Security.SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, failed. exception
hi everyone i created windows form user control and i embedded it to asp.net web for , my user control sends mail using by System.Net.Mail library but when i open my web site and click to send button that on my user control  i ve got this exception System.Security.SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.    what can i do ? my best regards ..    Couple of questions: 1) Are you running this from an IIS installati...

Security Policy Error Converting Framework 1.1 to 2.0
All --BackgroundI have been searching all the forums and KBase articles I can locate to research a problem I have encountered. The plethora of information I have thumbed through indicates I am not the first to encounter this type problem; however, I can't seem to locate a concise answer; I hope someone can assist me.Brief Scenario1. A month ago, I was using Visual Studio 2003 loaded on a Windows XP client. I had a VB.Net application built on a server that resides on our LAN. This server-resident solution is my development solution that I add new features to, test, and then depl...

System.Security.Permissions.FileIOPermission on Upgradation from .NET 1.1 to 2
Hello, I am upgrading my application from .Net 1.1 to 2. My folder structure is as follows :  Root Directory |||---Admin|---Images|---.... Admin folder contains a page : pic.aspx which has to upload pictures to the images folder and delete pictures in the images folder. But when I try to access the Images folder using the following code: Server.MapPath("..\Images\") or Directory.GetParent(Server.MapPath("..\Images\"))I get the following exception : Security Exception Description: The application attempted to perform an operation not allowed by the security p...

error in converting a framework 1.1 vb.net web site to framework 2.0
  I am trying to convert a framework 1.1 vb.net web site to framework 2.0 site, and it's not possible to rewrite it.  I have gone through the convertion wizard and compliled successfully. Sound great so far. However, when I run the page via the virtual web server, I get a error message said, "Parser Error Message: Could not load type BizWeb.WebPages.DefaultSettings.FeeForm"   Did anyone exprience this problem when doing convertion? Please share some experience to me.   Thanks in advance!   vcllvc  Hi, One way: Go to IIS manager, right click...

Ports Page Updated for 1.0.2, 1.0.2 & 1.7.6
Mike's new security update releases of FF, TB & Moz available now. Links at the Warpzilla page in your bookmarks: http://www.mozilla.org/ports/os2/ -- "In everything, do to others what you would have them do to you." Matthew 7:12 NIV Team OS/2 ** Reg. Linux User #211409 Felix Miata *** http://members.ij.net/mrmazda/ In <4243230E.3070604@dev.nul>, on 03/24/2005 at 03:29 PM, Felix Miata <UgaddaBkidding.due2UCE@dev.nul> said: >Mike's new security update releases of FF, TB & Moz available now. Links >at the Warpzilla pag...

CrystalReportViewer problem after converting from .NET 1.1 to .NET 2.0
After converting my web aaplication project from .NET 1.1 to .NET 2.0, I am getting the following error when trying to run reports (and even in the VS 2005 designer):The base class includes the field 'crvBCSOnHandReport', but its type (CrystalDecisions.Web.CrystalReportViewer) is not compatible with the type of control (CrystalDecisions.Web.CrystalReportViewer)Has anybody else had this problem after converting?Thanks,Sacha...

critical leak in security on firefox 2.0.0.1 and 2.0 #2
Name: Jimi Product: Firefox Summary: critical leak in security on firefox 2.0.0.1 and 2.0 Comments: Dear Sirs, I saw that you created new version of firefox 2 so I have just tested latest firefox 2.0.0.1. on the same problem that I had with firefox 2. So, after browsing again this time with 2 opened tabs I was testing switch proxy extension and than suddenly huge amount of data came on my computer seemingly out of nowhere. I stopped activities by pusshing stop loading this page icon on browser on both opened tabs although only on one the page was loading ...

Web resources about - IIS web page converted from 1.1 to 2.0 Security Exception System.Data.SqlClient.SqlClientPermission - asp.net.security

Resources last updated: 11/26/2015 9:06:46 PM