For LDAP, you can take a look at the ACS LDAP Authentication package at
http://www.arsdigita.com/acs-repository/one-version?version_id=266
It won't work for you out of the box (it's based on ACS 4.0 for starters), but it should give you a good idea of how to approach the problem.
Also, check out Lars' LDAP write-up at
http://www.pinds.com/software/ldap-in-general