Oct 18 2007

CFLDAP: JRun vs. JBoss gotcha

Posted by Joe Rinehart at 5:15 PM
5 comments
- Categories: ColdFusion MX | Best Practices

One of the teams I'm working with right now is in the process of moving an application that was developed on CF7 + JRun to a CF8 + JBoss deployment stack. Overall, it's been pretty smooth, but we've found one gotcha.

Summary for <cfldap /> pros:

The error message sent back from the LDAP authentication attempt differs, so if you're testing what went wrong based on the error message / error code, you'll need to change what you're testing.

Details:

When using the <cfldap /> tag for authentication, the underlying LDAP implementation throws an error when username and password are invalid.

Basically, you have to try/catch your authentication. The most easily Google'd example of this results in a <cfldap /> example shown in a recently defunct ColdFusion "journal" to which I'd rather not link. It looks like this:

<cftry>
<cfldap action="QUERY"
name="AuthenticateUser"
attributes="givenname,samaccountname,dn,cn,mail"
start="dc=adtest,dc=com"
maxrows="1"
scope="subtree"
filter="(&(objectclass=user)(samaccountname=#form.cfusername#))"
server="ns1.adtest.com"
username="#form.cfusername#@adtest.com"
password="#form.cfpassword#">

<cfset LoginMessage = "User Authentication Passed">
<cfcatch type="any">
<cfset LoginMessage = "User Authentication Failed">
</cfcatch>
</cftry>

That's not a very good way to do it: it considers all errors thrown during an authentication request equivalent. Handling the "invalid password" error would be much different than handling a "LDAP server isn't online" error: one should notify the user, the other should notify the user and set off a pager.

To that end, my use of LDAP authentication looks more like this:

<cftry>
<cfldap ... />

<!--- Invalid password or username --->
<cfcatch message="Inappropriate Authentication">
<!--- Do stuff --->
</cfcatch>
<cfcatch message="Connection to LDAP server failed.">
<!--- Do more serious stuff --->
</cfcatch>
</cftry>

On JBoss, instead of "Inappropriate Authentication," you get "Authentication failed:[LDAP: error code 49 - Invalid Credentials]", which obviously threw our code for a loop.

Conclusion

Literals like these should be configured outside of code (yes, I slopped and used a magic string), and they're likely to change between environments.

Comments

Damon Gentry

Damon Gentry wrote on 10/18/07 7:31 PM

Great post Joe. I'm in the process of migrating CF7+JRun to CF8+JBoss, and we use CFLDAP. I'll be sure to tuck this little nugget away.
Joe Rinehart

Joe Rinehart wrote on 10/18/07 9:34 PM

It was arcane, but someone used it. My work here is done!

Thanks, Damon!
jagged

jagged wrote on 08/07/08 9:48 AM

Hi Joe,

We are also looking at porting our JRun solution into JBoss. Do you know of any information source for the same? any pointers, things to do / watch out for? website tutorials?

Thanks
Joe Rinehart

Joe Rinehart wrote on 08/07/08 10:02 AM

Hi Jaggerd,

I've used Adobe's docs (they're pretty good):

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=installj2ee_15.html

And referred to Steven Brownlee's blog as well:

http://www.fusioncube.net/index.php/coldfusion-on-jboss-standalone-primer

(He also has add'l JBoss / ColdFusion posts)

Overall, my experience with JBoss has been pretty darned smooth.
Elza

Elza wrote on 09/29/08 3:58 AM

We are also looking at porting our JRun solution into JBoss. Do you know of any information source for the same? any pointers, things to do / watch out for? website tutorials?
http://www.batteryfast.co.uk/asus/m68.htm asus m68 battery,
http://www.batteryfast.co.uk/asus/m68n.htm asus m68n battery,
http://www.batteryfast.co.uk/asus/m6000.htm asus m6000 battery,
http://www.batteryfast.co.uk/asus/a42-w1.htm asus a42-w1 battery,
http://www.batteryfast.co.uk/asus/w1.htm asus w1 battery,
http://www.batteryfast.co.uk/asus/w1g.htm asus w1g battery,
http://www.batteryfast.co.uk/asus/w1v.htm asus w1v battery,
http://www.batteryfast.co.uk/asus/w1000.htm asus w1000 battery,
http://www.batteryfast.co.uk/asus/w1000n.htm asus w1000n battery,

http://www.batteryfast.co.uk/asus/w1000g.htm asus w1000g battery,
http://www.batteryfast.co.uk/asus/a42-w3.htm asus a42-w3 battery,
http://www.batteryfast.co.uk/asus/w3a.htm asus w3a battery,
http://www.batteryfast.co.uk/asus/w3n.htm asus w3n battery,
http://www.batteryfast.co.uk/asus/w3v.htm asus w3v battery,
http://www.batteryfast.co.uk/asus/w3000a.htm asus w3000a battery,
http://www.batteryfast.co.uk/asus/w3000.htm asus w3000 battery,
http://www.batteryfast.co.uk/asus/w3000v.htm asus w3000v battery,
http://www.batteryfast.co.uk/asus/a31-s5.htm asus a31-s5 battery,

http://www.batteryfast.co.uk/asus/a32-s5.htm asus a32-s5 battery,
http://www.batteryfast.co.uk/asus/s52n.htm asus s52n battery,
http://www.batteryfast.co.uk/asus/s5000.htm asus s5000 battery,
http://www.batteryfast.co.uk/asus/s5200n.htm asus s5200n battery,
http://www.batteryfast.co.uk/asus/s5n.htm asus s5n battery,
http://www.batteryfast.co.uk/asus/90-naa1b1000.htm asus 90-naa1b1000 battery,
http://www.batteryfast.co.uk/asus/s2691061.htm asus s2691061 battery,
http://www.batteryfast.co.uk/asus/a42-v6.htm asus a42-v6 battery,
http://www.batteryfast.co.uk/asus/a32-u5.htm asus a32-u5 battery,

Write your comment



(it will not be displayed)