Results 1 to 9 of 9

Thread: VS2010 ASP > SQL Connections

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    26

    VS2010 ASP > SQL Connections

    Hi,

    I have an ASP.Net website running on IIS7.
    The Application Pool is set to ASPv4 Classic.
    Authentication Mode is set to ASP.Net Authentication & Windows Authentication

    My question is, when I want to connect to SQL using a "trusted connection" in the Connection String, what user will actually be passed into SQL?

    I thought it would pass my logon details, but it is coming back with an NT AUTHORITY\ANONYMOUS LOGON error, which seems to point towards it not passing in my logon.

    Is this expected behaviour?
    Last edited by davieeeee; Aug 10th, 2011 at 02:26 AM.

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: VS2010 ASP > SQL Connections

    Will the db has the all the user logins created in it ?

    Did you add <identity impersonate="true" /> in the web.config
    Last edited by danasegarane; Aug 10th, 2011 at 02:27 AM.
    Please mark you thread resolved using the Thread Tools as shown

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    26

    Re: VS2010 ASP > SQL Connections

    No it wont, which brings up a good point.
    I assume that I should not worry about individual user level access to the database then and just create a single ASP logon in SQL?

  4. #4
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: VS2010 ASP > SQL Connections

    Yes Create single user login and password and then add this in the web.config file

    Code:
    <identity impersonate="true" userName="domain\user" password="password" />
    Please mark you thread resolved using the Thread Tools as shown

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    26

    Re: VS2010 ASP > SQL Connections

    By placing that in the web.config, will that still recognize the logged in user? (this is an intranet application)

    I need the user to be recognized for authentication purposes (so I can control menu items etc) however access to SQL via a single logon is acceptable.

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: VS2010 ASP > SQL Connections

    Hello,

    If you are not going to provide user level permissions at the database, then you are not going to be able to pass the credentials of the logged in user to the database, as they will not be able to access the database.

    Gary

  7. #7
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: VS2010 ASP > SQL Connections

    Quote Originally Posted by davieeeee View Post
    By placing that in the web.config, will that still recognize the logged in user? (this is an intranet application)

    I need the user to be recognized for authentication purposes (so I can control menu items etc) however access to SQL via a single logon is acceptable.
    Yes that will consider as the logged in user. User.Identity.Name will give the user name and when connecting to user the system will try to connect using the impersonated user name and password..
    Please mark you thread resolved using the Thread Tools as shown

  8. #8
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Re: VS2010 ASP > SQL Connections

    If you are using a single SQL login, why not just use:

    Dim strConnectString = _
    "Persist Security Info=False;server=MyServer;" & _
    "database=MyDB;User ID=MySQLLogin;Password=MyPassword"
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  9. #9
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: VS2010 ASP > SQL Connections

    Assuming of course the above was in a web.config file, so that you didn't have to re-compile your application, just to change the database connection string

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width