SPSqlDataSource: This control does not allow connection strings with the following keywords: ‘Integrated Security’, ‘Trusted_Connection’.
Posted
Monday, February 11, 2008 10:28 AM
by
CoreyRoth
I ran into this one again lately when deploying. We are folowing best practices with our connection strings by using Integrated Security. We have several controls on the web site making use of SqlDataSource controls. However, at runtime, we are left when an error like the following.
Microsoft.SharePoint.WebPartPages.DataSourceControlDisabledException: This control does not allow connection strings with the following keywords: ‘Integrated Security’, ‘Trusted_Connection’.
This is because SharePoint puts a tagMapping in the web.config that maps the ASP.NET SqlDataSource to its SPSqlDataSource. Why it does this, I have no idea? If I check the SDK on that class, there is not so much as even a description of what the class does (come on Microsoft, you still need to work on this SDK documentation). A workaround is actually pretty simple, remove the tagMapping. However, you can't just simply delete the line, you must use the remove element to get rid of it.
<remove tagType="System.Web.UI.WebControls.SqlDataSource, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
This will allow the control to work, but you also need to register the ASP.NET SqlDataSource as a safe control. You know the syntax, but here it is in case to make it easy.
<SafeControl Assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="System.Web.UI.WebControls" TypeName="SqlDataSource" Safe="True" AllowRemoteDesigner="False" />
That is all it takes and everything inside SharePoint still seems to work. My point of today's post is to put out the following questions.
-
What is the purpose of this inherited control?
-
Why on earth would it not support integrated security?
-
Why does the SDK documentation continue to leave out details about key classes?
If you have the answer to any of those, please leave a comment.