Pull a List of All Coldfusion Datasources, Along With Username and Passwords
Posted by Paul Alkema | Tags: ColdFusion
There are special times when you may need to get a list of your datasources or retrieve the passwords for your datasources. If this is your case, no problem.
The script below will pull all datasources, along with the username and a decrypted password.
// Create Data Source Object dataSourceObb=createobject("java","coldfusion.server.ServiceFactory"). getDatasourceService().getDatasources(); // Loop Through DataSources for(i in dataSourceObb) { if(len(dataSourceObb[i]["password"])){ // Get username username=(dataSourceObb[i]["username"]); // Get and decrypt password decryptPassword=Decrypt(dataSourceObb[i]["password"], generate3DesKey("0yJ!@1$r8p0L@r1$6yJ!@1rj"), "DESede", "Base64"); // Output all datasources along with username and passwords writeoutput("" & "DataSource: " & i & "
" & "Username: " & username & "
Password: " & decryptPassword &"
"); } }
Enjoy!
UPDATE: When this post was originally posted, this worked on 9, however since then 9.0.1 has been released. This version has fixed this issue.
Tags: Coldfusion, Datasource Passwords, ColdFusion Passwords, ColdFusion ServiceFactory, Paul Alkema

8 responses so far ↓
Leave a Comment