mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 17:48:25 +01:00
premier import du nouveau code ldap
ATTENTION !! ceci peut abimer l'arbre ldap pour l'instant
This commit is contained in:
@@ -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 "</tr>\n";
|
||||
print '<tr><td>Serveur LDAP</td><td>'.LDAP_SERVER_HOST.'</td></tr>';
|
||||
|
||||
print '<tr><td>DN</td><td>'.LDAP_SERVER_DN.'</td></tr>';
|
||||
print '<tr><td>Login</td><td>'.LDAP_SERVER_LOGIN.'</td></tr>';
|
||||
print '<tr><td>Pass</td><td>'.LDAP_SERVER_PASS.'</td></tr>';
|
||||
print '<tr><td>Type</td><td>'.LDAP_SERVER_TYPE.'</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
@@ -94,19 +94,22 @@ print '</td></tr>';
|
||||
print '<tr><td>DN</td><td>';
|
||||
print '<input size="25" type="text" name="dn" value="'.LDAP_SERVER_DN.'">';
|
||||
print '</td></tr>';
|
||||
print '<tr><td>Login</td><td>';
|
||||
print '<input size="25" type="text" name="login" value="'.LDAP_SERVER_LOGIN.'">';
|
||||
print '</td></tr>';
|
||||
print '<tr><td>Pass</td><td>';
|
||||
print '<input size="25" type="text" name="pass" value="'.LDAP_SERVER_PASS.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td><select name="type">';
|
||||
print '<option value="openldap" selected>OpenLdap';
|
||||
print '<option value="egroupware">Egroupware';
|
||||
print '</select>';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td><input type="submit" value="changer"></td></tr>';
|
||||
print '</table></form>';
|
||||
|
||||
print '</td></tr></table>';
|
||||
|
||||
print '<a href="ldap.php?action=test">test</a><br>';
|
||||
print '<a href="ldap.php?action=test">test de connection</a><br>';
|
||||
|
||||
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<br>";
|
||||
print "connection r<>ussie<br>";
|
||||
|
||||
//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<br>";
|
||||
print "connection au dn r<>ussi<br>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "bind erreur<br>";
|
||||
print "connection au dn rat<61><br>";
|
||||
}
|
||||
ldap_close($ds);
|
||||
}
|
||||
else
|
||||
{
|
||||
print "connect erreur<br>";
|
||||
print "connection <20>chou<6F>e<br>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,6 +134,7 @@ class Contact
|
||||
{
|
||||
$info["cn"] = utf8_encode($this->firstname." ".$this->name);
|
||||
$info["sn"] = utf8_encode($this->name);
|
||||
$info["ou"] = "People";
|
||||
|
||||
if ($this->email)
|
||||
$info["rfc822Mailbox"] = $this->email;
|
||||
@@ -163,28 +164,28 @@ class Contact
|
||||
|
||||
$info["objectclass"][0] = "organizationalPerson";
|
||||
$info["objectclass"][1] = "inetOrgPerson";
|
||||
$info["objectclass"][2] = "phpgwContact"; // compatibilite egroupware
|
||||
// $info["objectclass"][2] = "phpgwContact"; // compatibilite egroupware
|
||||
|
||||
$info['uidnumber'] = $this->id;
|
||||
// $info['uidnumber'] = $this->id;
|
||||
|
||||
$info['phpgwTz'] = 0;
|
||||
$info['phpgwMailType'] = 'INTERNET';
|
||||
$info['phpgwMailHomeType'] = 'INTERNET';
|
||||
// $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 ;
|
||||
//$dn = "cn=".$info["cn"].", ".LDAP_SERVER_DN ;
|
||||
|
||||
$r = @ldap_delete($ds, $dn);
|
||||
$r = @ldap_delete($ds, LDAP_SERVER_DN);
|
||||
|
||||
if (! ldap_add($ds, $dn, $info))
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user