Showing posts with label posting. Show all posts
Showing posts with label posting. Show all posts

Saturday, February 25, 2012

connection string with authenticated user info

Hi. New to ASP.NET and first time posting.

My web app connects to a SQL database - SQL authentication.

Users login to the web app through the login server control. Once authenticated, it is my understanding that the user name and password are stored on the client as a cookie.

How do you programmatically get this user info and use it for the userid and password parameters of the connection string?

Is there a better way to use the authenticated user info to access a SQL database?

Thanks

Once authenticated (using asp.net login control), you can get the user info programmatically using:

Page

.User.Identity ( for example,Page.User.Identity.Name returns the username )|||

Thanks for the info.

I did some reading on Page.User.Identity, but don't understand how to get the password used for login. I need both the username and password to authenticate in SQL server.

Sunday, February 19, 2012

Connection String and login problems?

After posting and solving the last problem - I thought I'd post this one as it has got me a bit confused?

I am trying to connect to a local SQL Express database via an ASP website using the below connection string

Provider=SQLNCLI;Server=.\S15XXXX;Database=thenameofdb;Trusted_Connection=yes;

But I am getting the following error...

Microsoft SQL Native Client
Cannot open database "thenameofdb" requested by the login. The login failed.

I thought as I am using a trusted connection I didn't need to login? Have I got the connection string wrong? any help very much appreciated... Thanks
All sorted...

I just needed to add IUSR to the DB