When we have a tunneled MS-CHAP2-Success attribute, it goes
[freeradius.git] / dialup_admin / lib / sql / find.php3
1 <?php
2 if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3"))
3         include_once("../lib/sql/drivers/$config[sql_type]/functions.php3");
4 else{
5         echo "<b>Could not include SQL library</b><br>\n";
6         exit();
7 }
8
9 $link = @da_sql_pconnect($config);
10 if ($link){
11         $search = da_sql_escape_string($search);
12         if (!is_numeric($max_results))
13                 $max_results = 10;
14         if (($search_IN == 'name' || $search_IN == 'ou') && $config[sql_use_user_info_table] == 'true'){
15                 $attr = ($search_IN == 'name') ? 'name' : 'department';
16                 $res = @da_sql_query($link,$config,
17                 "SELECT username FROM $config[sql_user_info_table] WHERE
18                 lower($attr) LIKE '%$search%' LIMIT $max_results;");
19                 if ($res){
20                         while(($row = @da_sql_fetch_array($res,$config)))
21                                 $found_users[] = $row[username];
22                 }
23                 else
24                         "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
25         }
26         else if ($search_IN == 'radius' && $radius_attr != ''){
27                 require("../lib/sql/attrmap.php3");
28                 if ($attrmap["$radius_attr"] == ''){
29                         $attrmap["$radius_attr"] = $radius_attr;
30                         $attr_type["$radius_attr"] = 'replyItem';
31                 }
32                 $table = ($attr_type[$radius_attr] == 'checkItem') ? $config[sql_check_table] : $config[sql_reply_table];
33                 $attr = $attrmap[$radius_attr];
34                 $res = @da_sql_query($link,$config,
35                 "SELECT username FROM $table WHERE attribute = '$attr' AND value LIKE '%$search%' LIMIT $max_results;");
36                 if ($res){
37                         while(($row = @da_sql_fetch_array($res,$config)))
38                                 $found_users[] = $row[username];
39                 }
40                 else
41                         "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
42         }
43 }
44 else
45         echo "<b>Could not connect to SQL database</b><br>\n";
46 ?>