Ajout gestion des users via Active Directory (ouindoze)
Fix: synchro suppression des contacts sur ldap
This commit is contained in:
parent
241addc03e
commit
9bd79dd282
@ -237,7 +237,16 @@ print '<tr><td>'.$langs->trans("DNGroup").'</td><td>';
|
|||||||
print '<input size="25" type="text" name="group" value="'.LDAP_GROUP_DN.'">';
|
print '<input size="25" type="text" name="group" value="'.LDAP_GROUP_DN.'">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '<tr><td>'.$langs->trans("DNContactActive").'</td><td><select name="activecontact">';
|
print '<tr><td>'.$langs->trans("DNContactActive").'</td><td><select name="activecontact">';
|
||||||
print '<option value="0" selected>'.$langs->trans("No");
|
if (defined("LDAP_CONTACT_ACTIVE") && LDAP_CONTACT_ACTIVE == 1)
|
||||||
|
{
|
||||||
|
print '<option value="1" selected>'.$langs->trans("Yes");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<option value="0" selected>'.$langs->trans("No");
|
||||||
|
}
|
||||||
|
print '<option value="LDAP_CONTACT_ACTIVE">--------';
|
||||||
|
print '<option value="0">'.$langs->trans("No");
|
||||||
print '<option value="1">'.$langs->trans("Yes");
|
print '<option value="1">'.$langs->trans("Yes");
|
||||||
print '</select>';
|
print '</select>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
@ -246,8 +255,25 @@ print '<input size="25" type="text" name="contact" value="'.LDAP_CONTACT_DN.'">'
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("Type").'</td><td><select name="type">';
|
print '<tr><td>'.$langs->trans("Type").'</td><td><select name="type">';
|
||||||
print '<option value="openldap" selected>OpenLdap';
|
if (defined("LDAP_SERVER_TYPE") && LDAP_SERVER_TYPE == activedirectory)
|
||||||
|
{
|
||||||
|
print '<option value="activedirectoty" selected>Active Directory';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (defined("LDAP_SERVER_TYPE") && LDAP_SERVER_TYPE == egroupware)
|
||||||
|
{
|
||||||
|
print '<option value="egroupware" selected>Egroupware';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<option value="openldap" selected>OpenLdap';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print '<option value="LDAP_SERVER_TYPE">------------------------';
|
||||||
|
print '<option value="openldap">OpenLdap';
|
||||||
print '<option value="egroupware">Egroupware';
|
print '<option value="egroupware">Egroupware';
|
||||||
|
print '<option value="activedirectory">Active Directory';
|
||||||
print '</select>';
|
print '</select>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
@ -266,7 +292,7 @@ if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && $_GET["action"] == 'test')
|
if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && LDAP_ADMIN_DN && LDAP_ADMIN_PASS && $_GET["action"] == 'test')
|
||||||
{
|
{
|
||||||
$ds = dolibarr_ldap_connect();
|
$ds = dolibarr_ldap_connect();
|
||||||
|
|
||||||
|
|||||||
@ -179,7 +179,6 @@ class Contact
|
|||||||
$info["objectclass"][2] = "organizationalPerson";
|
$info["objectclass"][2] = "organizationalPerson";
|
||||||
$info["objectclass"][3] = "inetOrgPerson";
|
$info["objectclass"][3] = "inetOrgPerson";
|
||||||
|
|
||||||
$info["ou"] = 'People';
|
|
||||||
$info["cn"] = utf8_encode($this->firstname." ".$this->name);
|
$info["cn"] = utf8_encode($this->firstname." ".$this->name);
|
||||||
$info["sn"] = utf8_encode($this->name);
|
$info["sn"] = utf8_encode($this->name);
|
||||||
$info["givenName"] = utf8_encode($this->firstname);
|
$info["givenName"] = utf8_encode($this->firstname);
|
||||||
@ -259,12 +258,7 @@ class Contact
|
|||||||
$info["mail"] = $this->email;
|
$info["mail"] = $this->email;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dnshort = explode(",", LDAP_ADMIN_DN.','.LDAP_SUFFIX_DN,2);
|
$dn = "cn=".$info["cn"].",".LDAP_CONTACT_DN.",".LDAP_SUFFIX_DN;
|
||||||
|
|
||||||
// TODO comprendre pourquoi cela ne marche plus
|
|
||||||
//$dn = "cn=".$info["cn"].","."ou=".$info["ou"].",".$dnshort[1];
|
|
||||||
|
|
||||||
$dn = "cn=".$info["cn"].",".$dnshort[1];
|
|
||||||
|
|
||||||
$r = @ldap_delete($ds, $dn);
|
$r = @ldap_delete($ds, $dn);
|
||||||
|
|
||||||
@ -275,7 +269,7 @@ class Contact
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
echo "Connection au dn $dn échoué !";
|
echo "Connexion au dn $dn échoué !";
|
||||||
}
|
}
|
||||||
|
|
||||||
dolibarr_ldap_unbind($ds);
|
dolibarr_ldap_unbind($ds);
|
||||||
@ -487,6 +481,20 @@ class Contact
|
|||||||
*/
|
*/
|
||||||
function delete($id)
|
function delete($id)
|
||||||
{
|
{
|
||||||
|
$sql = "SELECT c.name, c.firstname FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||||
|
$sql .= " WHERE c.idp = ". $id;
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
if ($this->db->num_rows($resql))
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
|
$this->old_name = $obj->name;
|
||||||
|
$this->old_firstname = $obj->firstname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople";
|
||||||
$sql .= " WHERE idp=$id";
|
$sql .= " WHERE idp=$id";
|
||||||
|
|
||||||
@ -500,32 +508,23 @@ class Contact
|
|||||||
if (defined('MAIN_MODULE_LDAP') && MAIN_MODULE_LDAP)
|
if (defined('MAIN_MODULE_LDAP') && MAIN_MODULE_LDAP)
|
||||||
{
|
{
|
||||||
if (defined('LDAP_CONTACT_ACTIVE') && LDAP_CONTACT_ACTIVE == 1)
|
if (defined('LDAP_CONTACT_ACTIVE') && LDAP_CONTACT_ACTIVE == 1)
|
||||||
|
{
|
||||||
$this->update_ldap($user);
|
|
||||||
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function delete_ldap($user)
|
|
||||||
{
|
|
||||||
$this->fetch($this->id);
|
|
||||||
|
|
||||||
$ds = dolibarr_ldap_connect();
|
$ds = dolibarr_ldap_connect();
|
||||||
|
|
||||||
if ($ds)
|
if ($ds)
|
||||||
{
|
{
|
||||||
//ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
|
|
||||||
//ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $version);
|
|
||||||
dolibarr_ldap_setversion($ds, $version);
|
dolibarr_ldap_setversion($ds, $version);
|
||||||
$ldapbind = dolibarr_ldap_bind($ds);
|
$ldapbind = dolibarr_ldap_bind($ds);
|
||||||
|
|
||||||
if ($ldapbind)
|
if ($ldapbind)
|
||||||
{
|
{
|
||||||
// delete from ldap directory
|
// delete from ldap directory
|
||||||
$dn = utf8_encode("cn=".$this->old_firstname." ".$this->old_name.", ".LDAP_SUFFIX_DN);
|
$userdn = utf8_encode($this->old_firstname." ".$this->old_name);
|
||||||
|
$dn = "cn=".$userdn.",".LDAP_CONTACT_DN.",".LDAP_SUFFIX_DN;
|
||||||
|
|
||||||
$r = @ldap_delete($ds, $dn);
|
$r = @ldap_delete($ds, $dn);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -542,6 +541,8 @@ class Contact
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* \brief Charge les informations sur le contact, depuis la base
|
* \brief Charge les informations sur le contact, depuis la base
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -51,7 +52,7 @@ class modLdap extends DolibarrModules
|
|||||||
$this->name = "Ldap";
|
$this->name = "Ldap";
|
||||||
$this->family = "technic";
|
$this->family = "technic";
|
||||||
$this->description = "Synchronisation Ldap";
|
$this->description = "Synchronisation Ldap";
|
||||||
$this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
|
$this->version = 'experimental'; // 'experimental' or 'dolibarr' or version
|
||||||
$this->const_name = "MAIN_MODULE_LDAP";
|
$this->const_name = "MAIN_MODULE_LDAP";
|
||||||
$this->const_config = MAIN_MODULE_LDAP;
|
$this->const_config = MAIN_MODULE_LDAP;
|
||||||
$this->special = 1;
|
$this->special = 1;
|
||||||
|
|||||||
@ -282,7 +282,7 @@ DNContactActiveYes=Activated synchronization
|
|||||||
DNContactActiveExample=Desactivated synchronization
|
DNContactActiveExample=Desactivated synchronization
|
||||||
DNContact=Contacts' DN
|
DNContact=Contacts' DN
|
||||||
DNContactExample=ex: ou=contacts
|
DNContactExample=ex: ou=contacts
|
||||||
TypeExample=OpenLdap or Egroupware
|
TypeExample=OpenLdap, Egroupware or Active Directory
|
||||||
##### Propal #####
|
##### Propal #####
|
||||||
PropalSetup=Commercial proposals module setup
|
PropalSetup=Commercial proposals module setup
|
||||||
##### Sendings #####
|
##### Sendings #####
|
||||||
|
|||||||
@ -282,7 +282,7 @@ DNContactActiveYes=Synchronisation activ
|
|||||||
DNContact=DN des contacts
|
DNContact=DN des contacts
|
||||||
DNContactActiveExample=Synchronisation désactivée
|
DNContactActiveExample=Synchronisation désactivée
|
||||||
DNContactExample=ex: ou=contacts
|
DNContactExample=ex: ou=contacts
|
||||||
TypeExample=OpenLdap ou Egroupware
|
TypeExample=OpenLdap, Egroupware ou Active Directory
|
||||||
##### Propal #####
|
##### Propal #####
|
||||||
PropalSetup=Configuration du module Propositions Commerciales
|
PropalSetup=Configuration du module Propositions Commerciales
|
||||||
##### Sendings #####
|
##### Sendings #####
|
||||||
|
|||||||
@ -54,12 +54,19 @@ function dolibarr_ldap_connect()
|
|||||||
|
|
||||||
function dolibarr_ldap_bind($ds)
|
function dolibarr_ldap_bind($ds)
|
||||||
{
|
{
|
||||||
if (defined("LDAP_ADMIN_PASS") && LDAP_SUFFIX_DN && LDAP_ADMIN_DN && LDAP_ADMIN_PASS)
|
if (defined("LDAP_ADMIN_PASS") && LDAP_SUFFIX_DN && LDAP_ADMIN_DN && LDAP_ADMIN_PASS)
|
||||||
{
|
{
|
||||||
$ldapbind = ldap_bind($ds, LDAP_ADMIN_DN.",".LDAP_SUFFIX_DN, LDAP_ADMIN_PASS);
|
if (defined("LDAP_SERVER_TYPE") && LDAP_USER_DN && LDAP_SERVER_TYPE == activedirectory)
|
||||||
}
|
{
|
||||||
|
$ldapbind = ldap_bind($ds, LDAP_ADMIN_DN.",".LDAP_USER_DN.",".LDAP_SUFFIX_DN, LDAP_ADMIN_PASS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ldapbind = ldap_bind($ds, LDAP_ADMIN_DN.",".LDAP_SUFFIX_DN, LDAP_ADMIN_PASS);
|
||||||
|
}
|
||||||
|
|
||||||
return $ldapbind;
|
return $ldapbind;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user