Fix: A lot of fix for LDAP synchro
This commit is contained in:
parent
4977cfd44f
commit
3ab6ffdd0e
@ -48,7 +48,7 @@ if ($action == 'setvalue' && $user->admin)
|
|||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
if (! dolibarr_set_const($db, 'LDAP_SERVER_TYPE',GETPOST("type"),'chaine',0,'',$conf->entity)) $error++;
|
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',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_HOST_SLAVE',GETPOST("slave"),'chaine',0,'',$conf->entity)) $error++;
|
||||||
if (! dolibarr_set_const($db, 'LDAP_SERVER_PORT',GETPOST("port"),'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=array();
|
||||||
$arraylist['3']='Version 3';
|
$arraylist['3']='Version 3';
|
||||||
$arraylist['2']='Version 2';
|
$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>';
|
print '</td><td>'.$langs->trans("LDAPServerProtocolVersion").'</td></tr>';
|
||||||
|
|
||||||
// Serveur primaire
|
// Serveur primaire
|
||||||
|
|||||||
@ -207,7 +207,7 @@ class Ldap
|
|||||||
$this->connection = ldap_connect($host,$this->serverPort);
|
$this->connection = ldap_connect($host,$this->serverPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->connection)
|
if (is_resource($this->connection))
|
||||||
{
|
{
|
||||||
$this->setVersion();
|
$this->setVersion();
|
||||||
|
|
||||||
@ -274,9 +274,9 @@ class Ldap
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error='Failed to connect to LDAP';
|
$this->error='Failed to connect to LDAP'.($this->error?': '.$this->error:'');
|
||||||
$return=-1;
|
$return=-1;
|
||||||
dol_syslog("Ldap::connect_bind return=".$return, LOG_WARNING);
|
dol_syslog("Ldap::connect_bind return=".$return.' - '.$this->error, LOG_WARNING);
|
||||||
}
|
}
|
||||||
return $return;
|
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 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);
|
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: 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."\n";
|
print "DEBUG: uid/samacountname=".$ldapuserattr.", dn=".$ldapdn.", Admin:".$ldap->searchUser.", Pass:".$ldap->searchPassword."<br>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$resultFetchLdapUser=0;
|
$resultFetchLdapUser=0;
|
||||||
@ -104,7 +104,7 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
|
|||||||
if ($ldapadminlogin)
|
if ($ldapadminlogin)
|
||||||
{
|
{
|
||||||
$result=$ldap->connect_bind();
|
$result=$ldap->connect_bind();
|
||||||
if ($result)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$resultFetchLdapUser = $ldap->fetch($usertotest,$userSearchFilter);
|
$resultFetchLdapUser = $ldap->fetch($usertotest,$userSearchFilter);
|
||||||
//dol_syslog('functions_ldap::check_user_password_ldap resultFetchLdapUser='.$resultFetchLdapUser);
|
//dol_syslog('functions_ldap::check_user_password_ldap resultFetchLdapUser='.$resultFetchLdapUser);
|
||||||
@ -119,6 +119,10 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($ldapdebug) print "DEBUG: ".$ldap->error."<br>\n";
|
||||||
|
}
|
||||||
$ldap->close();
|
$ldap->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,11 +195,11 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
|
|||||||
** 53 - Account inactive (manually locked out by administrator)
|
** 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."'");
|
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);
|
$ldap->ldapErrorCode = ldap_errno($ldap->connection);
|
||||||
$this->ldapErrorText = ldap_error($this->connection);
|
$ldap->ldapErrorText = ldap_error($ldap->connection);
|
||||||
dol_syslog("unctions_ldap::check_user_password_ldap ".$this->ldapErrorText);
|
dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorText);
|
||||||
}
|
}
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$langs->load('main');
|
$langs->load('main');
|
||||||
|
|||||||
@ -1882,8 +1882,10 @@ class User extends CommonObject
|
|||||||
$this->ref = 'SPECIMEN';
|
$this->ref = 'SPECIMEN';
|
||||||
$this->specimen=1;
|
$this->specimen=1;
|
||||||
|
|
||||||
$this->nom='DOLIBARR';
|
$this->nom='DOLIBARR'; // deprecated
|
||||||
$this->prenom='SPECIMEN';
|
$this->prenom='SPECIMEN'; // deprecated
|
||||||
|
$this->lastname='DOLIBARR';
|
||||||
|
$this->firstname='SPECIMEN';
|
||||||
$this->note='This is a note';
|
$this->note='This is a note';
|
||||||
$this->email='email@specimen.com';
|
$this->email='email@specimen.com';
|
||||||
$this->office_phone='0999999999';
|
$this->office_phone='0999999999';
|
||||||
|
|||||||
@ -683,19 +683,18 @@ class UserGroup extends CommonObject
|
|||||||
if ($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)
|
if ($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)
|
||||||
{
|
{
|
||||||
$valueofldapfield=array();
|
$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=new User($this->db);
|
||||||
$muser->fetch($val);
|
$muser->fetch($val->id);
|
||||||
|
if ($conf->global->LDAP_KEY_USERS == 'cn') $ldapuserid=$muser->getFullName($langs);
|
||||||
$ldapuserid=$muser->login;
|
elseif ($conf->global->LDAP_KEY_USERS == 'sn') $ldapuserid=$muser->lastname;
|
||||||
// TODO ldapuserid should depends on value $conf->global->LDAP_KEY_USERS;
|
elseif ($conf->global->LDAP_KEY_USERS == 'uid') $ldapuserid=$muser->login;
|
||||||
|
|
||||||
$valueofldapfield[] = $conf->global->LDAP_KEY_USERS.'='.$ldapuserid.','.$conf->global->LDAP_USER_DN;
|
$valueofldapfield[] = $conf->global->LDAP_KEY_USERS.'='.$ldapuserid.','.$conf->global->LDAP_USER_DN;
|
||||||
}
|
}
|
||||||
$info[$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield)?$valueofldapfield:'');
|
$info[$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS] = (!empty($valueofldapfield)?$valueofldapfield:'');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?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>
|
* Copyright (C) 2006-2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -179,7 +179,7 @@ if ($result > 0)
|
|||||||
//var_dump($records);
|
//var_dump($records);
|
||||||
|
|
||||||
// Affichage arbre
|
// 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))
|
if (! is_array($records))
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user