]> git.entuzijast.net Git - freeradius-dialup-admin.git/commitdiff
* If an sql attribute is not contained in sql, assume that it has the same name as...
authorkkalev <kkalev>
Sat, 7 Sep 2002 20:46:41 +0000 (20:46 +0000)
committerkkalev <kkalev>
Sat, 7 Sep 2002 20:46:41 +0000 (20:46 +0000)
  it is a reply item. Add a comment for that in conf/sql.attrmap.
* Change the way radius attributes are read from the sql database. The change should make things somewhat
  faster. Create a reverse mapping from radius attributes to dialup_admin attributes.
* Add a configuration directive called ldap_use_http_credentials. If it is set to yes then we try to
  connect to the ldap server with the username/password given in http authentication, not those contained
  in admin.conf. That way multiple admins with different permissions on the ldap tree can work on a single
  dialup_admin.
* With the same logic we allow for multiple buttons html pages. We now create a folder html/buttons which
  by default contains a folder default. If the user logs in with http authentication then we try
  to open the file html/buttons/<username>/buttons.html.php3. If we can't we open
  html/buttons/default/buttons.html.php3. That way we can create muiltiple views of say the online users
  page based on which admin requests the page.

24 files changed:
Changelog
conf/admin.conf
conf/sql.attrmap
htdocs/buttons.php3 [new file with mode: 0644]
htdocs/index.html
html/buttons/default/buttons.html.php3 [moved from htdocs/buttons.html with 96% similarity]
lib/ldap/change_attrs.php3
lib/ldap/change_info.php3
lib/ldap/change_passwd.php3
lib/ldap/create_user.php3
lib/ldap/defaults.php3
lib/ldap/delete_user.php3
lib/ldap/find.php3
lib/ldap/functions.php3
lib/ldap/password_check.php3
lib/ldap/user_info.php3
lib/sql/attrmap.php3
lib/sql/change_attrs.php3
lib/sql/create_group.php3
lib/sql/create_user.php3
lib/sql/defaults.php3
lib/sql/find.php3
lib/sql/group_info.php3
lib/sql/user_info.php3

index 9c21533e1924e79868d4b44677a16e2bfe0ad346..09a85e679ddfb844fd1f389db2b75297a7e66842 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,4 @@
-Ver 1.56:
+Ver 1.60:
 * Small html fixes in user_edit.php3 and password.php3
 * Show number of failed logins in the last 7 days in the user admin page
 * Show date in the user/server test page
@@ -20,6 +20,19 @@ Ver 1.56:
   after the user tables. As a result user values should in general overwrite default values.
 * Add support for the default_user_profile of the sql module in lib/sql/defaults.php3
 * In sql.attrmap User-Password should map to User-Password, not Password
+* If an sql attribute is not contained in sql, assume that it has the same name as in dialup_admin and that
+  it is a reply item. Add a comment for that in conf/sql.attrmap.
+* Change the way radius attributes are read from the sql database. The change should make things somewhat
+  faster. Create a reverse mapping from radius attributes to dialup_admin attributes.
+* Add a configuration directive called ldap_use_http_credentials. If it is set to yes then we try to
+  connect to the ldap server with the username/password given in http authentication, not those contained
+  in admin.conf. That way multiple admins with different permissions on the ldap tree can work on a single
+  dialup_admin.
+* With the same logic we allow for multiple buttons html pages. We now create a folder html/buttons which
+  by default contains a folder default. If the user logs in with http authentication then we try
+  to open the file html/buttons/<username>/buttons.html.php3. If we can't we open
+  html/buttons/default/buttons.html.php3. That way we can create muiltiple views of say the online users
+  page based on which admin requests the page.
 Ver 1.55:
 * Update the FAQ about missing attributes from the user/group edit pages and add a few comments
   in the configuration files
index 47393a85c05a68e44d342ad287c315dd50f86ceb..2fbc503eb459aa56c89cc0fe4d1770d8fa9171e6 100644 (file)
@@ -78,6 +78,17 @@ ldap_bindpw: XXXXXXX
 ldap_default_new_entry_suffix: ou=dialup,ou=guests,%{ldap_base}
 ldap_default_dn: uid=default-dialup,%{ldap_base}
 ldap_regular_profile_attr: dialupregularprofile
