Wednesday, March 28, 2012

Login failed for user . The user is not associated with a trusted SQL Server connection.

I've seen many, many, many, many posts regarding this topic - but none have been able to fully explain nor fix my problem.


I've developed a security solution according toScott Gu's guide and it works great - but only on my local machine running VWD and SQLExp2005. Once I move this application it completely breaks in the productions environment.

Today I managed to get it halfway there. I created a SQL login and changed my web.config to use these credentials - now the web application will come up, but none of my links (that are role based) are displayed - most likely because i'm authenticating as the SQL credentials instead of me.

So I switch it back to windows authenticated, as it is on my laptop, and it breaks again.

Please tell me theres a way to get this working in production and Scott's fantastic tutorial hasn't wasted me 2 weeks of work.

Here's the exact error I get when using Integrated authentication:

Server Error in '/Contracts' Application.

Login failed for user ''. The user is not associated with a trusted SQL Server connection.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.Data.SqlClient.SqlException: Login failed for user ''. The user is not associated with a trusted SQL Server connection.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[SqlException (0x80131904): Login failed for user ''. The user is not associated with a trusted SQL Server connection.]
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +437
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +84
System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +197
System.Web.Security.SqlRoleProvider.GetRolesForUser(String username) +771
System.Web.Security.RolePrincipal.IsInRole(String role) +272
System.Web.SiteMapProvider.IsAccessibleToUser(HttpContext context, SiteMapNode node) +194
System.Web.SiteMapNode.IsAccessibleToUser(HttpContext context) +14
System.Web.StaticSiteMapProvider.GetChildNodes(SiteMapNode node) +348
System.Web.SiteMapNode.get_ChildNodes() +23
System.Web.SiteMapNode.get_HasChildNodes() +4
System.Web.SiteMapNode.System.Web.UI.IHierarchyData.get_HasChildren() +4
System.Web.UI.WebControls.Menu.DataBindRecursive(MenuItem node, IHierarchicalEnumerable enumerable) +4225
System.Web.UI.WebControls.Menu.DataBindItem(MenuItem item) +277
System.Web.UI.WebControls.Menu.PerformDataBinding() +117
System.Web.UI.WebControls.HierarchicalDataBoundControl.PerformSelect() +82
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.Menu.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.Menu.EnsureDataBound() +29
System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e, Boolean registerScript) +21
System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e) +22
System.Web.UI.Control.PreRenderRecursiveInternal() +77
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360



Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

I am not saying it will fix it but it maybe related to your Windows User/Group not having permission in the database when using Windows Authentication. The database permissions are in the new security section in the database in Management Studio. Hope this helps.|||Can you post your Web.config file?sql

No comments:

Post a Comment