title: Change username programmatically when connecting to a Sql Server using Windows authentication from a Delphi application
body: <p>I have a Sql Server that uses Windows Authentication.</p>
  
  <p>I want to connect to the server from a Delphi application.</p>
  
  <p>By default, SQL Server will assume the credentials of the user that launches the connecting process.</p>
  
  <p>This means that to change the login, I currently have two options:</p>
  
  <ol>
  <li><p>Log off and Log in as the desired
  user, then run my application</p></li>
  <li><p>Launch the program from the command
  line using the RUNAS command.</p></li>
  </ol>
  
  <p>I'd like to let the user provide credentials from within the application, and log in as that user.  Is this possible, either by manipulating the ConnectionString or by programatically changing the user of the current process?</p>
  
  <p>The closest I've found is <a href="http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_21637479.html" rel="nofollow noreferrer">this entry</a>, which tells me how to launch <strong>another</strong> process under specific credentials.  I could use that technique to create a "launcher" program that launches the connecting process after gathering credentials from the user, but I'd really like something cleaner.</p>
  
  <p>I'm using Delphi 2010 for this project.</p>
  
  <p>Thanks</p>