mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-08-20 05:10:23 +00:00
Merge pull request #343 from shtrom/master
[ldapauth] More logging in the connection phase, and use cn for fullname by default
This commit is contained in:
commit
cb28355e04
1 changed files with 9 additions and 3 deletions
|
@ -47,7 +47,7 @@
|
||||||
* // attribute to get email - optional - default : 'mail'
|
* // attribute to get email - optional - default : 'mail'
|
||||||
* $a->config['ldapauth']['ldap_autocreateaccount_emailattribute'] = 'mail';
|
* $a->config['ldapauth']['ldap_autocreateaccount_emailattribute'] = 'mail';
|
||||||
* // attribute to get nickname - optional - default : 'givenName'
|
* // attribute to get nickname - optional - default : 'givenName'
|
||||||
* $a->config['ldapauth']['ldap_autocreateaccount_nameattribute'] = 'givenName';
|
* $a->config['ldapauth']['ldap_autocreateaccount_nameattribute'] = 'cn';
|
||||||
*
|
*
|
||||||
* ...etc.
|
* ...etc.
|
||||||
*/
|
*/
|
||||||
|
@ -90,23 +90,29 @@ function ldapauth_authenticate($username,$password) {
|
||||||
|
|
||||||
if(! ((strlen($password))
|
if(! ((strlen($password))
|
||||||
&& (function_exists('ldap_connect'))
|
&& (function_exists('ldap_connect'))
|
||||||
&& (strlen($ldap_server))))
|
&& (strlen($ldap_server)))) {
|
||||||
|
logger("ldapauth: not configured or missing php-ldap module");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$connect = @ldap_connect($ldap_server);
|
$connect = @ldap_connect($ldap_server);
|
||||||
|
|
||||||
if(! $connect)
|
if($connect === false) {
|
||||||
|
logger("ldapauth: could not connect to $ldap_server");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION,3);
|
@ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION,3);
|
||||||
@ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
|
@ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
|
||||||
if((@ldap_bind($connect,$ldap_binddn,$ldap_bindpw)) === false) {
|
if((@ldap_bind($connect,$ldap_binddn,$ldap_bindpw)) === false) {
|
||||||
|
logger("ldapauth: could not bind $ldap_server as $ldap_binddn");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = @ldap_search($connect,$ldap_searchdn, $ldap_userattr . '=' . $username);
|
$res = @ldap_search($connect,$ldap_searchdn, $ldap_userattr . '=' . $username);
|
||||||
|
|
||||||
if(! $res) {
|
if(! $res) {
|
||||||
|
logger("ldapauth: $ldap_userattr=$username,$ldap_searchdn not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue