Navigation

Login failed for user iis apppool default apppool System.Data.Sqlclient.Sqlexception

IIS, Login failed user, Application Pool, Login failed for user iis apppool, System.Data.SqlClient.SqlException

Introduction

I am here highlighting the difficulty System.Data.Sqlclient.Sqlexception:Login failed for user iis apppool \default apppool usually encountering whereas working with ASP.Net application with IIS. I actually have been engaged on web application. Everything was going fine however suddenly I got the error “System.Data.SqlClient.SqlException was unhandled by user code:  Login failed for user 'IIS APPPOOL\DefaultAppPool’” and database connection couldn't open.

Error Description:

System.Data.SqlClient.SqlException was unhandled by user code:  Login failed for user 'IIS APPPOOL\DefaultAppPool

Know How About Application Pool Identity 

Application Pool Identity corresponds to security of your website whereas running your website under IIS. Application Pool Identity runs your website unique account. Network service is IIS default identity, it doesn't need password so caused low prevailed. You'll reconfigure IIS Application Pool Identities as per your specific demand.
I have below provided steps to resolve this issue.
Step 1: Go to Run (Win+R Shortcut) and then type “inetmgr” and hit “OK” button.

Step 2: Now you are in the IIS and now expand left pane and click on the “Application Pools

Login failed for user iis apppool
IIS (Application Pool)



Step 3: Now you can select “DefaultAppPool” and click on “Advance Settings”.

Step 4: Now open “Advance Settings” window and scroll down window to “Process Model”. Under the “Process Model” section select “Identity” property. Select “LocalSystem” from drop down list. Local Service works the computer on local system & over the local computer.

Application Pool Identity
Application Pool Identity
Step 5: Process Model Element was introduced with IIS 7.0
Step 6: "ApplicationPoolIdentity" runs under dynamically created application pools. identity account. "ApplicationPoolIdentity" pool access the resources from IIS AppPool\<AppPool>, It's nice feature to administrator who will impose security privileges to end users. This is often run mostly for remotely or public accessing the website.

ApplicationPoolIdentity
ApplicationPoolIdentity

Step 7: Now Click on "OK" button, you have to take optional Step 4 or step 6 to run your application smoothly.

OK

By Command line, we can also provide complete access to DefaultAppPool (if Already complete access to production server)


ICACLS test.txt /grant "IIS AppPool\DefaultAppPool":F

Summary

Given above steps will provide you complete helpline, the way to resolve the error of “Login failed for user 'IIS APPPOOL\DefaultAppPool’”. Application pool identity need default permission to run your website under IIS perfectly for specific account access group.  I hope steps provided above will work to resolve your problem perfectly.

Relevant Reading:

Videologin failed for user

Share

Anjan Kant

Outstanding journey in Microsoft Technologies (ASP.Net, C#, SQL Programming, WPF, Silverlight, WCF etc.), client side technologies AngularJS, KnockoutJS, Javascript, Ajax Calls, Json and Hybrid apps etc. I love to devote free time in writing, blogging, social networking and adventurous life

Post A Comment:

23 comments:

  1. Thank you very much !!! worked for me !!!

    ReplyDelete
  2. Thank you very much for your suggestion

    ReplyDelete
  3. Perfect. I had the problem when I tried to log through web service into SQL Express 2005 And this solved it. Thank you and keep up the good work

    ReplyDelete
  4. In iis 6 how to get application pool

    ReplyDelete
    Replies
    1. Hi Ganesh,
      IIS 6.0 The element replaces some of the settings in the IIS 6.0 IIsApplicationPools metabase object. you may check also given link http://www.iis.net/configreference/system.applicationhost/applicationpools/add/processmodel

      Delete
    2. moreover check it also http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/ee81b97b-b967-48f7-8ce9-1796a2e994fd.mspx?mfr=true

      Delete
  5. thank u very much .. much usefull

    ReplyDelete
  6. am trying to access a web service from android application, the application pool identity is already set to applicationPoolIdentity . but still the error is exist

    ReplyDelete
    Replies
    1. Marwan, did you tried "Localservice" if are you using in your local system if remotely then set to "ApplicationPoolIdenity", sometimes this problem also arise from "IntegratedSecurity=True" in web.config, in fact, I think are you using SQL authentication.
      Hope it will work for you otherwise let me know.

      Delete
  7. it shows the same error in both case
    please tell me whats the problem

    ReplyDelete
    Replies
    1. Jay, are you hosted on remote machine or on your local development machine...

      Delete
  8. Replies
    1. Welcome, keep visiting to follow latest tutorials here

      Delete
  9. Hi... I have calling my webapi from a asp.net application with windows authentication. But i am getting username as IIS APPPool/user. Both the applications are configured for windows authentication. Can u pls help me.

    ReplyDelete
    Replies
    1. Can you ensure all steps provided here and check permissions already granted to IIS_IUSRS to get windows default permissions, physical folders and IIS.

      Delete
  10. can u please help in profering solution to this error?

    Server Error in '/eHotel' Application.


    Cannot open database "Crescent" requested by the login. The login failed.
    Login failed for user 'sa'.
    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: Cannot open database "Crescent" requested by the login. The login failed.
    Login failed for user 'sa'.

    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): Cannot open database "Crescent" requested by the login. The login failed.
    Login failed for user 'sa'.]
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5096486
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2294
    System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +35
    System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +245
    System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +703
    System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
    System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232
    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
    System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33
    System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524
    System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
    System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479
    System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108
    System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
    System.Data.SqlClient.SqlConnection.Open() +125
    DivineHotel._default._Default.checkdate() +196
    DivineHotel._default._Default.Page_Load(Object sender, EventArgs e) +4295
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
    System.Web.UI.Control.OnLoad(EventArgs e) +91
    System.Web.UI.Control.LoadRecursive() +74
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.233

    ReplyDelete
    Replies
    1. First check your username & password provided in web.config & also try to connect directly with SQL Server Management. Again check your connection string configured correctly in web.config.

      Delete