Solved

Login failed for user 'null"

Posted on 2009-05-07
12
332 Views
Last Modified: 2013-12-17
Good afternoon expert,

Using
    <connectionStrings>
        <add name="TimeEntry_bConnectionString" connectionString="Data Source=labsdirvg600;Initial Catalog=TimeEntry_b;Integrated Security=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
I get

Login failed for user '(null)'. Reason: 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 '(null)'. Reason: Not associated with a trusted SQL Server connection.

So i found a service account called WTE at the SQL server with a login and made WTE a user on the database. Then I made WTE a user on the Web server and at Edit Anonymous user on the IIS property of the web site mad the user WTE.

THen changed the web.config to
    <appSettings/>
    <connectionStrings>
        <add name="TimeEntry_bConnectionString"
       
        connectionString="Server=labsdirvg600;Database=TimeEntry_b;User ID=WTE;Password=King0n1;Trusted_Connection=False;"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
I then get
Login falied for user WTE

What am I doing wrong?

Thanks

Allen In Dallas
0
Comment
Question by:9apit
  • 5
  • 4
  • 3
12 Comments
 
LVL 18

Expert Comment

by:David Robitaille
ID: 24329071
check under properties of the SQL server (Right click), in "security" page (on left), make sure the server authentication is set to "SQL SERVER and Windows Authentication Mode"
0
 

Author Comment

by:9apit
ID: 24329178
Yes the server is set for mixed mode
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 24329195
then try with SA (if you have the password)
if it work, you will know it<s a problem int the SQL server  user.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 18

Expert Comment

by:David Robitaille
ID: 24329245
you could also try this
connectionString="Data Source=labsdirvg600;Initial Catalog=TimeEntry_b;User ID=WTE;Password=King0n1;Persist Security Info=True"

0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24330242
You might need the full domain for the user
 
 WTE@domain.com
0
 

Author Comment

by:9apit
ID: 24330614
Tried it both ways with and with the domain name. Same result. Inserted    
 <identity impersonate="true" /> in web.config.
The web app worked on the local machine but not on any remote
computer. And when iinserted the name of the machine in the URL
in address instead of 'localhost' the error reappeared. Wierd.
THen after that the Login failed for user 'null" appears on the local
machine no matter how I call it.
0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24330664
Can you Ping the Machine Name?
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 24331372
and doid you allow TCP/ip for the SQL server?
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 24331383
0
 

Accepted Solution

by:
9apit earned 0 total points
ID: 24331424
Success.

There are two types of connection strings.
One uses a trusted connection. The other uses
a username and password. Used the latter
and set up an account with those credentials at the DB.

I think my mistake was thinking that the
the credentials at the web server had to be
the same as the credential at the SQL Server.
It is true that the log in the local Windows user has to be the
same as the Anonymous User at the IIS
Properties. This calls the web.config.
Then the credentials in the web.config have to
be the same as the credentials in the SQL server
security login. But the credentials at the web server
do not have to match authentication at the DB
server.
 
Allen
0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24331784
Did any of our answers rule out possibilities and help you arrive at your answer quicker?
0
 

Author Comment

by:9apit
ID: 24331819
Good evening Mr. Campbell,

Perhaps the problem that I posed is so integrated to the
environment in which I was troubleshooting that it would
be almost impossible for someone not in that environment
to take an deductive approach to a solution.

To answer your question, no, only one of thel the answers
I got had to do with the connection string and it wasn't
even close.

Thanks.

Allen
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question