-1

I have an MVC web application on Windows Server 2019 with SQL Server 2017.

When I read/write to the database, if I add credentials on connection string or I remove the credentials, the database can be read/write.

I have create a user in IUSR group, with credentials and I have create a new Pool Application, but the problem is not solved.

Some one can help me?

5
  • There can be multiple ways to connect to a SQL server instance from a web app on IIS, so you need to clearly tell your requirements. Do you want a dedicated account to be used, or you want to enable something like impersonation? People can only help when more details are provided. Commented Oct 15, 2024 at 20:57
  • Ok, i hope to help you, i have developed an application mvc (phone book for example) and each my user has a database. When a user log in the application, i need to open the db that is associated to this user using credentials that i found in the connection string. What is the best or correct mode to do this? Commented Oct 16, 2024 at 7:24
  • I will suggest you rethink the design of this app before moving further and bumping into other issues. 1) "each my user has a database" might be a bad design, unless you really need to isolate user data from each other. 2) "When a user log in the application", so what's the authentication method you use? That can impact a lot on other options you have at hand. At this stage, I think it is more like a Stack Overflow question when you might collect tips to improve the app rather than a question here for final deployment. Commented Oct 16, 2024 at 7:42
  • Correct what you say, but not in this particular case. My app is a software to business management, each user is a company, so each user need a db for security and privacy. In this moment my app manages multiple companies and multiple databases, I use only one application pool, and the database change is done based on the login done by the code. and work correctly, but i wan set credentials on connection string. Differently for another application, with 1 user 1 db 1 application pool, the authentication problem remains and I can't solve it. Commented Oct 16, 2024 at 9:12
  • Then that's a very strange isolation (shared web app but isolated databases). Full isolation (isolated web apps and isolated databases) might be better and prevent data leaking from one company from another. Anyway you figured out the culprit, so you should accept your own answer. Commented Oct 16, 2024 at 19:20

2 Answers 2

0

If you are using integrated authentication, set 'Integrated Security=true;' in the connection string instead of specifying the credentials.

If you are using forms-based authentication and prompting the user for the credentials, you will need to establish the connection in code by passing the credentials, which will probably be put in a connection string at some point when connecting to the database. How that is done depends on the ORM framework or how you are establishing the SQL connection.

1
  • Solved, the issue was a not correct configuration of IIS10 and Sequel Server. Thanks for you answer. Commented Oct 16, 2024 at 14:10
0

I think that the issue is on the connection string, After your post I have done a test and the result is this:

Case 1: userId and password correct

Connectionstring = Data Source=.;Initial Catalog=Webbit;Integrated Security=false;MultipleActiveResultSets=true;Trusted_Connection=false; User Id=joinddns;Password=Redbox@10;

Error = A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No other processes at the other end of the pipe.)

Case 2: userId or password not correct

Connectionstring = System;Data Source=.;Initial Catalog=Webbit;Integrated Security=false;MultipleActiveResultSets=true;Trusted_Connection=false; User Id=joinddns;Password=Redbox@100

Error = Login failed for user 'joinddns'.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.