Credentials with database activities

Hello there!

I’m currently working on improving the security of my connection with the SQL server. I’ve noticed that the connection strings display the username and password, which concerns me. I attempted to retrieve the credentials from the orchestrator, but encountered an error in the process. I’m seeking advice on the best approach to establish a secure connection to the database while keeping the user and password information safe.

Any help or suggestions would be greatly appreciated. Thank you!

Hi @Marc_Font

  1. Use Windows Authentication: Whenever possible, it’s recommended to use Windows Authentication to connect to the SQL server instead of SQL Server Authentication (username and password in the connection string). Windows Authentication leverages the user’s Windows credentials to authenticate with the database, eliminating the need to store or pass credentials in the connection string. This approach is more secure as it avoids exposing sensitive information.
  2. Store Credentials in Orchestrator Assets: To store the SQL server credentials securely, use UiPath Orchestrator Assets. Instead of hardcoding the credentials in the connection string, store the username and password as assets in Orchestrator. Assets are securely encrypted and can be used by robots during runtime without revealing the actual credentials in the workflow. This way, you can centralize and manage the credentials from Orchestrator.

Hope it helps!!

Hi @Marc_Font ,
You can get username and password by window credential
Regard,
LuongNV

1 Like

Hi @Marc_Font ,

We would like to understand what was the error faced ?

Did you store the Credential Asset name in the Assets Sheet or Settings Sheet in the config?

Hello @mkankatala,

I’ve been using Windows Authentication, but I’m encountering this error, and I’m not sure what’s causing it.
WindowsAuthenticationError

And then, as you suggested, I tried to store the credentials in orchestrator. However, I encountered this error in the string, and I’m wondering if I might be referencing the variables incorrectly.

thanks for the quick response :blush:

Hi @supermanPunch

this is the error that appears

yes I stored in the credential asset

thank you

It was not accepting the strings and secure strings. The username is string datatype and password is secure string format.

Could you give try like this after DbUser.toString and DbPassword.SecurePassword

Hope it helps!!

maybe the following property will help:

1 Like

@Marc_Font ,

Considering these two statements, we can have two different scenarios to check, Firstly we can check if the below method of Converting the SecureString to String works and if the database connection is successful.

PasswordStr = System.Net.NetworkCredential(String.Empty,DbPassword).Password

Here, PasswordStr is a String variable and will contain the actual password and you can use this variable in place of DbPassword in the Connection string.

After performing the above, if the DB connection is not successful, Check by Debugging the value of Password in Debug Panel (No need to share screenshots or data here), just check if it is the same password as provided.

If using latest versions, as mentioned by @ppr , we could use SecureConnectionString property, where you can keep the whole connection string as the Password in the Orchestrator, and after retrieving it as SecureString variable type you can directly place it in that property field.

1 Like

@Marc_Font it’s worth looking at using DSNs to connect using the connector. You’ll not have creds in UiPath.

1 Like

Hi @supermanPunch!

Great news! It worked!! I followed your instructions, and the connection is now working smoothly. The only thing I encountered was an error with the method of converting, but I realized that putting “New” first resolved the issue:

PasswordStr = New System.Net.NetworkCredential(String.Empty,DbPassword).Password

I want to express my sincere appreciation to all of you for your help <3 Thank you, and I wish you all a fantastic day!!

1 Like

please close the topic, so others can benefit from it, thanks
Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.