add new header ident.h
[freeradius.git] / dialup_admin / lib / ldap / user_info.php3
1 <?php
2 require('../lib/ldap/attrmap.php3');
3 require_once('../lib/ldap/functions.php3');
4 if (is_file("../lib/lang/$config[general_prefered_lang]/utf8.php3"))
5         include_once("../lib/lang/$config[general_prefered_lang]/utf8.php3");
6 else
7         include_once('../lib/lang/default/utf8.php3');
8
9 $cn = '-';
10 $cn_lang = '-';
11 $address = '-';
12 $address_lang = '-';
13 $homeaddress = '-';
14 $homeaddress_lang = '-';
15 $fax = '-';
16 $url = '-';
17 $ou = '-';
18 $ou_lang = '-';
19 $title = '-';
20 $title_lang = '-';
21 $telephonenumber = '-';
22 $homephone = '-';
23 $mobile = '-';
24 $mail = '-';
25 $mailalt = '-';
26 $dn = '';
27 $user_exists = 'no';
28 unset($item_vals);
29
30 if ($config[general_decode_normal_attributes] == 'yes')
31         $decode_normal = 1;
32
33 $ds=@ldap_connect("$config[ldap_server]");  // must be a valid ldap server!
34 if ($ds) {
35         $r=@da_ldap_bind($ds,$config);
36         if ($config[ldap_userdn] == ''){
37                 if ($config[ldap_filter] != '')
38                         $filter = xlat($config[ldap_filter],$login,$config);
39                 else
40                         $filter = 'uid=' . $login;
41         }
42         else
43                 $filter = xlat($config[ldap_userdn],$login,$config);
44         if ($config[ldap_debug] == 'true'){
45                 if ($config[ldap_userdn] == '')
46                         print "<b>DEBUG(LDAP): Search Query: BASE='$config[ldap_base]',FILTER='$filter'</b><br>\n";
47                 else
48                         print "<b>DEBUG(LDAP): Search Query: BASE='$filter',FILTER='(objectclass=radiusprofile)'</b><br>\n";
49         }
50         if ($config[ldap_userdn] == '')
51                 $sr=@ldap_search($ds,"$config[ldap_base]", $filter);
52         else
53                 $sr=@ldap_read($ds,$filter, '(objectclass=radiusprofile)');
54         $info = @ldap_get_entries($ds, $sr);
55         $dn = $info[0]['dn'];
56         if ($dn == '')
57                 $user_exists = 'no';
58         else{
59                 $user_exists = 'yes';
60                 $user_info = 1;
61                 $k = init_decoder();
62                 $cn = ($info[0]['cn'][0]) ? $info[0]['cn'][0] : '-';
63                 if ($decode_normal)
64                         $cn = decode_string($cn,$k);
65                 $cn_lang = $info[0]["cn;lang-$config[general_prefered_lang]"][0];
66                 $cn_lang = decode_string("$cn_lang", $k);
67                 $cn_lang = ($cn_lang) ? $cn_lang : '-';
68                 $telephonenumber = ($info[0]['telephonenumber'][0]) ? $info[0]['telephonenumber'][0] : '-';
69                 $homephone = ($info[0]['homephone'][0]) ? $info[0]['homephone'][0] : '-';
70                 $address = ($info[0]['postaladdress'][0]) ? $info[0]['postaladdress'][0] : '-';
71                 if ($decode_normal)
72                         $address = decode_string($address,$k);
73                 $address_lang = $info[0]["postaladdress;lang-$config[general_prefered_lang]"][0];
74                 $address_lang = decode_string("$address_lang",$k);
75                 $address_lang = ($address_lang) ? $address_lang : '-';
76                 $homeaddress = ($info[0]['homepostaladdress'][0]) ? $info[0]['homepostaladdress'][0] : '-';
77                 $homeaddress_lang = $info[0]["homepostaladdress;lang-$config[general_prefered_lang]"][0];
78                 $homeaddress_lang = decode_string("$homeaddress_lang", $k);
79                 $homeaddress_lang = ($homeaddress_lang) ? $homeaddress_lang : '-';
80                 $mobile = ($info[0]['mobile'][0]) ? $info[0]['mobile'][0] : '-';
81                 $fax = ($info[0]['facsimiletelephonenumber'][0]) ? $info[0]['facsimiletelephonenumber'][0] : '-';
82                 $url = ($info[0]['labeleduri'][0]) ? $info[0]['labeleduri'][0] : '-';
83                 $ou = $info[0]['ou'][0];
84                 if ($decode_normal)
85                         $ou = decode_string($ou,$k);
86                 $ou_lang = $info[0]["ou;lang-$config[general_prefered_lang]"][0];
87                 $ou_lang = decode_string("$ou_lang", $k);
88                 $ou_lang = ($ou_lang) ? $ou_lang : '-';
89                 $mail = ($info[0]['mail'][0]) ? $info[0]['mail'][0] : '-';
90                 $title = ($info[0]['title'][0]) ? $info[0]['title'][0] : '-';
91                 if ($decode_normal)
92                         $title = decode_string($title,$k);
93                 $title_lang = $info[0]["title;lang-$config[general_prefered_lang]"][0];
94                 $title_lang = decode_string("$title_lang", $k);
95                 $title_lang = ($title_lang) ? $title_lang : '-';
96                 $mailalt = ($info[0]['mailalternateaddress'][0]) ? $info[0]['mailalternateaddress'][0] : '-';
97                 $user_password_exists = ($info[0]['userpassword'][0] != '') ? 'yes' : 'no';
98                 foreach($attrmap as $key => $val){
99                         $item_vals["$key"] = $info[0]["$val"];
100                 }
101         }
102         @ldap_close($ds);
103 }
104 else
105         echo "<b>Could not connect to the LDAP server</b><br>\n";
106 ?>