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

M

Maziar Aflatoun

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.
 
J

Joshua Flanagan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top