mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-11 10:22:37 +01:00
Fix: A lot of fix for LDAP synchro
This commit is contained in:
@@ -48,7 +48,7 @@ if ($action == 'setvalue' && $user->admin)
|
||||
|
||||
$db->begin();
|
||||
if (! dolibarr_set_const($db, 'LDAP_SERVER_TYPE',GETPOST("type"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION',GETPOST("version"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION',GETPOST("LDAP_SERVER_PROTOCOLVERSION"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST',GETPOST("host"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE',GETPOST("slave"),'chaine',0,'',$conf->entity)) $error++;
|
||||
if (! dolibarr_set_const($db, 'LDAP_SERVER_PORT',GETPOST("port"),'chaine',0,'',$conf->entity)) $error++;
|
||||
@@ -169,7 +169,7 @@ print '<tr '.$bc[$var].'><td>'.$langs->trans("Version").'</td><td>';
|
||||
$arraylist=array();
|
||||
$arraylist['3']='Version 3';
|
||||
$arraylist['2']='Version 2';
|
||||
print $form->selectarray('version',$arraylist,$conf->global->LDAP_SERVER_PROTOCOLVERSION);
|
||||
print $form->selectarray('LDAP_SERVER_PROTOCOLVERSION',$arraylist,$conf->global->LDAP_SERVER_PROTOCOLVERSION);
|
||||
print '</td><td>'.$langs->trans("LDAPServerProtocolVersion").'</td></tr>';
|
||||
|
||||
// Serveur primaire
|
||||
|
||||
@@ -207,7 +207,7 @@ class Ldap
|
||||
$this->connection = ldap_connect($host,$this->serverPort);
|
||||
}
|
||||
|
||||
if ($this->connection)
|
||||
if (is_resource($this->connection))
|
||||
{
|
||||
$this->setVersion();
|
||||
|
||||
@@ -274,9 +274,9 @@ class Ldap
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error='Failed to connect to LDAP';
|
||||
$this->error='Failed to connect to LDAP'.($this->error?': '.$this->error:'');
|
||||
$return=-1;
|
||||
dol_syslog("Ldap::connect_bind return=".$return, LOG_WARNING);
|
||||
dol_syslog("Ldap::connect_bind return=".$return.' - '.$this->error, LOG_WARNING);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -85,8 +85,8 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
|
||||
{
|
||||
dol_syslog("functions_ldap::check_user_password_ldap Server:".join(',',$ldap->server).", Port:".$ldap->serverPort.", Protocol:".$ldap->ldapProtocolVersion.", Type:".$ldap->serverType);
|
||||
dol_syslog("functions_ldap::check_user_password_ldap uid/samacountname=".$ldapuserattr.", dn=".$ldapdn.", Admin:".$ldap->searchUser.", Pass:".$ldap->searchPassword);
|
||||
print "DEBUG: Server:".join(',',$ldap->server).", Port:".$ldap->serverPort.", Protocol:".$ldap->ldapProtocolVersion.", Type:".$ldap->serverType."\n";
|
||||
print "DEBUG: uid/samacountname=".$ldapuserattr.", dn=".$ldapdn.", Admin:".$ldap->searchUser.", Pass:".$ldap->searchPassword."\n";
|
||||
print "DEBUG: Server:".join(',',$ldap->server).", Port:".$ldap->serverPort.", Protocol:".$ldap->ldapProtocolVersion.", Type:".$ldap->serverType."<br>\n";
|
||||
print "DEBUG: uid/samacountname=".$ldapuserattr.", dn=".$ldapdn.", Admin:".$ldap->searchUser.", Pass:".$ldap->searchPassword."<br>\n";
|
||||
}
|
||||
|
||||
$resultFetchLdapUser=0;
|
||||
@@ -104,7 +104,7 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
|
||||
if ($ldapadminlogin)
|
||||
{
|
||||
$result=$ldap->connect_bind();
|
||||
if ($result)
|
||||
if ($result > 0)
|
||||
{
|
||||
$resultFetchLdapUser = $ldap->fetch($usertotest,$userSearchFilter);
|
||||
//dol_syslog('functions_ldap::check_user_password_ldap resultFetchLdapUser='.$resultFetchLdapUser);
|
||||
@@ -119,6 +119,10 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
|
||||
return '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($ldapdebug) print "DEBUG: ".$ldap->error."<br>\n";
|
||||
}
|
||||
$ldap->close();
|
||||
}
|
||||
|
||||
@@ -191,11 +195,11 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
|
||||
** 53 - Account inactive (manually locked out by administrator)
|
||||
*/
|
||||
dol_syslog("functions_ldap::check_user_password_ldap Authentification ko failed to connect to LDAP for '".$usertotest."'");
|
||||
if ($this->connection) // If connection ok but bind ko
|
||||
if (is_resource($ldap->connection)) // If connection ok but bind ko
|
||||
{
|
||||
$this->ldapErrorCode = ldap_errno($this->connection);
|
||||
$this->ldapErrorText = ldap_error($this->connection);
|
||||
dol_syslog("unctions_ldap::check_user_password_ldap ".$this->ldapErrorText);
|
||||
$ldap->ldapErrorCode = ldap_errno($ldap->connection);
|
||||
$ldap->ldapErrorText = ldap_error($ldap->connection);
|
||||
dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorText);
|
||||
}
|
||||
sleep(1);
|
||||
$langs->load('main');
|
||||
|
||||
@@ -1882,8 +1882,10 @@ class User extends CommonObject
|
||||
$this->ref = 'SPECIMEN';
|
||||
$this->specimen=1;
|
||||
|
||||
$this->nom='DOLIBARR';
|
||||
$this->prenom='SPECIMEN';
|
||||
$this->nom='DOLIBARR'; // deprecated
|
||||
$this->prenom='SPECIMEN'; // deprecated
|
||||
$this->lastname='DOLIBARR';
|
||||
$this->firstname='SPECIMEN';
|
||||
$this->note='This is a note';
|
||||
$this->email='email@specimen.com';
|
||||
$this->office_phone='0999999999';
|
||||
|
||||
@@ -683,19 +683,18 @@ class UserGroup extends CommonObject
|
||||
if ($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)
|
||||
{
|
||||
$valueofldapfield=array();
|
||||
foreach($this->members as $key=>$val)
|
||||
foreach($this->members as $key=>$val) // This is array of users for group into dolibarr database.
|
||||
{
|
||||
$muser=new User($this->db);
|
||||
$muser->fetch($val);
|
||||
|
||||
$ldapuserid=$muser->login;
|
||||
// TODO ldapuserid should depends on value $conf->global->LDAP_KEY_USERS;
|
||||
$muser->fetch($val->id);
|
||||
if ($conf->global->LDAP_KEY_USERS == 'cn') $ldapuserid=$muser->getFullName($langs);
|
||||
elseif ($conf->global->LDAP_KEY_USERS == 'sn') $ldapuserid=$muser->lastname;
|
||||
elseif ($conf->global->LDAP_KEY_USERS == 'uid') $ldapuserid=$muser->login;
|
||||
|
||||
$valueofldapfield[] = $conf->global->LDAP_KEY_USERS.'='.$ldapuserid.','.$conf->global->LDAP_USER_DN;
|
||||
}
|
||||
$info[$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield)?$valueofldapfield:'');
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -179,7 +179,7 @@ if ($result > 0)
|
||||
//var_dump($records);
|
||||
|
||||
// Affichage arbre
|
||||
if (count($records) && (! isset($records['count']) || $records['count'] > 0))
|
||||
if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0))
|
||||
{
|
||||
if (! is_array($records))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user