SQL Connection String - Windows different user


#1

Hi @vvaidya @aksh1yadav @akhi_s27 @Vikas.Jain @badita @beesheep,

I have logged into windows as user ‘abc123’ and then connected to sql server as different user ‘xyz456’,

in this case what would be the connection string ?

I’m unable to connect the usual way and doubt there should be something which I’m missing in my connection string for a different windows user, please share your thoughts guys.

Thanks!


#2

If you are using UserID and Password in Connection string, you are connecting to that Database using SQL Authentication (user created in SQL DB), not your Windows credentials.

Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;
Password=myPassword;

If you mention Integrated Security=SSPI;instead of User ID, Password, then you will be able to connect with your Windows Credentials provided you have enabled Windows Authentication (Or Mixed) in the DataBase.

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
User ID=myDomain\myUsername;Password=myPassword;

More Info : https://www.connectionstrings.com/sql-server/


#3

didn’t really worked. Tried all these options from google before posting here…

Thanks!


#4

I was thinking SQL User, if this is a different Windows User, I doubt you can do that. Actually never tried.


#5

yea, that’s what I’m after now. Tricky but that’s a requirement. pls see the screenshot below…

If I dont use the “Integrated Security=True”, then it really tries using the other user, but still it doesn’t goes through as shown below,

really appreciate if someone could share thier ideas/thoughts to resolve this…


#6

Guys, any luck with this query ? Really appreciable. Thanks.!


#7

Hi,

Anyone had any luck with this?


#8

Guys, if you set the connection as trusted, then that means you cannot set the username manually. Trusted connections will use the account used by the service that initiated the connection. In this case it will be the service account that is logged in into windows and running the robot.