From ad6cf8772ddf30951c3bbc58dbf585a09e44ba8c Mon Sep 17 00:00:00 2001 From: opensides Date: Tue, 15 Jun 2004 18:13:55 +0000 Subject: [PATCH] premier import du nouveau code ldap ATTENTION !! ceci peut abimer l'arbre ldap pour l'instant --- htdocs/admin/ldap.php | 27 ++++++++++++---------- htdocs/contact.class.php | 49 ++++++++++++++++++++-------------------- htdocs/lib/ldap.lib.php | 10 ++++---- 3 files changed, 45 insertions(+), 41 deletions(-) diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 7243fdf23d2..23b559be77b 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -31,11 +31,11 @@ if ($_GET["action"] == 'setvalue' && $user->admin) $db->query($sql); - $sql = "REPLACE INTO ".MAIN_DB_PREFIX."const SET name = 'LDAP_SERVER_LOGIN', value='".$HTTP_POST_VARS["login"]."', visible=0"; + $sql = "REPLACE INTO ".MAIN_DB_PREFIX."const SET name = 'LDAP_SERVER_PASS', value='".$HTTP_POST_VARS["pass"]."', visible=0"; $db->query($sql); - $sql = "REPLACE INTO ".MAIN_DB_PREFIX."const SET name = 'LDAP_SERVER_PASS', value='".$HTTP_POST_VARS["pass"]."', visible=0"; + $sql = "REPLACE INTO ".MAIN_DB_PREFIX."const SET name = 'LDAP_SERVER_TYPE', value='".$HTTP_POST_VARS["type"]."', visible=0"; $db->query($sql); @@ -73,8 +73,8 @@ print "\n"; print 'Serveur LDAP'.LDAP_SERVER_HOST.''; print 'DN'.LDAP_SERVER_DN.''; -print 'Login'.LDAP_SERVER_LOGIN.''; print 'Pass'.LDAP_SERVER_PASS.''; +print 'Type'.LDAP_SERVER_TYPE.''; print ''; @@ -94,19 +94,22 @@ print ''; print 'DN'; print ''; print ''; -print 'Login'; -print ''; -print ''; print 'Pass'; print ''; print ''; +print ''; +print ''; + print ''; print ''; print ''; -print 'test
'; +print 'test de connection
'; if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && $_GET["action"] == 'test') { @@ -114,25 +117,25 @@ if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && $_GET["action"] == 'test' if ($ds) { - print "connect ok
"; + print "connection réussie
"; - //ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); + ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); $ldapbind = dolibarr_ldap_bind($ds); if ($ldapbind) { - print "bind ok
"; + print "connection au dn réussi
"; } else { - print "bind erreur
"; + print "connection au dn raté
"; } ldap_close($ds); } else { - print "connect erreur
"; + print "connection échouée
"; } } diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php index 53e0bcb6d1d..ce7dbcde191 100644 --- a/htdocs/contact.class.php +++ b/htdocs/contact.class.php @@ -129,12 +129,13 @@ class Contact ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); $ldapbind = dolibarr_ldap_bind($ds); - + if ($ldapbind) { $info["cn"] = utf8_encode($this->firstname." ".$this->name); $info["sn"] = utf8_encode($this->name); - + $info["ou"] = "People"; + if ($this->email) $info["rfc822Mailbox"] = $this->email; @@ -149,7 +150,7 @@ class Contact if ($this->poste) $info["title"] = utf8_encode($this->poste); - + if ($this->socid > 0) { $soc = new Societe($this->db); @@ -160,32 +161,32 @@ class Contact $info["l"] = utf8_encode($soc->ville); } } - + $info["objectclass"][0] = "organizationalPerson"; $info["objectclass"][1] = "inetOrgPerson"; - $info["objectclass"][2] = "phpgwContact"; // compatibilite egroupware - - $info['uidnumber'] = $this->id; - - $info['phpgwTz'] = 0; - $info['phpgwMailType'] = 'INTERNET'; - $info['phpgwMailHomeType'] = 'INTERNET'; - +// $info["objectclass"][2] = "phpgwContact"; // compatibilite egroupware + +// $info['uidnumber'] = $this->id; + +// $info['phpgwTz'] = 0; +// $info['phpgwMailType'] = 'INTERNET'; +// $info['phpgwMailHomeType'] = 'INTERNET'; + $info["uid"] = $this->id. ":".$info["sn"]; - $info["phpgwContactTypeId"] = 'n'; - $info["phpgwContactCatId"] = 0; - $info["phpgwContactAccess"] = "public"; - $info["phpgwContactOwner"] = $user->egroupware_id; +// $info["phpgwContactTypeId"] = 'n'; +// $info["phpgwContactCatId"] = 0; +// $info["phpgwContactAccess"] = "public"; +// $info["phpgwContactOwner"] = $user->egroupware_id; $info["givenName"] = utf8_encode($this->firstname); - - if ($this->phone_mobile) - $info["phpgwCellTelephoneNumber"] = dolibarr_print_phone($this->phone_mobile); - + +// if ($this->phone_mobile) +// $info["phpgwCellTelephoneNumber"] = dolibarr_print_phone($this->phone_mobile); + //$dn = "uid=".$info["uid"].","."cn=".$info["cn"].", ".LDAP_SERVER_DN ; - $dn = "cn=".$info["cn"].", ".LDAP_SERVER_DN ; - - $r = @ldap_delete($ds, $dn); - + //$dn = "cn=".$info["cn"].", ".LDAP_SERVER_DN ; + + $r = @ldap_delete($ds, LDAP_SERVER_DN); + if (! ldap_add($ds, $dn, $info)) { $this->error[0] = ldap_err2str(ldap_errno($ds)); diff --git a/htdocs/lib/ldap.lib.php b/htdocs/lib/ldap.lib.php index f52f8f64d9f..7d74e12b2b9 100644 --- a/htdocs/lib/ldap.lib.php +++ b/htdocs/lib/ldap.lib.php @@ -31,15 +31,15 @@ Function dolibarr_ldap_connect() Function dolibarr_ldap_bind($ds) { - if (defined("LDAP_SERVER_PASS") && LDAP_SERVER_PASS) + if (defined("LDAP_SERVER_PASS") && LDAP_SERVER_DN && LDAP_SERVER_PASS) { - $ldapbind = ldap_bind($ds, LDAP_SERVER_LOGIN, LDAP_SERVER_PASS); + $ldapbind = ldap_bind($ds, LDAP_SERVER_DN, LDAP_SERVER_PASS); } - else +/* else { - $ldapbind = ldap_bind($ds, $dn); + $ldapbind = ldap_bind($ds, $dn); -- connection anonyme desactivee } - +*/ return $ldapbind; }