+#
+# If set to yes then the HTTP credentials (http authentication)
+# will be used to bind to the ldap server instead of ldap_binddn
+# and ldap_bindpw. That way multiple admins with different rights
+# on the ldap database can connect through one dialup_admin interface.
+# The ldap_binddn and ldap_bindpw are still needed to find the DN
+# to bind with (http authentication will only provide us with a
+# username). As a result the ldap_binddn should be able to do a search
+# with a filter of (uid=<username>). Normally, the anonymous (empty DN)
+# user can do that.
+#ldap_use_http_credentials: yes
 
 #
 # can be one of mysql,pg where:
index b828c7666d74d80ba082ee7e6d3c5c567c38f021..9a41e37f0059abb668d144843fc9706b940f7995 100644 (file)
@@ -2,6 +2,9 @@
 # A mapping between the attributes used by dialup_admin and the attribute
 # names that will be stored in the SQL database
 #
+# Attributes that are not contained in this file are assumed to be reply
+# items and map to the same name as the one used by dialup_admin
+#
 # Format:
 # checkItem|replyItem  Attribute-In-Dialup-Admin       Attribute-In-SQL
 #
diff --git a/htdocs/buttons.php3 b/htdocs/buttons.php3
new file mode 100644 (file)
index 0000000..12c2c32
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+$auth_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
+if ($auth_user){
+       if (is_file("../html/buttons/$auth_user/buttons.html.php3"))
+               include("../html/buttons/$auth_user/buttons.html.php3");
+       else{
+               if (is_file("../html/buttons/default/buttons.html.php3"))
+                       include("../html/buttons/default/buttons.html.php3");
+       }
+}
+else{  
+       if (is_file("../html/buttons/default/buttons.html.php3"))
+               include("../html/buttons/default/buttons.html.php3");
+}
+?>
index e08c94e9f9a26c24dfd1ab30c11310b9b134ce1b..b05a435585a3bbcb6656e935fff69a1d31da142f 100644 (file)
@@ -4,7 +4,7 @@
 dialup administration</title>
 </head>
        <frameset cols="122,*" border="0" frameborder="0" framespacing="0">
-               <frame  name="buttons" src="buttons.html" marginwidth="8"
+               <frame  name="buttons" src="buttons.php3" marginwidth="8"
                        marginheight="8" noresize >
                <frame  name="content" src="content.html" marginwidth="8"
                        marginheight="8" >
