Link to home
Start Free TrialLog in
Avatar of POOK-101
POOK-101Flag for United States of America

asked on

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
Err.Clear
objConnection.Open

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.
Avatar of Walter Ritzel
Walter Ritzel
Flag of Brazil image

I think you can run your vbscript with the runas command:
https://technet.microsoft.com/pt-br/library/cc771525(v=ws.10).aspx
Avatar of POOK-101

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Walter Ritzel
Walter Ritzel
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial