2 require_once('../lib/functions.php3');
3 require_once('../lib/ldap/functions.php3');
4 if ($config[ldap_write_server])
5 $ds = @ldap_connect($config[ldap_write_server]);
7 $ds = @ldap_connect($config[ldap_server]);
9 $r = @da_ldap_bind($ds,$config);
12 foreach($show_attrs as $key => $attr){
13 if ($attrmap["$key"] == 'none')
17 $name = $attrmap["$key"] . $i;
19 while (isset($$name)){
23 $name = $attrmap["$key"] . $i;
25 // if value is the same as the default and the corresponding attribute in ldap does not exist or
26 // the value is the same as that in ldap then continue
28 if ( (check_defaults($val,'',$default_vals["$key"]) && !isset($item_vals["$key"][$j])) || $val == $item_vals["$key"][$j])
31 // if value is null and ldap attribute does not exist then continue
33 if ($val == '' && !isset($item_vals["$key"][$j]))
36 // if values is the same as the default or if the value is null and the ldap attribute exists
39 if ((check_defaults($val,'',$default_vals["$key"]) || $val == '') &&
40 isset($item_vals["$key"][$j]))
41 $del[$attrmap["$key"]][] = $item_vals["$key"][$j];
43 // else modify the ldap attribute
46 if (isset($item_vals["$key"][$j])){
47 $del[$attrmap["$key"]][] = $item_vals["$key"][$j];
48 $add_r[$attrmap["$key"]][] = $val;
51 $add_r[$attrmap["$key"]][] = $val;
57 if ($config[ldap_debug] == 'true'){
58 print "<b>DEBUG(LDAP): ldap_mod_del(): DN='$dn'</b><br>\n";
59 print "<b>DEBUG(LDAP): ldap_mod_del(): Data:";
63 @ldap_mod_del($ds,$dn,$del);
66 if ($config[ldap_debug] == 'true'){
67 print "<b>DEBUG(LDAP): ldap_mod_add(): DN='$dn'</b><br>\n";
68 print "<b>DEBUG(LDAP): ldap_mod_add(): Data:";
72 @ldap_mod_add($ds,$dn,$add_r);
75 if (@ldap_error($ds) == 'Success')
76 echo "<b>The changes were successfully commited to the directory</b><br>\n";
78 echo "<b>LDAP ERROR: " . ldap_error($ds) . "</b><br>\n";