Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 354 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connection string using Windows Authentication

#1
I am creating a website, but in the database I use windows authentication.

I know that you use this for SQL authentication

<connectionStrings>
<add name="NorthwindContex"
connectionString="data source=localhost;
initial catalog=northwind;persist security info=True;
user id=sa;password=P@ssw0rd"
providerName="System.Data.SqlClient" />
</connectionStrings>

How do I modify this to work with windows authentication?
Reply

#2
Replace the username and password with `Integrated Security=SSPI;`

So the connection string should be

<connectionStrings>
<add name="NorthwindContex"
connectionString="data source=localhost;
initial catalog=northwind;persist security info=True;
Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
</connectionStrings>
Reply

#3
This is shorter and works

<connectionStrings>
<add name="DBConnection"
connectionString="data source=SERVER\INSTANCE;
Initial Catalog=MyDB;Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
</connectionStrings>

Persist Security Info not needed
Reply

#4
For the correct solution after many hours:

1. Open the configuration file
2. Change the connection string with the following

`<add name="umbracoDbDSN" connectionString="data source=YOUR_SERVER_NAME;database=nrc;Integrated Security=SSPI;persist security info=True;" providerName="System.Data.SqlClient" />`

3. Change the **YOUR_SERVER_NAME** with your current server name and save
4. Open the IIS Manager
5. Find the name of the application pool that the website or web application is using
6. Right-click and choose Advanced settings
7. From Advanced settings under **Process Model** change the **Identity** **to Custom account** and add your Server Admin details, please see the attached images:

[![enter image description here][1]][1]

Hope this will help.


[1]:
Reply

#5
For connecting to a sql server database via Windows authentication basically needs which server you want to connect , what is your database name , Integrated Security info and provider name.

Basically this works:

<connectionStrings>
<add name="MyConnectionString"
connectionString="data source=ServerName;
Initial Catalog=DatabaseName;Integrated Security=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>

Setting ***Integrated Security*** field **true** means basically you want to reach database via Windows authentication, if you set this field ***false*** Windows authentication will not work.

It is also working different according which provider you are using.


- **SqlClient** both **Integrated Security=true;** or **IntegratedSecurity=SSPI;** is working.

- **OleDb** it is **Integrated Security=SSPI;**
- **Odbc** it is **Trusted_Connection=yes;**
- **OracleClient** it is **Integrated Security=yes;**

> Integrated Security=true throws an exception when used with the OleDb provider.
Reply

#6
If anyone comes looking for asp.net core, we will have to add connection string in appsettings.json

{
"ConnectionStrings": {
"DefaultConnection": "Server=SQLServer\\Instance;Database=MYDB;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}

Source: [add windows authentication sql server connection string][1]


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through