If you're struggling to generate an SHA encoded password for LDAP (PHP < 5.0), what you end up needing is this:
$userpassword = base64_encode(pack("H*", sha1($pass)));
I found this in the OpenLDAP FAQ (many thanks to Google and Ace), though I'm using the iPlanet LDAP server.
Ray Semiraglio