 |
BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio
 | This is the forum to discuss the Wrox book ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solution by Vincent Varallo; ISBN: 9780470396865 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

May 14th, 2009, 12:36 PM
|
|
Registered User
|
|
Join Date: May 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
I receive the following error when trying to do the example from page 28 (chapter 2, 'adding a record'). I have been trying to find a solution for the last several hours, if you can help in any way that would be great. Thanks
Code:
Server Error in '/PaidTimeOffUI' Application.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
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 'NT AUTHORITY\NETWORK SERVICE'.
Source Error:
Line 43:
Line 44: // Save the changes to the db
Line 45: db.SubmitChanges();
Line 46: }
Line 47:
Source File: e:\Mirrored\MUST Save\Web Creation\Projects\PaidTimeOffSolution\PaidTimeOffUI\Default.aspx.cs Line: 45
Stack Trace:
[SqlException (0x80131904): Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +248 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +245 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2811 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +53 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +327 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +2445370 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +2445224 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +354 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +703 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +54 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +2414776 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +92 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +1657 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +84 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +1645767 System.Data.SqlClient.SqlConnection.Open() +258 System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode) +659 _Default.btnInsert_Click(Object sender, EventArgs e) in e:\Mirrored\MUST Save\Web Creation\Projects\PaidTimeOffSolution\PaidTimeOffUI\Default.aspx.cs:45 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
|
|

May 14th, 2009, 12:41 PM
|
|
Registered User
|
|
Join Date: May 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
oh goodness, this seems to work, can someone identify if this is the correct solution that I should be taking?
Code:
<system.web>
<identity impersonate="true" userName="xxxxx" password="xxxxx" />
<.system.web>
|
|

May 14th, 2009, 08:40 PM
|
|
Wrox Author
|
|
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
|
|
The web site uses the current user's windows identity to identify users. You should turn off anonymous access for this virtual directory and enable Integrated Windows Authentication. You can do this by opening IIS, right click on your virtual directory, select properties, click the directory security tab, click the edit button.
|
|

May 15th, 2009, 07:23 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
When creating the database connection the SQL client uses the details provided in the SQL connection string. If the connection string says to use integrated security (or trusted_Connection=Yes) then it will use the identity of the process it is currently running as.
In IIS this defaults to the NETWORK_SERVICE user, but can be overridden to 'impersonate' a different user.
You can change the user that the process runs as in a number of ways. Firstly you can edit the 'Identity' of the application pool that the web site is running as to any valid windows user.
Secondly you can set <identity impersonate="true"> in the web.config which will set it to use the user 'logged on' via the web site. This in turn will default to the anonymous user account (IUSER_<machinename>) unless you have anonymous access turned off.
Thirdly you can supply the username and password attributes with the <identity> element to get the web site to impersonate that particular user.
An alternative to all of this is to supply a username/password in the connection string 
|
|

May 28th, 2009, 08:11 PM
|
|
Registered User
|
|
Join Date: May 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by samjudson
When creating the database connection the SQL client uses the details provided in the SQL connection string. If the connection string says to use integrated security (or trusted_Connection=Yes) then it will use the identity of the process it is currently running as.
In IIS this defaults to the NETWORK_SERVICE user, but can be overridden to 'impersonate' a different user.
You can change the user that the process runs as in a number of ways. Firstly you can edit the 'Identity' of the application pool that the web site is running as to any valid windows user.
Secondly you can set <identity impersonate="true"> in the web.config which will set it to use the user 'logged on' via the web site. This in turn will default to the anonymous user account (IUSER_<machinename>) unless you have anonymous access turned off.
Thirdly you can supply the username and password attributes with the <identity> element to get the web site to impersonate that particular user.
An alternative to all of this is to supply a username/password in the connection string 
|
Thanks for the info, it is good to know my options.
|
|
 |