[openupload-devel] LDAP Users in subtrees
Status: Beta
Brought to you by:
tsdogs
|
From: Fathi B. N. <fa...@fa...> - 2011-05-05 21:25:44
|
Hello, I have successfully setup openupload to use postgresql and openldap but still could not connect with valid username and password if the user is not directly under config['userdn'] tree. In fact, my users are spread across multiple subtrees and some are even on another ldap server referred to in one of the subtrees. So, I have add the follwing code to lib/modules/auth/ldap.inc.php which made openupload first look to the Dn of the user and then bind accordingly. 45a46,51 > // The following code looks for the user DN, in case our users are not stored in a flat tree but in various subtrees. > // If all users are under config['userdn'], then the returned dn is the same as the previously determined uid. > $tmp_result=ldap_search($this->ds,$this->config['userdn'],"uid=$login"); > $infos=ldap_get_entries($this->ds,$tmp_result); > $dn=$infos[0]["dn"]; > $uid = $dn; I am posting it in case someone could find it useful. This code corresponds perfectly to how my users are stored in openldap and can't say if it could be of general use or even if it will work for someone else. This is part of a code I have posted to phpldapadmin, years ago, as I had the some trouble with it. I am submitting this to openupload to be used under the same license as openupload. I am not a php/ldap guru so can't code cleaner. TIA FATHI B.N. |