473,800 Members | 2,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting COM components running in ASP.NET to connect to SQL Server databases

Sorry for the cross-post but I've really no idea where this is best suited.

I've an ADO.NET application which connects to a SQL Server database. I have
spent the entire morning trying to get it to connect, but eventually got it
working by setting (in the web.config file) the authentication mode to
"Windows" and the identity impersonate flag to "True". I have left the
identity username blank so that it picks up the username and password from
the IIS configuration windows.

This is working fine. However, at one stage in my application I create a COM
object and call a function within it. The COM object creates an ADO-classic
connection to the database. This connection is failing every time with the
following error:

Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.

The connection string it is using is as follows:

Provider=SQLOLE DB;SERVER=(serv ername);Trusted _Connection=yes ;Initial
Catalog=(dbname )

The IIS web site is configured to allow Anonymous access, and it has been
provided with the username and password of a domain user account. This user
is successfully being used by the ASP.NET and ADO.NET portion of my code.
But the COM and ADO-classic seems to be ignoring these settings.

My SQL Server only has Windows Authentication enabled (I am unable to use
SQL Server authentication due to company network policies).

What can I try doing in order to get this to work? I'm tearing my hair out
with this at the moment as I just can't find a strategy to move this
forward.

My thanks in advance,

--

(O)enone
Nov 19 '05 #1
7 1514
This is a classic issue. Consider that in an ASP application, it's IIS that
"owns" the connection and the ASP pages that get launched. As such it has
its own identity "ASPNET". This means you need to create a Login Account in
SQL Server to connect to the Windows account "ASPNET" and grant it rights to
the appropriate objects (and just those objects).

hth

--
_______________ _______________ ______
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
_______________ _______________ ____

"Oenone" <oe****@nowhere .com> wrote in message
news:ul******** ******@TK2MSFTN GP09.phx.gbl...
Sorry for the cross-post but I've really no idea where this is best
suited.

I've an ADO.NET application which connects to a SQL Server database. I
have spent the entire morning trying to get it to connect, but eventually
got it working by setting (in the web.config file) the authentication mode
to "Windows" and the identity impersonate flag to "True". I have left the
identity username blank so that it picks up the username and password from
the IIS configuration windows.

This is working fine. However, at one stage in my application I create a
COM object and call a function within it. The COM object creates an
ADO-classic connection to the database. This connection is failing every
time with the following error:

Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.

The connection string it is using is as follows:

Provider=SQLOLE DB;SERVER=(serv ername);Trusted _Connection=yes ;Initial
Catalog=(dbname )

The IIS web site is configured to allow Anonymous access, and it has been
provided with the username and password of a domain user account. This
user is successfully being used by the ASP.NET and ADO.NET portion of my
code. But the COM and ADO-classic seems to be ignoring these settings.

My SQL Server only has Windows Authentication enabled (I am unable to use
SQL Server authentication due to company network policies).

What can I try doing in order to get this to work? I'm tearing my hair out
with this at the moment as I just can't find a strategy to move this
forward.

My thanks in advance,

--

(O)enone

Nov 19 '05 #2
William (Bill) Vaughn wrote:
This is a classic issue. Consider that in an ASP application, it's
IIS that "owns" the connection and the ASP pages that get launched.
As such it has its own identity "ASPNET". This means you need to
create a Login Account in SQL Server to connect to the Windows
account "ASPNET" and grant it rights to the appropriate objects (and
just those objects).


Hi Bill,

Thanks for the reply. I'm not sure this is actually the problem though...

With a combination of Windows authentication and impersonation, I've already
configured the IIS session to use a different user identity to ASPNET (I'm
using a domain account which we have created called IUSR_IIS). I can see
that the ASP.NET connection is successfully logging into the database using
this username (and not ASPNET).

However the ASP-classic connection (created within the COM object) appears
not to be using the IUSR_IIS credentials that the main process is using.

Could it be that the COM object is somehow falling back to the
non-impersonated identity?

Thanks,

--

(O) e n o n e
Nov 19 '05 #3
It could be. I usually recommend use of application-specific logons. I use
other techniques to validate the user using my own "valid user" tables. This
lets me tune what the user sees and can do based on their "rights" specified
by this server-based table. It's a lot easier than trying to figure out how
to get Kerberos to work.

