Login to machine with one user and login sql with windows authentication

Hi Team,

I have to login into machine using one user. Inside machine, I have to open the sql and login into it using windows auth with different user. How we can acheive it using uipath. What will be the connection string.

Hi @Shirish ,

Try below string

connectionString=“Data Source=your data source;Initial Catalog=DB Name;Integrated Security=true” />

Data Source - The name of the SQL Server and its Instance.
Initial Catalog - The name of the Database.
Integrated Security - By default False. If set true it signifies that Windows Authentication needs to be used.

Hi @ermanoj3101

we wanted to login into machine using window user account and we wanted login into sql server using different user using windows authentication, not using sql authentication. How we can acheive that ?

Hi @Shirish,

This can be done in the following way

  1. Create a credential asset in your Orchestrator with the required user name and password of the SQL user.
    In this example: SQLRobotUserName and SQLRobotPasswordSecureString

  2. In your process get the credential asset from Step 1 and store the credentials in string and secure string respectively

  3. Now convert the SQLRobotPasswordSecureString secure string to a normal string type by using an assign activity
    SQLRobotPassword = New System.Net.NetworkCredential(String.Empty, SQLRobotPasswordSecureString).Password

  4. We do some string manipulation to make this dynamic so that you can change user credentials in Orchestrator as and when required. Your connection string then should be :
    "Data Source=YOURDATABASESERVER;Initial Catalog=YOURDATABASENAME;Persist Security Info=True;User ID=USERNAME;Password=".Replace("USERNAME", SQLRobotUserName)+SQLRobotPassword

This approach is independent of the user who has logged into the VDI / Server / Robot Machine. It will just use the user credentials of SQL to login to the SQL instance and modify required tables in the database. Offcourse the user needs to be allocated permissions to the required databases/tables via SQL Management Studio.

Here is a sample file with exception handling : DatabaseConnectionUniqueUser.xaml (17.3 KB)

If you later need to call a stored procedure in your Database you can refer to this post: SQL Stored procedure Passing Parameters To fetch particular records - Help / Activities - UiPath Community Forum

Hope this helps you and others.