1

I enable windows authentication in my asp.net application as shown below:

<system.web>
    ...
    <authentication mode="Windows"/>
    ...
 </system.web>

In IIS 7.5 I also enabled windows authentication, however i get the following error...

Login failed for user 'Test\PRO'.

Apparently, it is using the name of my server to log in and not the name of the user. Some help please. thank you.

EDIT***** The error is coming when I navigate to the url.. http://PRO:7004/

I also disabled Anonymous authentication from IIS.

***Edit

Server Error in '/' Application.
--------------------------------------------------------------------------------

Login failed for user 'TEST\PRO'. 
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 'TEST\PRO'.

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 'TEST\PRO'.]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6675286
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +688
   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4403
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +84
   System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +55
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +368
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +6703926
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +6704427
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions) +610
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +1049
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +74
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions) +6706995
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions) +78
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +2192
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +116
   System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1012
   System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +6711619
   System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +152
   System.Data.SqlClient.SqlConnection.Open() +229
   System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +150
   System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +4874450
   System.Web.Security.SqlRoleProvider.GetRolesForUser(String username) +1466
   System.Web.Security.RolePrincipal.IsInRole(String role) +12322757
   System.Web.Configuration.AuthorizationRule.IsTheUserInAnyRole(StringCollection roles, IPrincipal principal) +192
   System.Web.Configuration.AuthorizationRule.IsUserAllowed(IPrincipal user, String verb) +233
   System.Web.Configuration.AuthorizationRuleCollection.IsUserAllowed(IPrincipal user, String verb) +241
   System.Web.Security.UrlAuthorizationModule.OnEnter(Object source, EventArgs eventArgs) +12673980
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165



--------------------------------------------------------------------------------
  • Where is the error coming from? Provide the relevant code. – mason Jan 19 '15 at 19:12
  • Did you turn off anonymous authentication on your website from IIS authentication option? – Serjik Jan 19 '15 at 19:13
  • Yes, i disabled anonymous from iis. the error is showing up when I navigate to the url.. –  Jan 19 '15 at 19:15
  • @Mavs Please provide the code that is giving you the error, and/or describe where you're going to find the error message. – mason Jan 19 '15 at 19:31
  • @mason when I go to the homepage, i am getting the error. There is no code, apart from what I added to web.config and the updates to IIS –  Jan 19 '15 at 19:35
  • What do you mean "getting the error". Is it just plain text in your HTML? Is it the yellow screen of death? Is it a popup? You need to figure out where the error is coming from so that you can figure out where you need to focus your effort. Simply saying that you see it when you access the homepage isn't very helpful. – mason Jan 19 '15 at 19:37
  • @mason my apologies. I added the error on the HTML page. –  Jan 19 '15 at 19:43
  • @Mavs Ah, that's better. See, that contained important information. Now we know that the problem is probably not with the user logging into your site, the problem is that your site is unable to log into the database (because it's an `System.Data.SqlClient.SqlException`). Make sure you provide the correct information in your connection string in your configuration or code, and verify you're able to log in via command line or SQL Server Manager. – mason Jan 19 '15 at 19:45
  • @mason sorry about that. thanks for your patience .. would this error occur because I used SQL server authentication to access my db from within the application? I do not have windows authentication on the database, only on the application. –  Jan 19 '15 at 19:48
  • @Mavs Probably. You should post your connection string (don't show us the actual username/password though) and verify that you're able to log into the database using external tools. I'm guessing your web application is trying to use Windows authentication to access your DB instead of SQL Authentication. – mason Jan 19 '15 at 19:50
  • @mason In connection string I edited the default connection and provided the username and password for the db. The default connection had integrated security = true . Thanks a lot .. the site loaded. –  Jan 19 '15 at 19:53

1 Answers1

1

In connection string on IIS, I edited the default connection and provided the username and password for the db. The default connection had integrated security = true. I therefore changed that.