Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi guys

this is my app.config :

 <connectionStrings>
         <add name="database_1"
            connectionString="Provider=OraOLEDB.Oracle;Data Source= (DESCRIPTION=(HOST=000.00.00.00.0 )(PORT=00000))) (CONNECT_DATA = ;User Id=username;Password=password"/>
</connectionString>



how can i get the value of username and password ? NOTE: i have several databases.

What I have tried:

i tried to access it from here :
System.Configuration.ConfigurationSettings.ConnectionStrings 


but failed to do so.

someone can help please?
Posted
Updated 25-Jul-18 22:59pm
v2
Comments
Richard MacCutchan 26-Jul-18 3:43am    
Do not store userid and password in configuration settings, it makes them available for anyone. Use a dialog to get the information from the user.
Joe Doe234 26-Jul-18 4:05am    
i need to make them available for everyone whoever is using this application
Eric Lynch 26-Jul-18 8:04am    
Storing a username/password in clear text is very insecure. You should consider using Integrated Security, which Oracle supports. With Integrated Security connection strings, clients are authenticated via Windows login credentials, so no username/password is required in the connection string.

Failing this, you should at least encrypt the information in the configuration file. Though, this is less secure and less easy to maintain.

See: https://docs.oracle.com/cd/B28359_01/win.111/b32010/external.htm#g1028005

string cnnString = System.Configuration.ConfigurationManager.ConnectionStrings["database_1"].ConnectionString;
 
Share this answer
 
Comments
Joe Doe234 26-Jul-18 4:05am    
i dont need the full connection string , i just want the user and password of that connection string.
I googled "c# extract username and password from connection string" and this was the first result

c# - Right way to get username and password from connection string? - Stack Overflow[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900