SQL windows Authentication without being logged in as that Domain account

Is there a way to do a SQL windows Authentication without being logged in as that Domain account.

I am working on a VBS script that connects to a SQL 2008 Database. I’m logged into my workstation with “Domain Account 1”, and the database only has permission for “Domain account 2”. I cannot get the VBS script to connect to the database.
* An SQL account is not an option per our SRM team.

This is the code I'm using.
strConnect = "Provider=SQLOLEDB.1;Password=xxxxxxx!;Persist Security Info=True;User ID=domain\account2;Initial Catalog=MYDB;Data Source=MYSERVERNAME"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnect

Open in new window

It fails with an error as follows
SQL_Connection_Test.vbs(39, 1) Microsoft OLE DB Provider for SQL Server: Login failed for user domain\account2.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Walter RitzelSenior Software EngineerCommented:
I think you can run your vbscript with the runas command:
POOK-101Author Commented:
I was hoping i didn't have to do that.  The script will be accessing  file servers (and logging to the database).
The "domain\account2" does not have access to the File Servers.
Walter RitzelSenior Software EngineerCommented:
Well, for file server access with another domain account, you can use the WMI object.

There is a thread on EE about this:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vitor MontalvãoMSSQL Senior EngineerCommented:
Is there a way to do a SQL windows Authentication without being logged in as that Domain account.
No, since you need the domain to send the credentials to the SQL Server instance. The workaround is to use a SQL Server login.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.