I've recently moved (yeah I know - it's only been round for years) to the Admin API for creating datasources but had a problem with the unencrypted password not working when verifying the datasource.
All elements of the datasource created correctly but the password was being stored incorrectly - I looked at how to create a twofish (2fish) based password but after coming accross this blog entry it became a lot simpler! However, it does require that you have access to the Java service factory too.
First to set up the service and encrypt the password:-
1 <cfset adminObj = createObject("component","cfide.adminapi.administrator")>
2 <cfset myObj = createObject("component","cfide.adminapi.datasource")>
3 <cfset service = createobject("java","coldfusion.server.ServiceFactory").getDatasourceService()>
4 <cfset form.password = service.encryptPassword(form.password)>
Next to creat the SQL server datasource:-
1 <cfscript>
2 // Login is always required. This example uses two lines of code.
3 adminObj.login("youradminpassword");
4
5 // Create a DSN.
6 myObj.setMSSQL(driver="MSSQLServer",
7 name="#form.dsn#",
8 host = "#form.host#",
9 port = "#form.port#",
10 database = "#form.database#",
11 username = "#form.username#",
12 password="#form.password#",
13 encryptpassword=false,
14 login_timeout = "29",
15 timeout = "23",
16 interval = 6,
17 buffer = "64000",
18 blob_buffer = "64000",
19 setStringParameterAsUnicode = "false",
20 description = "#form.description#",
21 pooling = true,
22 maxpooledstatements = 999,
23 enableMaxConnections = "true",
24 maxConnections = "299",
25 enable_clob = true,
26 enable_blob = true,
27 disable = false,
28 storedProc = true,
29 alter = true,
30 grant = true,
31 select = true,
32 update = true,
33 create = true,
34 delete = true,
35 drop = true,
36 revoke = false );
37 </cfscript>
Voila, the encrypted password works like a charm!