locked
When to use Trusted_Connection is equal to False RRS feed

  • Question

  • User1407435033 posted

    Can someone guide me when to use the trusted_connection=false; in the connection string.

    Wednesday, June 11, 2014 3:17 PM

Answers

  • User753101303 posted

    Hi,

    Yes, false is the default value so this is not needed and you can remove that from your connection string. It could have been quicker to just try rather than to ask in a forum ;-)

    For further reference keep also the SqlConnection.ConnectionString documentation at http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx handy. It includes a description of most if not all SQL Server connection string keywords.

    If "trying" means that you have a problem wiht your connection string, just directly post the error message you have.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 11, 2014 5:07 PM

All replies

  • User-760709272 posted

    Trusted connection means if you're using integrated security or not (you can use the integrated security property in stead.  Trusted connection (or integrated security on) means the connection will be made using the Windows account the code is currently running under.  Trusted connection false means you will be supplying your own user id and password that the connection will use, and that will then use SQL Server security rather than Windows integrated security.

    Wednesday, June 11, 2014 3:22 PM
  • User139467042 posted

    A trusted connection is used if you're connecting to the database without providing a user name and password.

    For example, if you are connecting via a Data Source Name, and the DSN contains the user ID you're using to connect, then your trusted connection is true.

    If you are providing a user name and password as part of your connection string, then trusted connection is false.

    If you specify a trusted connection in your connection string, whatever user name and password you pass to the database server will be ignored. In that case, your SQL Server needs to be configured to allow for trusted connections, which means either using the sa account in SQL Server or using Windows Authentication to connect to the server.

    So, it's a trusted connection if:

    • You're connecting via a DSN that contains the relevant login credentials.
    • You're connecting via Windows Authentication.
    • You've configured your SQL Server to allow remote connections via the sa account (which is a terrible idea).

    Otherwise, it's not trusted.

    Wednesday, June 11, 2014 3:28 PM
  • User1407435033 posted

    Hi All,

    Thanks for the replies. I am trying to pass Uid/Pwd explicitly so i have declared trusted_connection = false; Is it necessary to place the trusted_connection = false or i can remove the property from the connection string.

    Wednesday, June 11, 2014 4:19 PM
  • User139467042 posted

    You should add it, but in most connnection strings, if you omit a trusted connection value, the default is that it is not a trusted connection/

    Wednesday, June 11, 2014 5:04 PM
  • User753101303 posted

    Hi,

    Yes, false is the default value so this is not needed and you can remove that from your connection string. It could have been quicker to just try rather than to ask in a forum ;-)

    For further reference keep also the SqlConnection.ConnectionString documentation at http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx handy. It includes a description of most if not all SQL Server connection string keywords.

    If "trying" means that you have a problem wiht your connection string, just directly post the error message you have.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 11, 2014 5:07 PM