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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maziar Aflatoun

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

    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.


  • Joshua Flanagan

    #2
    Re: C# SQL connection string (Windows authentication) ???

    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_machinenam e 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



    Maziar Aflatoun wrote:[color=blue]
    > 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.
    >
    >[/color]

    Comment

    Working...