Showing posts with label developed. Show all posts
Showing posts with label developed. Show all posts

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

Wednesday, March 21, 2012

Login failed for user 'miovision'.

Hi I have an ASP.NET application which was being developed using SQL 2005, VS 2005 in a Server 2003 environment and using SQL Server Authentication.I deployed the application in a shared hosted enviroment running SQL Server. I created a new user and changed the connection string in my ASP.NET application to the following:

Server=209.200.235.3;Database=some_database;User ID=some_user; Password=some_password;

When i try to connect to the web page on my hosted site I get the following error:

Server Error in '/' Application. Login failed for user 'miovision'.

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 'miovision'.

Source Error: Line 4:
<html xmlns="http://www.w3.org/1999/xhtml" >Line 5: <head id="Head1" runat="server">Line 6: <title><%=Constants.PRODUCT_NAME %></title>Line 7: <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />Line 8: <link rel="icon" href="favicon.ico" type="image/x-icon" />

Source File: d:\Inetpub\vhosts\interlyticsonline.officewebsite.net\httpdocs\Default.aspx

Line: 6 Stack Trace: [SqlException (0x80131904): Login failed for user 'miovision'.] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734931 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +359 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496 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.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +121 System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) +162 System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) +107 Miovision.JInterlytics.Common.JAMAR_DevDataSetTableAdapters.procSoftwareConfigurationSelectTableAdapter.Fill(procSoftwareConfigurationSelectDataTable dataTable, Nullable`1 i_SoftwareConfigID, String i_SoftwareConfigName) in C:\My Code OLD\JInterlytics\Miovision.JInterlytics.Common\Miovision.JInterlytics.Common\DataAccess\JAMAR_DevDataSet.Designer.vb:9759 DataAccessSelect.procSoftwareConfigurationSelect(String softConfigName) +80 Constants.SERVER_ADDRESS() +11 Constants..cctor() +274

[TypeInitializationException: The type initializer for 'Constants' threw an exception.] ASP.default_aspx.__Render__control2(HtmlTextWriter __w, Control parameterContainer) in d:\Inetpub\vhosts\interlyticsonline.officewebsite.net\httpdocs\Default.aspx:6 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +2065851 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +24 System.Web.UI.HtmlControls.HtmlTitle.Render(HtmlTextWriter writer) +94 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +130 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +24 System.Web.UI.HtmlControls.HtmlHead.RenderChildren(HtmlTextWriter writer) +14 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +29 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +130 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +24 System.Web.UI.Page.Render(HtmlTextWriter writer) +26 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1896

I have verified the passwords match. What am I missing?

Thanks.Is "miovision" the actual user ID in your connection string? When you create a login/user, you need grant the login access to its default datebase. Otherwise, login will fail.|||Yes, the user ID is the same in the connection string as it is in the database.|||Hi,

please make sure that the user is enabled and not locked out, the user has the priviledge to access the server and the user has the appropiate right to have access to the server. If the connection possible using other clients than the ASP webpage ?

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

login failed for user

hi,
i have developed a web application. i need to connect to sqlserver 2000
to fetch data and i am getting the following error when requested for
login page.

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

When i refresh the page it is working properly, i.e., i could see the
login screen.

what is the solution for this problem?

Kalaivanankalaivanan (mail2kalai@.gmail.com) writes:

Quote:

Originally Posted by

i have developed a web application. i need to connect to sqlserver 2000
to fetch data and i am getting the following error when requested for
login page.
>
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
>
When i refresh the page it is working properly, i.e., i could see the
login screen.
>
what is the solution for this problem?


Looks as if the web server is trying to log in with its service account.
What does your connect string look like? Are you using Windows
authentication or SQL authentication?

If you are using Windows authentication, this is likely to be an issue
that requires knowledge of IIS (or whatever webserver you use) that I
don't. You may be better off asking in a group about IIS:

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

login failed for user

hi,
i have developed a web application. i need to connect to sqlserver 2000
to fetch data and i am getting the following error when requested for
login page.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
When i refresh the page it is working properly, i.e., i could see the
login screen.
what is the solution for this problem?
KalaivananIt sounds like the web application is trying to connect using the system
account. Give it a user account (non sa) which can logon to the sql server.
Also verify that SQL Server is not running under the local system account.
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"kalaivanan" <mail2kalai@.gmail.com> wrote in message
news:1157353804.602345.216230@.i3g2000cwc.googlegroups.com...
> hi,
> i have developed a web application. i need to connect to sqlserver 2000
> to fetch data and i am getting the following error when requested for
> login page.
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
> When i refresh the page it is working properly, i.e., i could see the
> login screen.
> what is the solution for this problem?
> Kalaivanan
>

login failed for user

hi,
i have developed a web application. i need to connect to sqlserver 2000
to fetch data and i am getting the following error when requested for
login page.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
When i refresh the page it is working properly, i.e., i could see the
login screen.
what is the solution for this problem?
KalaivananIt sounds like the web application is trying to connect using the system
account. Give it a user account (non sa) which can logon to the sql server.
Also verify that SQL Server is not running under the local system account.
--
Hilary Cotter
Director of Text Mining and Database Strategy
RelevantNOISE.Com - Dedicated to mining blogs for business intelligence.
This posting is my own and doesn't necessarily represent RelevantNoise's
positions, strategies or opinions.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"kalaivanan" <mail2kalai@.gmail.com> wrote in message
news:1157353804.602345.216230@.i3g2000cwc.googlegroups.com...
> hi,
> i have developed a web application. i need to connect to sqlserver 2000
> to fetch data and i am getting the following error when requested for
> login page.
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
> When i refresh the page it is working properly, i.e., i could see the
> login screen.
> what is the solution for this problem?
> Kalaivanan
>

Login failed for sql authentication

I've developed an ASP2 application. Locally, everything was fine. However, when I deployed it on a remote server. I got this error:

Login failed for user 'domain\userx'.

My connection string is:

connectionString="Data Source=ServerName;Initial Catalog=Aspect;User Id =domain\userx;Password = abc"

I'm quite sure that connection string is fine. I need to mention that whenever I try to connect to the remote server from my client by the Sql authentication, I get the message that login failed for this user. But when I try to connect by windows authentication, it works and there is no error.

I asked the administrator, and he told me that Sql Server authentication is in mixed mode.

So, I really can't figure out what is the problem

From your connection string I found you're trying to explicitly specify a Windows account, which seems to connect with Windows Authentication rather than SQL Authentication. To learn more about Authentication Mode in SQL, please take a look at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adminsql/ad_security_47u6.asp

You can 2 options when connect to SQL, either to specify a SQL account and password; or use WindowsAuthentication by setIntegrated Security to SSPI (true). So if you want to connect with Windows Authentication, firstly you have to add the Windows Account to the SQL logins and grant proper permission to it. More information about creating SQL Logins can be found at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/moddev/html/dehowcreatingsqlserverusers.asp

then write your connection string as following:

connectionString="Data Source=ServerName;Initial Catalog=Aspect; Integrated Security =SSPI;";

This website provides various connection strings:

http://www.connectionstrings.com

|||

Thanks lori_jay

You're right. that was my mistake

However, when I tried to connect with connection string same as you wrote, I got this error "Login failed for user null'. But. I could connect to my DB by using client tools and with windows authentication.

So, the problem occurs when I try to connect through my web application.

Do you have any suggestion ?

|||

Also I have another question.

If I use windows authentication in my connection string. Does everyone in the domain who succesfully logined, have access ?

Thanks.

|||

bkpazand:

However, when I tried to connect with connection string same as you wrote, I got this error "Login failed for user null'. But. I could connect to my DB by using client tools and with windows authentication.

Then is your application deployed under IIS? It seems that other account has been used to connect to SQL. So please make sure you perform proper impersonation when connect under IIS. You can take a look at this post:

http://forums.asp.net/thread/1294820.aspx

And you can also find much information about impersonation on MSDN.

bkpazand:

If I use windows authentication in my connection string. Does everyone in the domain who succesfully logined, have access ?

No. If you want to allow other users in the same domain to connect the SQL Server, you can add the users or usergroup to the local Administrators group of the SQL machine. That's because SQL has a built-in login 'BULITIN\Administrators', all memebers for local admin will be mapped to this login when connect to SQL with Windows Authentication.