--
_______________ _______________ ______
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
_______________ _______________ ____

"Oenone" <oe****@nowhere .com> wrote in message
news:AQ******** ***********@new sfe1-win.ntli.net...
William (Bill) Vaughn wrote:
This is a classic issue. Consider that in an ASP application, it's
IIS that "owns" the connection and the ASP pages that get launched.
As such it has its own identity "ASPNET". This means you need to
create a Login Account in SQL Server to connect to the Windows
account "ASPNET" and grant it rights to the appropriate objects (and
just those objects).


Hi Bill,

Thanks for the reply. I'm not sure this is actually the problem though...

With a combination of Windows authentication and impersonation, I've
already
configured the IIS session to use a different user identity to ASPNET (I'm
using a domain account which we have created called IUSR_IIS). I can see
that the ASP.NET connection is successfully logging into the database
using
this username (and not ASPNET).

However the ASP-classic connection (created within the COM object) appears
not to be using the IUSR_IIS credentials that the main process is using.

Could it be that the COM object is somehow falling back to the
non-impersonated identity?

Thanks,

--

(O) e n o n e

Nov 19 '05 #4
COM uses the process identity to call-out, while ADO.NET uses the
impersonated thread context.
So in your case COM uses "aspnet" to call out, while ado.net uses the domain
account.
One option to solve this issue is to changed the identity of the worker
process from aspnet into the same domain account, but I would never suggest
to run asp.net using a domain identity. I suggest you don't use integrated
security to concet to SQL server, but supply explicit SQL credentials in
your conncetion string(s). These credentials can better be encrypted and
stored in your config file.
Willy.
Willy.

"Oenone" <oe****@nowhere .com> wrote in message
news:AQ******** ***********@new sfe1-win.ntli.net...
William (Bill) Vaughn wrote:
This is a classic issue. Consider that in an ASP application, it's
IIS that "owns" the connection and the ASP pages that get launched.
As such it has its own identity "ASPNET". This means you need to
create a Login Account in SQL Server to connect to the Windows
account "ASPNET" and grant it rights to the appropriate objects (and
just those objects).


Hi Bill,

Thanks for the reply. I'm not sure this is actually the problem though...

With a combination of Windows authentication and impersonation, I've
already
configured the IIS session to use a different user identity to ASPNET (I'm
using a domain account which we have created called IUSR_IIS). I can see
that the ASP.NET connection is successfully logging into the database
using
this username (and not ASPNET).

However the ASP-classic connection (created within the COM object) appears
not to be using the IUSR_IIS credentials that the main process is using.

Could it be that the COM object is somehow falling back to the
non-impersonated identity?

Thanks,

--

(O) e n o n e

Nov 19 '05 #5
Willy Denoyette [MVP] wrote:
So in your case COM uses "aspnet" to call out, while ado.net uses the
domain account.
Many thanks for that -- I can see a way to progress in this case. And I
still have a little bit of hair left too. :-)
I suggest you
don't use integrated security to concet to SQL server, but supply
explicit SQL credentials in your conncetion string(s). These
credentials can better be encrypted and stored in your config file.


By this do you mean to use SQL Server authentication instead of Windows
authentication? If so then whilst I don't disagree with what you're saying,
I'm not sure it is an option for me (we don't permit SQL Server
authentication on any of our servers as part of our company security
policy). It may be better for me to just permit the ASPNET user to access
the databases on the SQL Server and allow COM to access them like that.

Thanks for your help,

--

(O) e n o n e
Nov 19 '05 #6

"Oenone" <oe****@nowhere .com> wrote in message
news:p7******** **********@news fe1-win.ntli.net...
Willy Denoyette [MVP] wrote:
So in your case COM uses "aspnet" to call out, while ado.net uses the
domain account.


Many thanks for that -- I can see a way to progress in this case. And I
still have a little bit of hair left too. :-)
I suggest you
don't use integrated security to concet to SQL server, but supply
explicit SQL credentials in your conncetion string(s). These
credentials can better be encrypted and stored in your config file.


