The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Mar 3, 2011 at 11:51 AM

We are trying to setup slickticket on a machine but seem unable to resolve some issues. Primarily the AD integration.

Our Setup currently is

win2k3r2 AD and child domain Forrest running in 2000AD mode and child AD running in 2000AD mode.

Exchange 2003

Server we wanted to install on

Win2k8r2 Sql2008express.

Must the sql server be 2005 or 2005 express? and the windows version will 2008r2 do or must it be 2003? IIS should it be iis6 or is 7.0 and 7.5 fine?

We have tried to use the default configuration connection string in the web.config file to connect to sql no luck. The only thing we changed is the datasource to (servername or localhost)

On trying to create the database the following error comes up.

An error occured: System.Data.SqlClient.SqlException: Cannot open database "SlickTicket" requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at setup_build_database.btnRunSQL_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\itdept\setup\build_database.aspx.cs:line 44

 

 

Coordinator
Mar 4, 2011 at 1:03 AM

This is simply a SQL login error - your user NT AUTHORITY\NETWORK SERVICE that you are using, does not have access to the db.  Check the error:

An error occured: System.Data.SqlClient.SqlException: Cannot open database "SlickTicket" requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

Mar 15, 2011 at 7:09 PM

Hi, I am having exactly the same issue and have tried many and varied different ways to solve it but it keeps coming back down to the same error in setup/activedirectory.aspx.cs :

 

        if (!IsPostBack)
        {
            foreach (security_level s in (from p in db.security_levels where p.id > 1 select p))   << Cannot open database 'SlickTicket' requested by the login. The Login failed. Login failed for user 'win7-imac\myusername'
                ddlLevels.Items.Add(new ListItem(s.id.ToString() + " " + s.security_level_name, s.id.ToString()));

            foreach (string v in Groups().ToArray())
            {
                string[] split = v.Split(new char[] { '\\' });
                ddlAD.Items.Add(new ListItem((split.Length == 1 ? v : split[1])));
            }
        }

I understand 'win7-imac\myusername' needs access to the database but for some reason when I go into SQL and look under

'Security>Logins'  I have a login 'sa' and under

'Secutiry>Users' I have a User named 'dbo' which uses the login 'sa'

So 'dbo is my default user name and cannot be changed so I tried to create a Login 'win7-imac\myusername' which was fine but when I went to assign it to a username it says that 'sa' is already using 'win7-imac\myusername' so I am a bit confused as to how I am supposed to create the login for my windows username in SQL?

Any help would be great thanks!

Coordinator
Mar 15, 2011 at 8:33 PM

You need to go into SQL Management Studio and add a Login under the security tab of the *root* of your SQL Connection, then add it to the Database you want to use it.  YOu need to make sure it is mapped to the proper database and given the proper read/write permissions.

A SQL forum might be a better place to get help for this as it is simply a SQL login issue.

Mar 16, 2011 at 11:30 AM

This is what i've done, I went straight under the win7-imac\myservername >> Security Tab and added the win7-imac\myusername login however when I go to add the new username to the slickticket database I create new user then select the win7-imac\myusername login and give it a username but it fails and says 'Create failed for user win7-imac\myusername' 'the login already has an account under a different username'

I am failing to understand why it is that I can log in to my sql server through sql managment studio with the details

ServerName: win7-imac\myservername

Authentication: Windows Authentication

Login: win7-imac\myusername


And this works no problem, it allows me to create, update and delete the slickticket database but asp.net fails when its using exactly the same login details to login?

Asp.Net failure message:

An error occured: System.Data.SqlClient.SqlException: Cannot open database "SlickTicket" requested by the login. The login failed. Login failed for user 'win7-imac\myusername'.


Here is my web.config connection string:

    <remove name="SlickTicket" />
        <add name="SlickTicket" connectionString="Data Source=WIN7-IMAC\myservername; Initial Catalog=SlickTicket; Integrated Security=True;" providerName="System.Data.SqlClient"/>

Ive also tried:

<add name="SlickTicket" connectionString="Data Source=WIN7-IMAC\myservername; Initial Catalog=SlickTicket; user id=imac\myusername; password=mypassword" providerName="System.Data.SqlClient"/>

 

I'm losing the will now as i've spent hours trying to get this to work, but I really want to get it working as it looks like an awsome piece of kit.

Coordinator
Mar 16, 2011 at 1:38 PM

The application does not use your login credentials, it uses a service account set in IIS.

Mar 17, 2011 at 1:20 AM

Ok after restarting my computer several times sql has finally decided to let me add the user to the database so I have now added the login win7-imac\myusername and also managed to add the user win7-imac\myusername to the slickticket database, I have tested the login independantly and it works fine but I still get the sam error when running the set up?

Coordinator
Mar 17, 2011 at 3:46 PM

Sorry, I really don't know what to tell you, you probably want to try a .net or SQL forum - this isn't a problem with the software, it is a problem with your connection.

Nov 25, 2014 at 10:31 PM
Edited Nov 25, 2014 at 10:33 PM
Hi Naspinski,
Actually, it's not an SQL login issue because that works. Proven by dropping a gridview on a form, using the same connection string, and accessing data in a table I built. Looks fine. So I can log into the SQL database.
So... this isn't really a "cant connect to SQL issue". This has something to do with it not using that connection string. You mentioned "It uses a service account in IIS" so that is not the connection string. It really IS a software problem in that the setup is not only with the connection string. So there are things that are not documented that need to be setup.

Also note that the "Login failed for user ... XXX" is not part of the connection string so where is that coming from? Answer that and you are going to be more helpful.