Error in ASP.NET 2.0 Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection

Posted on 2007-11-14
Last Modified: 2013-11-07
I am running a linked server using windows authentication. WHen I run a query against the linked server it runs fine. However when I try to connect that to my ASP page and run that query i get an error. Everything else in the ASP site linked to this database runs fine, just not the linked server based query. I am getting the following error. I have impersenation set to true in my web.config as well.
This is ASP.NET 2.0, SQL 2005 linked to a SQL 2000 instance and Windows Authentication.

Here is my errors: any help?
TCP Provider: An existing connection was forcibly closed by the remote host.

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
Question by:edi77
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20287022
what is the connection string you use?

Author Comment

ID: 20288569
connection info:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="KitID"
                <asp:BoundField DataField="KitID" HeaderText="KitID" ReadOnly="True" SortExpression="KitID" />
                <asp:BoundField DataField="KitNumber" HeaderText="KitNumber" SortExpression="KitNumber" />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestADNIConnectionString %>"
            SelectCommand="SELECT [KitID], [KitNumber] FROM [FromLabKitsTable]"></asp:SqlDataSource>
also web config:

  <add name="TestADNIConnectionString" connectionString="Data Source=IN-MMGE-HLOWRLD;Initial Catalog=TestADNI;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  <roleManager enabled="false" />
            <identity impersonate="true"/>
  <customErrors mode="Off"/>

            <compilation debug="true"/>
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
            <authentication mode="Windows"/>
                  <allow roles="ADS\In-mmge-hd-admins"/>
                  <allow roles="ADS\In-mmge-hd-users"/>
                  <deny users="*"/>

Author Comment

ID: 20297954
hello anyone out there to help?
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20298025
did you define the windows accounts of the users and the asp account in your sql server?

Author Comment

ID: 20298114
i probably didn't? what do i need to do? my first time at all this. would you be able to give me some direction. that might be it.

Author Comment

ID: 20298130
in the linked server? or the main sql server? any asp page i hit from the main sql server works fine. its just the linked part that doesnt.  i tested the linked server connections under my user id (using windows auth for everything)

so i thought it should work at least as me but it doesnt...
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20298196
>or the main sql server?
yes, in the main sql server. open the security folder, logins, and create there the logins based on the windows accounts used (or the windows groups those users are member of).
than, grant that login the permissions in the database(s) ..

Author Comment

ID: 20298724
ok so i went into SQL under security i added a user login that is in my users group in ads.

then i made the db im using their defualt db.

is this what you mean or do they need something else?

now what are you saying about adding the asp account to my sql server?

Author Comment

ID: 20298739
ok so after adding that user to sql i am getting this error now....
seems better
Cannot open database "TestADNI" requested by the login. The login failed.
Login failed for user 'ADS\mmgehg'

this user can login into any other page that accesses the db just not this one, because this one is the linked server one. any idea what to do next?

Author Comment

ID: 20298771
so i just noticed when I login as ME -im the admin ---i get the null error
TCP Provider: An existing connection was forcibly closed by the remote host.
Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
when i login as this new user i created on sql i get the
Cannot open database "TestADNI" requested by the login. The login failed.
Login failed for user 'ADS\mmgehg'

my default db is master, mmgehg's the specific testadni db it needs.

LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 500 total points
ID: 20301718
you might want to read through this blog:

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Easy filter aspnet 2 36
transition to visual .net from vb6 5 64
Multi-Column Repeater 3 29
powershell try catch  and $ErrorActionPreference = continue 6 31
In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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