By this do you mean to use SQL Server authentication instead of Windows
authentication? If so then whilst I don't disagree with what you're
saying,
I'm not sure it is an option for me (we don't permit SQL Server
authentication on any of our servers as part of our company security
policy). It may be better for me to just permit the ASPNET user to access
the databases on the SQL Server and allow COM to access them like that.

Thanks for your help,

--

(O) e n o n e


You won't be able to access SQLServer on another server using the "aspnet"
account. ASPNET is a local (machine) account (auto-generated) with
restricted privileges (doesn't have network privileges at all).
So, your options are rather limitted:
Run the asp.net worker process using domain credentials (not sure the the
company security policy allows this), or,
drop your DAL in a COM+ (System.Enterpr iseServices classes) server type
application that runs with fixed windows credentials.

Willy.

Nov 19 '05 #7
Willy Denoyette [MVP] wrote:
So, your options are rather limitted:
Run the asp.net worker process using domain credentials


Could you by any chance point me to a resource that explains how to do this?

Many thanks,

--

(O)enone
Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8179
by: Linda Lee | last post by:
I purchased Visual Basic .NET version 2003 Standard I first try to connect Visual Basic .NET 2003 Standard to SQL Server 2000 Personal edition. When I go into Visual Basic .NET under Server Explorer and try to add the connection, I received the following message "Unable to connect to database. It is only possible to connect to SQL Server Desktop Engine databases and Microsoft Access Databases with this version of Visual Studio." Then...
3
2478
by: Dad | last post by:
I need to connect SQL Server 2000 to DB2 on z/OS through DB2 Connect 8. I can successfully connect and query data through a System DSN, but trying to link the server using this DSN and MSDASQL fails (can't seem to find the DB2 Connect server). I've also tried IBM's OLE/DB driver (IBMDADB2). Has anyone successfully linked to DB2 on a mainframe through DB2 Connect 8.x via either ODBC or OLE/DB drivers?
2
2123
by: David Hearn | last post by:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. 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. SQLExpress database file auto-creation error: The connection string specifies a local SQL Server Express instance using a...
2
1630
by: Steve Gollery | last post by:
I installed Postgres 8 beta 3 on an XP box, with Postgres running as a service. TaskManager tells me that postgres and postmaster are both running. Using pgAdmin III, I can connect to the server and create users, databases, tables, etc. But at the command line, on the same machine where the service is running, executing createdb mydb
5
5741
by: Nathan Given | last post by:
Hello All, I've been struggling on and off for 3 months trying to connect to an DB2 database running on an IBM iSeries machine. I FINALLY figured out how to connect with Coldfusion (see instructions below). So, now I am trying to connect to the same database with MS Access. I want to link the tables within Access so I can quickly query and answer
4
10728
by: Odd Bjørn Andersen | last post by:
I have installed DB2 9 Enterprise Edition on my laptop (Windows xp prof. ed.). But when I try to connect to any of my local databases I get this error: SQL30082N Security processing failed with reason "19" ("USERID DISABLED or RESTRICTED"). SQLSTATE=08001 I am quite certain that this user is valid, I have used it to log on to the pc. The properties of the user also looks fine -password never expires, and the disabled checkbox is NOT...
0
1287
by: mogenses | last post by:
This is going to be a good one but may be easy for you experts. I have recently joined a tech support dept supporting an application using ACCESS 2.0 DATABASES and I believe written in Fox Pro. Yes, its 16 bit and still running for many clients (We're working on the new version.). We run WOWExe, NTVDM and a NWAdministrator application which allows workgrouped Nodes to access a central db. I had a client who could not connect to the DB. ...
0
1561
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the databases in that server. Then after the user selects a database, I have another button that he/she click and I want to retrieve file groups from a specific table. At this point when he/she clicks on that button I get an error:
4
2669
by: lage | last post by:
I am working with a system using a Com+ layer built in VB6. I am now trying to use these components from VB.Net. I have added the component as reference and .Net seem to communicate with the component. I am using the following code to connect: Dim adm_event As Admin.Event adm_event = CreateObject("admin.event") While running the procedure I get the error:
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10250
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.