<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to provide extra trust for an Internet Explorer hosted assembly</title><link>http://blogs.msdn.com/b/shawnfa/archive/2003/06/26/57026.aspx</link><description>Avoiding security exceptions that occur when you try to provide extra trust based upon strong name or X509 certificates</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>have created a windows library control that accesses a local sql database</title><link>http://blogs.msdn.com/b/shawnfa/archive/2003/06/26/57026.aspx#9383281</link><pubDate>Thu, 29 Jan 2009 19:00:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9383281</guid><dc:creator>Tayfun KAPUSUZ</dc:creator><description>&lt;p&gt; have created a windows library control that accesses a local sql database&lt;/p&gt;
&lt;p&gt;I tried the following strings for connecting&lt;/p&gt;
&lt;p&gt;Dim connectionString As String = &amp;quot;Data Source=localhost\SQLEXPRESS;Initial Catalog=TimeSheet;Trusted_Connection = true&amp;quot;&lt;/p&gt;
&lt;p&gt;Dim connectionString As String = &amp;quot;Data Source=localhost\SQLEXPRESS;Initial Catalog=TimeSheet;Integrated Security=SSPI&amp;quot;&lt;/p&gt;
&lt;p&gt;I am not running the webpage in a virtual directory but in &lt;/p&gt;
&lt;p&gt;C:\Inetpub\wwwroot\usercontrol&lt;/p&gt;
&lt;p&gt;and I have a simple index.html that tries to read from an sql db but throws&lt;/p&gt;
&lt;p&gt;the error&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt; &amp;nbsp; at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark&amp;amp; stackMark, Boolean isPermSet)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; at System.Security.PermissionSet.Demand()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; at System.Data.Common.DbConnectionOptions.DemandPermission()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; at System.Data.SqlClient.SqlConnection.PermissionDemand()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection,&lt;/p&gt;
&lt;p&gt;etc etc&lt;/p&gt;
&lt;p&gt; The action that failed was:&lt;/p&gt;
&lt;p&gt;Demand&lt;/p&gt;
&lt;p&gt;The type of the first permission that failed was:&lt;/p&gt;
&lt;p&gt;System.Data.SqlClient.SqlClientPermission&lt;/p&gt;
&lt;p&gt;The Zone of the assembly that failed was:&lt;/p&gt;
&lt;p&gt;Trusted&lt;/p&gt;
&lt;p&gt;I looked into the .net config utility but it says unrestricted and I tried adding it to the trusted internet zones in ie options security&lt;/p&gt;
&lt;p&gt;I think that a windows form connecting to a sql database running in a webpage should be simple&lt;/p&gt;
&lt;p&gt;to configure what am I missing?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9383281" width="1" height="1"&gt;</description></item><item><title>re: How to provide extra trust for an Internet Explorer hosted assembly</title><link>http://blogs.msdn.com/b/shawnfa/archive/2003/06/26/57026.aspx#2530990</link><pubDate>Fri, 11 May 2007 01:15:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2530990</guid><dc:creator>IvanK</dc:creator><description>&lt;p&gt;I have a .NET control hosted in IE, which uses WSE2 (Microsoft.Web.Services2.dll) to connect back to the server and download files which are later loaded into MS Office applications (Excel, Word, Outlook).&lt;/p&gt;
&lt;p&gt;WSE2 requires FullTrust and does not trust partially trusted callers. &lt;/p&gt;
&lt;p&gt;My solution so far is to set a URL/Site based policy entry, which grants FullTrust.&lt;/p&gt;
&lt;p&gt;The problem is - how to deploy this policy with minimum client involvement?&lt;/p&gt;
&lt;p&gt;1.	Provide the power users with a document, which describes for them how to do the change using .NET Framework Configuration tool. &lt;/p&gt;
&lt;p&gt;Problem – too much user involvement and .NET 2.0 doesn’t even come with Configuration tool (you have to install the SDK to get it – that’s &amp;nbsp;way too much to ask from the end user)&lt;/p&gt;
&lt;p&gt;2.	The built-in tools - The msi file, generated by the Framework Configuration Tool simply replaces the whole policy instead of only updating it. &lt;/p&gt;
&lt;p&gt;Problem - while this might be considered somewhat OK for well established enterprise-wide situations - it's completely ridiculous each policy “update” to wipe out everything else at that level. On top of that it seems that the msi toggles between install and uninstall no matter how it’s called. Also with the generated msi, there’s no way to change the URL/Site which is different for every client we have.&lt;/p&gt;
&lt;p&gt;3.	To deal with the above situation, I wrote an ActiveX control, which again is launched from a page to set the required .NET CAS permissions. As long as the user has enough Windows permissions and ActiveX controls are allowed, it doesn’t need anything else to “update” the .NET security policy (for the highest CLR version it finds on the machine). This worked just fine in XP...Then Vista came along…and ActiveX basically lost that ability. It’s signed, marked safe for Scripting and Initialization, but I don’t know of any way for the ActiveX to request elevated Windows permissions to run caspol.exe in order to update the policy. In an exe, I can embed a manifest and require admin rights. Then at runtime Vista will prompt for rights elevation if the user can in fact obtain them. &lt;/p&gt;
&lt;p&gt;Problem - how can I do the same an ActiveX?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2530990" width="1" height="1"&gt;</description></item><item><title>re: How to provide extra trust for an Internet Explorer hosted assembly</title><link>http://blogs.msdn.com/b/shawnfa/archive/2003/06/26/57026.aspx#1989607</link><pubDate>Thu, 29 Mar 2007 20:35:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1989607</guid><dc:creator>shawnfa</dc:creator><description>&lt;p&gt;That behavior is from the Windows Forms classes, which I believe (but am not 100% sure) base it upon the zone of the form rather than the trust level of the form.&lt;/p&gt;
&lt;p&gt;You could try asking over in the WinForms group on the MSDN forums, where someone who is better versed in WinForms could provide a more authoratitive answer.&lt;/p&gt;
&lt;p&gt;-Shawn&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1989607" width="1" height="1"&gt;</description></item><item><title>re: How to provide extra trust for an Internet Explorer hosted assembly</title><link>http://blogs.msdn.com/b/shawnfa/archive/2003/06/26/57026.aspx#1896338</link><pubDate>Fri, 16 Mar 2007 23:45:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1896338</guid><dc:creator>rpt2k</dc:creator><description>&lt;p&gt;First of all Thank you for maintaing this blog. This is very usefull and informative. There is very little (if any) documentation available on this issue. Here is my situation. I have a user control which I am hosting in IE. This is signed using a strong name. I have created a new CodeGroup and the membership condition is the publik key part of the strong name. Everything works fine in both the Intranet and Internet zone in IE. Except, when a modal form pops up in the Internet Zone, it has a .NET security warning bubble associated with it, warning not to enter password and other stuff on the dialog. ( The form/dialog does not have any textboxes on it). This does not happen in Intranet zone. I am confused as to the behaviour. I will really appreciate your input/suggestions for resolving this issue. &lt;/p&gt;
&lt;p&gt;Thanks much.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1896338" width="1" height="1"&gt;</description></item><item><title>re: How to provide extra trust for an Internet Explorer hosted assembly</title><link>http://blogs.msdn.com/b/shawnfa/archive/2003/06/26/57026.aspx#1846466</link><pubDate>Fri, 09 Mar 2007 21:11:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1846466</guid><dc:creator>shawnfa</dc:creator><description>&lt;p&gt;Hi Laca,&lt;/p&gt;
&lt;p&gt;You can't do this without modifying anything on the client machine. &amp;nbsp;(Think of how much malware would love to be able to elevate on client machines!).&lt;/p&gt;
&lt;p&gt;In Orcas there is a feature that allows controls to carry a manifest which states it needs to be trusted, and if that manifest is signed by a trusted publisher (you'll have to push the trusted publisher down to client machines), then it will run with the requested permissions.&lt;/p&gt;
&lt;p&gt;-Shawn&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1846466" width="1" height="1"&gt;</description></item><item><title>re: How to provide extra trust for an Internet Explorer hosted assembly</title><link>http://blogs.msdn.com/b/shawnfa/archive/2003/06/26/57026.aspx#1846462</link><pubDate>Fri, 09 Mar 2007 21:09:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1846462</guid><dc:creator>shawnfa</dc:creator><description>&lt;p&gt;Hi Alvin,&lt;/p&gt;
&lt;p&gt;I'm not sure I entirely understand your points. &amp;nbsp;ClickOnce aside (it's not really the same thing -- it allows for installing applciations locally, whereas we're talking about hosting a control in a web page here), let me look at your other points.&lt;/p&gt;
&lt;p&gt;You don't have to elevate a Zone, Site, or URL to get this scenario to work. &amp;nbsp;I totally agree that elevating a zone is almost certainly the wrong way to go. &amp;nbsp;You can use StrongName or Publisher evience to elevate your control, however that means the AppDomain itself will not be trusted. &amp;nbsp;To solve this, you can place Asserts at the entry points of your control so that demands never hit the AppDomain boundary.&lt;/p&gt;
&lt;p&gt;-Shawn&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1846462" width="1" height="1"&gt;</description></item><item><title>re: How to provide extra trust for an Internet Explorer hosted assembly</title><link>http://blogs.msdn.com/b/shawnfa/archive/2003/06/26/57026.aspx#1845311</link><pubDate>Fri, 09 Mar 2007 18:26:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1845311</guid><dc:creator>Alvin Bruney</dc:creator><description>&lt;p&gt;I'm annoyed at the fact that there is no viable solution for this at the enterprise level today. Orcas isn't out yet. Clickonce has its issues. On a fundamental level, elevating the code trust for a site, url or zone in order to have a usercontrol run flies in the face of security. It is just as bad as running an ActiveX because a site, zone or url receives more permissions than it requires. Roll that out to the enterprise and it opens up a massive hole ripe for hacking. What do we do TODAY to make this work in a way that is safe for an enterprise? The *solutions* provided are bandaids that do not address the underlying issue. I'm not referring to this within the context of one or two desktops, i'm putting this in the context of a government or large instituion with hundreds of thousands of client machines. You can't reasonably expect to raise the permissions of a site, zone or url to full trust? Or did i take a wrong turn somewhere?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1845311" width="1" height="1"&gt;</description></item><item><title>Specifying Permissions for IE Controls in Orcas</title><link>http://blogs.msdn.com/b/shawnfa/archive/2003/06/26/57026.aspx#1831336</link><pubDate>Thu, 08 Mar 2007 02:07:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1831336</guid><dc:creator>.Net Security Blog</dc:creator><description>&lt;p&gt;One of my most read blog posts (and one of the reasons I created this blog in the first place -- to answer&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1831336" width="1" height="1"&gt;</description></item><item><title>Specifying Permissions for IE Controls in Orcas</title><link>http://blogs.msdn.com/b/shawnfa/archive/2003/06/26/57026.aspx#1830279</link><pubDate>Wed, 07 Mar 2007 22:47:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1830279</guid><dc:creator>RSS It All</dc:creator><description>&lt;p&gt;One of my most read blog posts (and one of the reasons I created this blog in the first place -- to answer&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1830279" width="1" height="1"&gt;</description></item><item><title>re: How to provide extra trust for an Internet Explorer hosted assembly</title><link>http://blogs.msdn.com/b/shawnfa/archive/2003/06/26/57026.aspx#1827611</link><pubDate>Wed, 07 Mar 2007 16:33:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1827611</guid><dc:creator>Laca</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;I want to use a .net object in IE. (Directoryservices) &lt;/p&gt;
&lt;p&gt;Can I give full-trust to it? Without modifying anything on client machine.&lt;/p&gt;
&lt;p&gt;Maybe with a certificate or a popup at the client, that he gives full trust to this activex.&lt;/p&gt;
&lt;p&gt;Thanks Laszlo.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1827611" width="1" height="1"&gt;</description></item></channel></rss>