why aspnet instead of logged in user when trusted_connection=yes

G

Guest

I am using the following code and it works when I have aspnet as a bona fide
user in the sql server database. Why doesn't the use of trusted connection
allow me as logged in user and dbo of database to access dbase. If I do not
have aspnet on the sql side I get login failed machinename/aspnet??

Dim myConnString As String =
"SERVER=fcstestbox;Trusted_Connection=yes;DATABASE=sex_offender_group;"
Dim myconnection As New System.Data.SqlClient.SqlConnection(myConnString)
Dim sqlstr As String = "insert into tblname
(fname,lname,clientID,dob,agetype) values('" & TextBox1.Text &
"','akin',1,'2/24/51','a')"
Dim objsqlcommand As New System.Data.SqlClient.SqlCommand(sqlstr,
myconnection)
myconnection.Open()
objsqlcommand.ExecuteNonQuery()
myconnection.Close()
 
C

Craig Deelsnyder

bindurajeesh said:
I am using the following code and it works when I have aspnet as a bona fide
user in the sql server database. Why doesn't the use of trusted connection
allow me as logged in user and dbo of database to access dbase. If I do not
have aspnet on the sql side I get login failed machinename/aspnet??

Dim myConnString As String =
"SERVER=fcstestbox;Trusted_Connection=yes;DATABASE=sex_offender_group;"
Dim myconnection As New System.Data.SqlClient.SqlConnection(myConnString)
Dim sqlstr As String = "insert into tblname
(fname,lname,clientID,dob,agetype) values('" & TextBox1.Text &
"','akin',1,'2/24/51','a')"
Dim objsqlcommand As New System.Data.SqlClient.SqlCommand(sqlstr,
myconnection)
myconnection.Open()
objsqlcommand.ExecuteNonQuery()
myconnection.Close()

It's called the one-hop rule; NTLM/credentials can only hop from one
computer to another once within a network. i.e. from the user's
browser/PC to your webserver = 1 hop. So even tho you impersonate on
the server, this rule stops it from being able to open the DB connection
as that user (= 2 hops). Falls back to machine account.

You have to either use Kerberos w/ forwarding on in your network
(usually not an option :) ), or grant access to the machine account (as
you've seen), or use a SQL account in your connection string.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top