Reputation: 575
I have to change from SQL Server authentication to Windows authentication:
My SQL Server authentication string is:
<add name="GCDataContext"
connectionString="Data Source=111.78.152.64;Initial Catalog=GC;User Id=sa;Password=xxxx;Trusted_Connection=False;Persist Security Info=True;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
Changed to (not working)
<add name="GCDataContext"
connectionString="Data Source=111.78.152.64;Initial Catalog=GC;Persist Security Info=True;Integrated Security=True;"
providerName="System.Data.SqlClient" />
Can anyone please help me on this?
Integrated Security=True
is for Windows authentication, but the connection is not established.
Upvotes: 0
Views: 2356
Reputation: 26
ASP.NET applications do not impersonate by default. As a result, when they use Windows authentication to connect to SQL Server, they use the Web application's process identity. With this approach, your front-end Web application authenticates and authorizes its users and then uses a trusted identity to access the database. The database trusts the application's identity and trusts the application to properly authenticate and authorize callers.
To connect to SQL Server using Windows authentication, perform the following steps:
Step 1. Configure a connection string. The connection string used with Windows authentication must include either the Trusted_Connection=Yes attribute, or the equivalent attribute Integrated Security=SSPI,
Step 2. Configure SQL Server security: You need to create a SQL Server login for your application's service account, and grant restricted permissions to access your database. You application's service account is usually either the Network Service account, which is the default account used to run ASP.NET application pools on Windows Server 2003 and IIS 6.0 or a custom service account.
For this do the following-
a).Create a SQL Server login for your application's account.
b).Map the login to a database user in the required database.
c). Provide appropriate permissions
Upvotes: 1
Reputation: 21
<add name="GCDataContext" connectionString="Data Source=111.78.152.64;Initial Catalog=GC;Integrated Security=True;" providerName="System.Data.SqlClient" />
Remove : Persist Security Info=True; If it's not able to connect verify DB permission and privilege.
Upvotes: 0
Reputation: 2738
<add name="GCDataContext"
connectionString="Data Source=111.78.152.64;Initial Catalog=GC;Integrated Security=True"
providerName="System.Data.SqlClient" />
This should work.
You just need to remove Persist Security Info=True
Also you can copy my above code
Upvotes: 1