Connection Object in ASP.NET

G

Guest

I cannot successfully create a connection object in a web form. In the
page_load event I try the following code:

Dim sConnection As String = "server=MIDATLANTICUS;" & _
database=Pubs;integrated security=SSPI"
Dim conTest As New SqlConnection
conTest.ConnectionString = sConnection
conTest.Open()
conTest.Close()

I get an error saying that login failed for user
ElectroSource\IWAM_MIDATLANTICUS

The description I get is the following:

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.

My operating system is Windows 2000 Server and my server is a domain
controller and I'm programming with Visual Basic.NET 2003. I read an article
titled, BUG: IWAM Account Is Not Granted the Impersonate Privilege for
ASP.NET 1.1 on a Windows 2000 Domain Controller with SP4, but it still didn't
work when I did what the article suggested. Please help me resolve this
problem. What should I do? I should tell you that I am new to .NET and I
have never successfully created a connection object in a web form but I have
successfully created a connection object in a windows form. What do you
think I need to do?
 
K

Karl Seguin

Keith:
You are saying, in your connection string, to use integrated security. You
probably think that this will log you on with YOUR credentials. However,
since you likely have IIS set up to work anonymously, it isn't your
credentials but rather thsoe ofthe anonymous user asp.net is working under.
The simplest solution is that instead of using a trusted connection you use
SQL security:

Data Source=MIDATLANTICUS;Initial Catalog=pubs;User
Id=SomeSQLAccount;Password=SomePassword;"

while I don't recommend using the sa account, it certainly wouldn't hurt to
give it a try...

Karl
 
G

Guest

I have already tried what you suggest Karl. The error I get when I try it is
the following:

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

This puzzles me because I can successfully create the connection object in a
VB.NET windows form.

Maybe this tells you something and you can suggest something else. I really
appreciate your help. Hopefully we will get this solved. :)

I forgot to mention in my previous post that my domain is ELECTROSOURCE but
you probably figured that out.

Karl Seguin said:
Keith:
You are saying, in your connection string, to use integrated security. You
probably think that this will log you on with YOUR credentials. However,
since you likely have IIS set up to work anonymously, it isn't your
credentials but rather thsoe ofthe anonymous user asp.net is working under.
The simplest solution is that instead of using a trusted connection you use
SQL security:

Data Source=MIDATLANTICUS;Initial Catalog=pubs;User
Id=SomeSQLAccount;Password=SomePassword;"

while I don't recommend using the sa account, it certainly wouldn't hurt to
give it a try...

Karl
 
K

Karl Seguin

I think that means SQL Server isn't configured to allow SQL logins...only
windows authentication. You can do this by right clicking the server in
enterprise manager --> properties and one of the tabs has the security
settings...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


Keith Norris said:
I have already tried what you suggest Karl. The error I get when I try it is
the following:

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

This puzzles me because I can successfully create the connection object in a
VB.NET windows form.

Maybe this tells you something and you can suggest something else. I really
appreciate your help. Hopefully we will get this solved. :)

I forgot to mention in my previous post that my domain is ELECTROSOURCE but
you probably figured that out.
 
J

Juan T. Llibre

Try this connection :

"server=MIDATLANTICUS;Trusted_Connection=true;database=Pubs"



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 
G

Guest

When I configured the SQL Server to accept SQL server logins as well as
Windows logins the error changed slightly. The error message says, Login
failed for user 'username'. I think there is a problem with the IWAM
account and Impersenating a client after login. I read that this is a known
problem with Windows 2000 domain controlers that have service pack 4. I
don't know how to configure my computer for a work around if this is in fact
the problem. Thanks for trying to help. Hopefully my response will trigger
something.
 
G

Guest

This didn't solve the problem. Now I get an error saying login failed for
user 'username'. I think the problem may be with the IWAM account and
Impersenating a client after authentication. Apparantly this is a known
problem with Windows 2000 domain controllers with service pack 4. Maybe my
response will trigger something. I appreciate your willingness to help.
 
G

Guest

When I try this connection string I get an error saying Login failed for user
'ELECTROSOURCE\IWAM_MIDATLANTICUS'. I really think the IWAM account is not
configured properly. I think there is a known problem with that account on
Windows 2000 Servers that are domain controllers and have service pack 4.
Thanks for the suggestion.

Juan T. Llibre said:
Try this connection :

"server=MIDATLANTICUS;Trusted_Connection=true;database=Pubs"



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top