Oct 19, 2010

Impersonate Active Directory Account when Connecting to Database using Windows Authentication

Lately I have a little problem, not a major but I’m not comfortable and must get to used to it. Suppose we want to connect to another SQL Server Database, and we don’t have any options except use the WINDOWS Authentication. But frankly, this SQL Server which we want to connect to is in another domain. Yeah, you could try to use Windows Authentication, but the User name field and Password field are grayed out. For example, my notebook wasn’t joined to another domain (with logged on user is RADIT\raditz), and I need to connect to another SQL Server in a different domain (suppose another domain user to connect to is CONTOSO\admin), use the following command-line:

RUNAS /user:CONTOSO\admin /netonly “<the SQL Management Studio exe path>”

RUNAS /user:CONTOSO\admin /netonly “D:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe”

image

You’ll be asked for the password, and the application will running with that user accounts.

image

Don’t worry, just insert the SQL Server Name, and click Connect.