What to write in webconfig file when use Web Authentication in Asp.net

238 views Asked by At

I have this problem:

What to write in webconfig file when use Web Authentication in Asp.net?

As what do I know if use Web Authentication in Asp.net dont have to put user id and password. So this is the original coding in webconfig file:

add name="HibahTotalConnectionString" connectionString="Data Source=HTP7526\SQLEXPRESS_2;Initial Catalog=HIBAHV4;Persist Security Info=True; User ID=sa;Password=uts" providerName="System.Data.SqlClient"/>

And, I had replace the User ID=sa;Password=uts part with this Integrated Security=SSPI but it doesnt work. When I run my webpage it says cannot connect to database.

1

There are 1 answers

1
cdlk On

Setting Integrated Security=SSPI means your Web application will try to connect to the database using the Windows account which the Web application is running under. Assuming you're running this application in IIS, this will be an IIS user account for the local system by default.

You could make sure that the local IIS user has permission to access the database but this probably won't work if the database is on a different machine. Probably a better solution is to configure the application pool to run as a different Windows (domain) user who does have permission to access the database.