By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,474 Members | 966 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,474 IT Pros & Developers. It's quick & easy.

C# SQL connection string (Windows authentication)???

P: n/a
Hi guys,

I'm using Windows authentication to connect to SQL Server 2000. On my
computer the connection is fine. Now if I move it to a remote server, how
to I hard code my Username/Password in my connection string (using Windows
NT authentication and not SQL Server authentication)?

Thank you
Maz.
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You don't.

The main benefit of using Windows authentication for your connection to
SQL Server is that you can avoid coding a username and password into the
connection string.

To indicate you want to use Windows authentication in your connection
string, replace the "user id=xx;password=xx" part with
"Integrated Security=SSPI;"

The connection will be made using whatever account the process is
running under.
If it is an interactive desktop application (WinForms or Console), it
will run under the user's account.
If it is an ASP.NET website, without impersonation enabled, the
connection will be made from the ASPNET (on 2K) or NETWORK SERVICE (on
2K3). With impersonation enabled, and Anonymous access disabled in IIS,
it will run under the client user's account. If Anonymous access is
enabled, it will run under the IUSR_machinename account.

If you do not want to grant all users access to the SQL Server, you can
run your assembly under a specific identity in COM+.
Joshua Flanagan
http://flimflan.com/blog
Maziar Aflatoun wrote:
Hi guys,

I'm using Windows authentication to connect to SQL Server 2000. On my
computer the connection is fine. Now if I move it to a remote server, how
to I hard code my Username/Password in my connection string (using Windows
NT authentication and not SQL Server authentication)?

Thank you
Maz.

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.