Solved

Error with ASP.NET 2.0 page running a linked server query

Posted on 2007-11-14
10
312 Views
Last Modified: 2011-09-20
I have a query i want to run via my asp webpage. It runs fine in SQL Server 2005. It's based on a linked server. However when I tried to throw this query up in ASP. I get the following error. I need someone to help me figure out what this means in plain engrish. I don't really know what to do...

The OLE DB provider "SQLNCLI" for linked server "IN-MMGE-CELLLAB" reported an error. Authentication failed.
Cannot initialize the data source object of OLE DB provider "SQLNCLI" for linked server "IN-MMGE-CELLLAB".

Stack Trace:


[SqlException (0x80131904): The OLE DB provider "SQLNCLI" for linked server "IN-MMGE-CELLLAB" reported an error. Authentication failed.
Cannot initialize the data source object of OLE DB provider "SQLNCLI" for linked server "IN-MMGE-CELLLAB".]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +862234
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +739110
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1956
   System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +31
   System.Data.SqlClient.SqlDataReader.get_MetaData() +62
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +297
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +903
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +122
   System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12
   System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +7
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +141
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +137
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1770
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
   System.Web.UI.WebControls.GridView.DataBind() +4
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69
   System.Web.UI.Control.EnsureChildControls() +87
   System.Web.UI.Control.PreRenderRecursiveInternal() +41
   System.Web.UI.Control.PreRenderRecursiveInternal() +161
   System.Web.UI.Control.PreRenderRecursiveInternal() +161
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360

 
0
Comment
Question by:edi77
  • 5
  • 5
10 Comments
 
LVL 37

Assisted Solution

by:samtran0331
samtran0331 earned 500 total points
ID: 20284044
I don't think the problem is because you're using a linked server, it's a problem with the connection string, does your connection string include a username/password with access to the db server?
0
 

Author Comment

by:edi77
ID: 20284092
no i think its using the same connection string i used for other tables in the website. how would the syntax look?
0
 
LVL 37

Assisted Solution

by:samtran0331
samtran0331 earned 500 total points
ID: 20284180
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 37

Assisted Solution

by:samtran0331
samtran0331 earned 500 total points
ID: 20284201
0
 

Author Comment

by:edi77
ID: 20284314
you meanthe connection string  from asp to the query right because the query works between the linked sql server instances
0
 
LVL 37

Assisted Solution

by:samtran0331
samtran0331 earned 500 total points
ID: 20288565
>>you meanthe connection string  from asp to the query right

yes, because if you're using sql2005 management studio, you're logging into the db servers with either your windows username/password (in which case the app is not using the same) or a username/password that exists in the db servers (which should be part of your app's conn string)...
0
 

Author Comment

by:edi77
ID: 20289333
but im using windows authentication so im logging into the app with my network password.

so i cant put that in the connection string for everyone who will use the app....

how would that look? not sure exactly what you mean can u give me an example of the syntax in the connection string u mean?
0
 
LVL 37

Assisted Solution

by:samtran0331
samtran0331 earned 500 total points
ID: 20289410
>>but im using windows authentication so im logging into the app with my network password
That gets you into the application, but unless you are using impersonation, the app is still using the default account NETWORK SERVICE (IIS6), if lower version of IIS, it's using the account ASPNET.
So when the app communicates with other servers (like the DB server) it is using one of those accounts.
Usually what I do, is create a user on the DB server(s) called "webapps" and then any connection string a web app(s) uses, I use the username and password for the "webapps" db account.
What connectionstring do you have currently?
0
 

Author Comment

by:edi77
ID: 20289899
ok i actually am using impersonation actually.  do u use windows authentication? or forms when you create your webapps person? cuz im using windows auth.

can u show me an example of the syntax u use for your conn string?

all i did for my connection string was use gridview and bind the query(view) using the same connection string i set for the rest of the tables and in the web config. of course these others are not using a linked server.

this is what my web config looks like
<connectionStrings>
  <add name="TestADNIConnectionString" connectionString="Data Source=IN-MMGE-HLOWRLD;Initial Catalog=TestADNI;Integrated Security=True"
   providerName="System.Data.SqlClient" />
 </connectionStrings>
      <system.web>
              
  <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"/>
            <authorization>
            
                  <allow roles="ADS\In-mmge-hd-admins"/>
                  <allow roles="ADS\In-mmge-hd-users"/>
                  
                  <deny users="*"/>
                  
            </authorization>
0
 

Accepted Solution

by:
edi77 earned 0 total points
ID: 20289905
ok i actually am using impersonation actually.  do u use windows authentication? or forms when you create your webapps person? cuz im using windows auth.

can u show me an example of the syntax u use for your conn string?

all i did for my connection string was use gridview and bind the query(view) using the same connection string i set for the rest of the tables and in the web config. of course these others are not using a linked server.

this is what my web config looks like
<connectionStrings>
  <add name="TestADNIConnectionString" connectionString="Data Source=IN-MMGE-HLOWRLD;Initial Catalog=TestADNI;Integrated Security=True"
   providerName="System.Data.SqlClient" />
 </connectionStrings>
      <system.web>
              
  <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"/>
            <authorization>
            
                  <allow roles="ADS\In-mmge-hd-admins"/>
                  <allow roles="ADS\In-mmge-hd-users"/>
                  
                  <deny users="*"/>
                  
            </authorization>
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

766 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