similarity index 96%
rename from htdocs/buttons.html
rename to html/buttons/default/buttons.html.php3
index 031449456cd641d1b5ae43a0bab3c2f17c7d788e..49ab0b241af64c9ea215b8d40ae68df234b0ab8d 100644 (file)
@@ -18,6 +18,10 @@ function myout(a) {
 <tr><td align=center>
 <img src="images/logo2.gif" vspace=2>
 </td></tr>
+<?php
+if ($HTTP_SERVER_VARS["PHP_AUTH_USER"])
+       echo "<tr valign=top><td align=center><b>Logged in as " . $HTTP_SERVER_VARS["PHP_AUTH_USER"] . "...</b><br><br></td></tr>\n";
+?>
 <tr bgcolor="black" valign=top><td>
 <table border=0 width=100% cellpadding=2 cellspacing=0>
 <tr bgcolor="#907030" align=center valign=top><th>
index 5d03a6009694c45db956f8072f57efe8dada3fe6..937d70cf49ffa42fa0f7cefd1f251005e9f202f1 100644 (file)
@@ -1,8 +1,8 @@
 <?php
-require('../lib/functions.php3');
+require_once('../lib/ldap/functions.php3');
        $ds = @ldap_connect($config[ldap_server]);
        if ($ds){
-               $r = @ldap_bind($ds,"$config[ldap_binddn]",$config[ldap_bindpw]);
+               $r = @da_ldap_bind($ds,$config);
                if ($r){
 
                        foreach($show_attrs as $key => $attr){
index a4d4188006d97fc3793f21891abde9608e03c66d..d41a4145f2cedf9afa5427b1c8edb39cff2ea891 100644 (file)
@@ -1,7 +1,8 @@
 <?php
+require_once('../lib/ldap/functions.php3');
        $ds = @ldap_connect($config[ldap_server]);
        if ($ds){
-               $r = @ldap_bind($ds,"$config[ldap_binddn]",$config[ldap_bindpw]);
+               $r = @da_ldap_bind($ds,$config);
                if ($r){
                        if ($Fcn != '' && $Fcn != '-' && $Fcn != $cn)
                                $mod['cn'] = $Fcn;
index b032cddbf764ddf1d4e00ac513fc9bbbaf07d6e7..48dc4a0964e8d38c48a261410a7fb13e0889ee12 100644 (file)
@@ -1,7 +1,8 @@
 <?php
+require_once('../lib/ldap/functions.php3');
        $ds = @ldap_connect($config[ldap_server]);
        if ($ds){
-               $r = @ldap_bind($ds,"$config[ldap_binddn]",$config[ldap_bindpw]);
+               $r = @da_ldap_bind($ds,$config);
                if ($r){
                        if (is_file("../lib/crypt/$config[general_encryption_method].php3")){
                                include("../lib/crypt/$config[general_encryption_method].php3");
index 1115e6f22312d717cae91765d3adc7f2263bcc44..d64fe0e9ea4162ac204559e6e7541d0f2f5b548b 100644 (file)
@@ -1,7 +1,8 @@
 <?php
+require_once('../lib/ldap/functions.php3');
        $ds = @ldap_connect($config[ldap_server]);
        if ($ds){
-               $r = @ldap_bind($ds,"$config[ldap_binddn]",$config[ldap_bindpw]);
+               $r = @da_ldap_bind($ds,$config);
                if ($r){
                        list ($givenname,$sn) = split(' ',$Fcn,3);
                        $dn = 'uid=' . $login . ',' . $config[ldap_default_new_entry_suffix];
index e37e2cd0bb06579bc82d7781fdcb32dfa2af07b5..4169d8a43a050f2b536d58e1e82f2981e5434dd8 100644 (file)
@@ -1,10 +1,11 @@
 <?php
+require_once('../lib/ldap/functions.php3');
 if ($config[ldap_default_dn] != ''){
        include('../lib/ldap/attrmap.php3');
        $regular_profile_attr = $config[ldap_regular_profile_attr];
        $ds=@ldap_connect("$config[ldap_server]");  // must be a valid ldap server!
        if ($ds) {
-                       $r=@ldap_bind($ds,"$config[ldap_binddn]",$config[ldap_bindpw]);
+                       $r=@da_ldap_bind($ds,$config);
                        $sr=@ldap_search($ds,"$config[ldap_default_dn]", 'objectclass=*');
                        if ($info = @ldap_get_entries($ds, $sr)){
                                $dn = $info[0]['dn'];
index 1d8aab2f035164eefe19abbea5021f43a509638b..052ab7885d7d748a81bd63e92f9bed61427f0060 100644 (file)
@@ -1,7 +1,8 @@
 <?php
+require_once('../lib/ldap/functions.php3');
 $ds = @ldap_connect($config[ldap_server]);
 if ($ds){
-       $r = @ldap_bind($ds,"$config[ldap_binddn]",$config[ldap_bindpw]);
+       $r = @da_ldap_bind($ds,$config);
        if ($r){
                @ldap_delete($ds,$dn);
                if (@ldap_error($ds) == 'Success')
index fdf6ea4ad613dd4c03789601a7fcf4b7c4d06b28..5c6da52e7634f3d86490ab0929b711034a8d2039 100644 (file)
@@ -1,7 +1,8 @@
 <?php
+require_once('../lib/ldap/functions.php3');
 $ds=@ldap_connect("$config[ldap_server]");  // must be a valid ldap server!
 if ($ds) {
-       $r=@ldap_bind($ds,"$config[ldap_binddn]",$config[ldap_bindpw]);
+       $r=@da_ldap_bind($ds,$config);
        if ($search_IN == 'name' || $search_IN == 'ou')
                $attr = ($search_IN == 'name') ? 'cn' : 'ou';
        else if ($search_IN == 'radius'){
index 72805d857613a98a6a347f77718c5b29486522b5..d480bf31d7c319d796a021daf4c1a6f0f13d4d44 100644 (file)
@@ -1,9 +1,37 @@
 <?php
+function da_ldap_bind($ds,$config)
+{
+       if ($ds){
+               if ($config[ldap_use_http_credentials] == 'yes'){
+                       global $HTTP_SERVER_VARS;
+                       $din = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
+                       $pass = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
+               }
+               if ($config[ldap_use_http_credentials] != 'yes' ||
+                       ($din == '' && $pass == '')){
+                       $din = $config[ldap_binddn];
+                       $pass = $config[ldap_bindpw];
+               }       
+               if (preg_match('/[\s,]/',$din))         // It looks like a dn
+                       return @ldap_bind($ds,$din,$pass);
+               else{                           // It's not a DN. Find a corresponding DN
+                       $r=@ldap_bind($ds,"$config[ldap_binddn]",$config[ldap_bindpw]);
+                       if ($r){
+                               $sr=@ldap_search($ds,"$config[ldap_base]", 'uid=' . $din);
+                               $info = @ldap_get_entries($ds, $sr);
+                               $din = $info[0]['dn'];
+                               if ($din != '')
+                                       return @ldap_bind($ds,$din,$pass);
+                       }
+               }
+       }
+}
+
 function connect2db($config)
 {
        $ds=@ldap_connect("$config[ldap_server]");  // must be a valid ldap server!
        if ($ds)
-               $r=@ldap_bind($ds,"$config[ldap_binddn]",$config[ldap_bindpw]);
+               $r=@da_ldap_bind($ds,$config);
        return $ds;
 }
 
index 6893d82986dd9d3f336d2e1cfe425c4825b6faf3..0fae14b8c00c94cc2d66423f1a62874f50059b17 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-require('password.php3');
 
 if ($action == 'checkpass'){
        $ds=@ldap_connect("$config[ldap_server]");  // must be a valid ldap server!
index 497458111c1d044bc6284a4fb54b3c0498714fd8..f14ef3dc5e5e5342ba344ca9be833c59b1144750 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 require('../lib/ldap/attrmap.php3');
+require_once('../lib/ldap/functions.php3');
 if (is_file("../lib/lang/$config[general_prefered_lang]/utf8.php3"))
        include_once("../lib/lang/$config[general_prefered_lang]/utf8.php3");
 else
@@ -25,7 +26,7 @@ $mailalt = '-';
 
 $ds=@ldap_connect("$config[ldap_server]");  // must be a valid ldap server!
 if ($ds) {
-       $r=@ldap_bind($ds,"$config[ldap_binddn]",$config[ldap_bindpw]);
+       $r=@da_ldap_bind($ds,$config);
        $sr=@ldap_search($ds,"$config[ldap_base]", 'uid=' . $login);
        $info = @ldap_get_entries($ds, $sr);
        $dn = $info[0]['dn'];
index 9524f7d5baa8cd57ab3c998792ce225df2901d66..c69f1a8ba784aadb64b8379143b055ad27ad43dc 100644 (file)
@@ -7,5 +7,6 @@ foreach($ARR as $val){
                continue;
        list($type,$key,$v)=split('[[:space:]]+',$val);
        $attrmap["$key"]=$v;
+       $rev_attrmap["$v"] = $key;
        $attr_type["$key"]=$type;
 }
index 9fbfc155f8e2a22af6b9aabef278b1ee89969503..72a2782e116b22b0c81b333f6d6356a7bc548d71 100644 (file)
@@ -16,6 +16,11 @@ if ($link){
        foreach($show_attrs as $key => $desc){
                if ($attrmap["$key"] == 'none')
                        continue;
+               if ($attrmap["$key"] == ''){
+                       $attrmap["$key"] = $key;
+                       $attr_type["key"] = 'replyItem';
+                       $rev_attrmap["$key"] = $key;
+               }
                $i = 0;
                $j = -1;
                $name = $attrmap["$key"] . $i;
index bae7175a12d78c72a1fb90213ed8aee2589f9f32..f6dee4b7814ca58a59f75ba05a1882a5ea12c544 100644 (file)
@@ -29,11 +29,16 @@ if ($link){
                foreach($show_attrs as $key => $attr){
                        if ($attrmap["$key"] == 'none')
                                continue;
-                       if ($attr_type[$key] == 'checkItem'){
+                       if ($attrmap["$key"] == ''){
+                               $attrmap["$key"] = $key;
+                               $attr_type["$key"] = 'replyItem';
+                               $rev_attrmap["$key"] = $key;
+                       }       
+                       if ($attr_type["$key"] == 'checkItem'){
                                $table = "$config[sql_groupcheck_table]";
                                $type = 1;
                        }
-                       else if ($attr_type[$key] == 'replyItem'){
+                       else if ($attr_type["$key"] == 'replyItem'){
                                $table = "$config[sql_groupreply_table]";
                                $type = 2;
                        }
index 7271325a2ac6abffa197e77409ad579525dd207e..fd723ef9b0d222d934f926dfa51c8b0260c2d37f 100644 (file)
@@ -66,11 +66,16 @@ if ($link){
                        foreach($show_attrs as $key => $attr){
                                if ($attrmap["$key"] == 'none')
                                        continue;
-                               if ($attr_type[$key] == 'checkItem'){
+                               if ($attrmap["$key"] == ''){
+                                       $attrmap["$key"] = $key;
+                                       $attr_type["$key"] = 'replyItem';
+                                       $rev_attrmap["$key"] = $key;
+                               }
+                               if ($attr_type["$key"] == 'checkItem'){
                                        $table = "$config[sql_check_table]";
                                        $type = 1;
                                }
-                               else if ($attr_type[$key] == 'replyItem'){
+                               else if ($attr_type["$key"] == 'replyItem'){
                                        $table = "$config[sql_reply_table]";
                                        $type = 2;
                                }
index fbaa3ef3629e3c198a56772bc7f0a8c6de10556f..764161714801bed42607df7197c1782c114d47f4 100644 (file)
@@ -66,8 +66,17 @@ if ($login != ''){
                                        }
                                        else
                                                echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
-                                       foreach($attrmap as $key => $val){
-                                               if (isset($tmp[$val])){
+                                       if (isset($tmp)){
+                                               foreach(array_keys($tmp) as $val){
+                                                       if ($val == '')
+                                                               continue;
+                                                       $key = $rev_attrmap["$val"];
+                                                       if ($key == ''){
+                                                               $key = $val;
+                                                               $attrmap["$key"] = $val;
+                                                               $attr_type["$key"] = 'replyItem';
+                                                               $rev_attrmap["$val"] = $key;
+                                                       }
                                                        if (isset($default_vals["$key"]) && $overwrite_defaults){
                                                                if ($use_op)
                                                                        $default_vals["$key"][operator] = $tmp["$val"][operator];
index 22d2e5bae3b1a384660fe464c377cec17a9a3013..2c638193927cccd38c71eb9f512908d9c32826a9 100644 (file)
@@ -22,6 +22,10 @@ if ($link){
        }
        else if ($search_IN == 'radius' && $radius_attr != ''){
                require("../lib/sql/attrmap.php3");
+               if ($attrmap["$radius_attr"] == ''){
+                       $attrmap["$radius_attr"] = $radius_attr;
+                       $attr_type["$radius_attr"] = 'replyItem';
+               }
                $table = ($attr_type[$radius_attr] == 'checkItem') ? $config[sql_check_table] : $config[sql_reply_table];
                $attr = $attrmap[$radius_attr];
                $res = @da_sql_query($link,$config,
index d26a9128aba7c6bbc332f1cab5c549c282bf5f33..eb29d740972e2f3917a0e90e7fb085c7bd6e1c95 100644 (file)
@@ -64,13 +64,21 @@ if ($link){
                }       
                else
                        echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
-               foreach($attrmap as $key => $val){
-                       if (isset($tmp[$val])){
+               if (isset($tmp)){
+                       foreach(array_keys($tmp) as $val){
+                               if ($val == '')
+                                       continue;
+                               $key = $rev_attrmap["$val"];
+                               if ($key == ''){
+                                       $key = $val;
+                                       $attrmap["$key"] = $val;
+                                       $attr_type["$key"] = 'replyItem';
+                                       $rev_attrmap["$val"] = $key;
+                               }
                                $item_vals["$key"] = $tmp[$val];
                                $item_vals["$key"][count] = $tmp[$val][count];
                                if ($use_op)
                                        $item_vals["$key"][operator] = $tmp[$val][operator];
-
                        }
                }
 
index 0bea6924945a09a29270170f757ae1d1124b1979..81abcfb40d28b2019521947830be00bb26900a69 100644 (file)
@@ -93,13 +93,21 @@ if ($link){
                }
                else
                        echo "<b>Database query failed partially: " . da_sql_error($link,$config) . "</b><br>\n";
-               foreach($attrmap as $key => $val){
-                       if (isset($tmp[$val])){
+               if (isset($tmp)){
+                       foreach(array_keys($tmp) as $val){
+                               if ($val == '')
+                                       continue;
+                               $key = $rev_attrmap["$val"];
+                               if ($key == ''){
+                                       $key = $val;
+                                       $attrmap["$key"] = $val;
+                                       $attr_type["$key"] = 'replyItem';
+                                       $rev_attrmap["$val"] = $key;
+                               }
                                $item_vals["$key"] = $tmp[$val];
                                $item_vals["$key"][count] = $tmp[$val][count];
                                if ($use_op)
                                        $item_vals["$key"][operator] = $tmp[$val][operator];
-
                        }
                }