import from branch_1_1:
[freeradius.git] / dialup_admin / lib / ldap / change_info.php3
1 <?php
2 require_once('../lib/ldap/functions.php3');
3         if ($config[ldap_write_server])
4                 $ds = @ldap_connect($config[ldap_write_server]);
5         else
6                 $ds = @ldap_connect($config[ldap_server]);
7         if ($config[general_decode_normal_attributes] == 'yes'){
8                 $decode_normal = 1;
9                 if (is_file("../lib/lang/$config[general_prefered_lang]/utf8.php3"))
10                         include_once("../lib/lang/$config[general_prefered_lang]/utf8.php3");
11                 else
12                         include_once('../lib/lang/default/utf8.php3');
13                 $k = init_encoder();
14         }
15         if ($ds){
16                 $r = @da_ldap_bind($ds,$config);
17                 if ($r){
18                         if ($Fcn != '' && $Fcn != '-' && $Fcn != $cn){
19                                 list ($givenname,$sn) = split(' ',$Fcn,2);
20                                 $mod['cn'] = $Fcn;
21                                 $mod['cn'] = ($decode_normal) ? encode_string($mod['cn'],$k) : $mod['cn'];
22                                 $mod['givenname'] = $givenname;
23                         $mod['givenname'] = ($decode_normal) ? encode_string($mod['givenname'],$k) : $mod['givenname'];
24                                 $mod['sn'] = $sn;
25                                 $mod['sn'] = ($decode_normal) ? encode_string($mod['sn'],$k) : $mod['sn'];
26
27                         }
28                         if ($Fmail != '' && $Fmail != '-' && $Fmail != $mail)
29                                 $mod['mail'] = $Fmail;
30                         if ($Fou != '' && $Fou != '-' && $Fou != $ou){
31                                 $mod['ou'] = $Fou;
32                                 $mod['ou'] = ($decode_normal) ? encode_string($mod['ou'],$k) : $mod['ou'];
33                         }
34                         if ($Ftelephonenumber != '' && $Ftelephonenumber != '-' && $Ftelephonenumber != $telephonenumber)
35                                 $mod['telephonenumber'] = $Ftelephonenumber;
36                         if ($Fhomephone != '' && $Fhomephone != '-' && $Fhomephone != $homephone)
37                                 $mod['homephone'] = $Fhomephone;
38                         if ($dn != ''){
39                                if ($config[ldap_debug] == 'true'){
40                                         print "<b>DEBUG(LDAP): ldap_mod_replace(): DN='$dn'</b><br>\n";
41                                         print "<b>DEBUG(LDAP): ldap_mod_replace(): Data:";
42                                         print_r($mod);
43                                         print "</b><br>\n";
44                                 }
45                                 @ldap_mod_replace($ds,$dn,$mod);
46                                 if (@ldap_error($ds) != 'Success')
47                                         echo "<b>LDAP ERROR: " . ldap_error($ds) . "</b><br>\n";
48                                 else
49                                         echo "<b>User personal information updated successfully</b><br>\n";
50                         }
51                 }
52                 @ldap_close($ds);
53         }
54 ?>