简体   繁体   中英

asmx web service error to connect sql server

I published a web service on a server and this web service is trying to connect to the sql server which is on the same server. This is my connection string:

Data Source=........\sqlexpress; Initial Catalog =mybooks; User Id =......; Password =......; Integrated Security=SSPI

I want to connect to sql using a sql user account so I used SSPI.
I created an app pool "mypool" for the service, runs under ApplicationPoolIdentity built-in account.
Web service gives error:

System.Data.SqlClient.SqlException: Cannot open database "mybooks" requested by the login. The login failed. Login failed for user "IIS APPPOOL\mypool"
  • Should I create sql login for IIS pool "mypool"? How can I create this login?
  • If I create sql login, is there a security issue?
  • Can I not login to sql using sql username and password?

Thanks for any help

Since you are using SSPI which means Integrated Security = true;

So your windows credentials will be used to authenticate to the sql-server. Not your sql-server username/password. (In your case, the user specified under application pool or web server process)

Just use sql-server username/password and do not use integrated security. Your username/password will be ignored when SSPI is used.

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM