Connection string mvc app

TomaszW-0873 136 Reputation points
2020-08-27T22:33:36.227+00:00

I created a Web Application using mvc.app and connection to SQL Server. Application authenticates user via ADFS. How should I form my connection string, so the application will work with the SQL permission granted to the user? i.e. I have a user named John and he can only read from the database, so he should have the same permssions when using the application. If I create another user with broader permissions, that user (after login to the app) should also have broader permissions.
Application is hosted on-permises

SQL Server Other
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. AmeliaGu-MSFT 14,006 Reputation points Microsoft External Staff
    2020-08-28T07:11:30.663+00:00

    Hi TomaszW-0873,
    You can try to use the following connection string in web.config:

    <add name="ConnectionStringName"  
        providerName="System.Data.SqlClient"  
    connectionString="Data Source=ServerName;Initial Catalog=DatabaseName;Integrated Security=False;User Id=userid;Password=password;MultipleActiveResultSets=True" />  
      
    

    For more details, please refer to SQL Server Connection Strings for ASP.NET Web Applications and SQL Server Database Connection To MVC Application which might help.
    In addition, your issue is more related to MVC. I suggest you open a thread in the ASP.NET MVC forum so that people there will help you more effectively.
    Best Regards,
    Amelia

    =======================================

    Please remember to click " Accept Answer" and upvote the responses that resolved your issue.

    0 comments No comments

  2. TomaszW-0873 136 Reputation points
    2020-08-28T14:27:10.077+00:00

    I will try, although I would like to avoid providing username and password as those would depend on the logged user. When I use Windows Integrated login, the webiste "log" to SQL Server using a computer account.


  3. Tom Phillips 17,771 Reputation points
    2020-08-31T14:26:13.03+00:00
    0 comments No comments

  4. TomaszW-0873 136 Reputation points
    2020-08-31T15:03:53.363+00:00

    I found a way using <identity impersonate="true" />
    just wondering if there is any other way

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.