]> git.entuzijast.net Git - freeradius-dialup-admin.git/commitdiff
* Add a directive ldap_debug. Add debuging statements in the ldap library
authorkkalev <kkalev>
Sat, 11 Jan 2003 18:33:10 +0000 (18:33 +0000)
committerkkalev <kkalev>
Sat, 11 Jan 2003 18:33:10 +0000 (18:33 +0000)
* Add debug statements in the pg driver

Changelog
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/user_info.php3
lib/sql/drivers/pg/functions.php3

index d0704b355909f0436c5bd716aeee6ea046474212..275255a4c06a9d734a5ae563f06ef96847fb5acf 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -25,6 +25,8 @@ Ver 1.62:
   sql command succeeds we delete the corresponding input file. That way if an sql server is down we store the
   accounting info in the input file and then send it all when it comes back up.
 * Add a directive sql_debug. Add debuging statements in the sql library
+* Add a directive ldap_debug. Add debuging statements in the ldap library
+* Add debug statements in the pg driver
 Ver 1.61:
 * Add a string encoder for greek
 * If general_decode_normal_attributes is set then encode attributes in lib/ldap/change_info. In the near future
index 414e94df3c349a32ce91586ec4a4fab6a87593b1..9c4d34622610a0451c52c6c6ab5bdda578ea7fba 100644 (file)
@@ -54,12 +54,30 @@ require_once('../lib/ldap/functions.php3');
                                }
                        }
                        if (isset($mod)){
+                              if ($config[ldap_debug] == 'true')
+                                       print "<b>DEBUG(LDAP): ldap_mod_del(): DN='$dn'</b><br>\n";
+                                       print "<b>DEBUG(LDAP): ldap_mod_del(): Data:";
+                                       print_r($mod);
+                                       print "</b><br>\n";
+                               }
                                @ldap_mod_del($ds,$dn,$mod);
                        }
                        if (isset($add_r)){
+                              if ($config[ldap_debug] == 'true')
+                                       print "<b>DEBUG(LDAP): ldap_mod_add(): DN='$dn'</b><br>\n";
+                                       print "<b>DEBUG(LDAP): ldap_mod_add(): Data:";
+                                       print_r($add_r);
+                                       print "</b><br>\n";
+                               }
                                @ldap_mod_add($ds,$dn,$add_r);
                        }
                        if (isset($del)){
+                              if ($config[ldap_debug] == 'true')
+                                       print "<b>DEBUG(LDAP): ldap_mod_replace(): DN='$dn'</b><br>\n";
+                                       print "<b>DEBUG(LDAP): ldap_mod_replace(): Data:";
+                                       print_r($del);
+                                       print "</b><br>\n";
+                               }
                                @ldap_mod_del($ds,$dn,$del);
                        }
                }
index 8d0e47e3fb3eb9cbb462bb895d264836f8f5cb6a..175b460dc5ae88575a2198ee11be772ff2a2f0f9 100644 (file)
@@ -36,6 +36,12 @@ require_once('../lib/ldap/functions.php3');
                        if ($Fhomephone != '' && $Fhomephone != '-' && $Fhomephone != $homephone)
                                $mod['homephone'] = $Fhomephone;
                        if ($dn != ''){
+                              if ($config[ldap_debug] == 'true')
+                                       print "<b>DEBUG(LDAP): ldap_mod_replace(): DN='$dn'</b><br>\n";
+                                       print "<b>DEBUG(LDAP): ldap_mod_replace(): Data:";
+                                       print_r($mod);
+                                       print "</b><br>\n";
+                               }
                                @ldap_mod_replace($ds,$dn,$mod);
                                if (@ldap_error($ds) != 'Success')
                                        echo "<b>LDAP ERROR: " . ldap_error($ds) . "</b><br>\n";
index 8ec3108f8238dbf25ffd9e152d919a967141b9ad..e68d52614e1e9a2d8159f8f7dd7517031e817d1f 100644 (file)
@@ -12,6 +12,12 @@ require_once('../lib/ldap/functions.php3');
                                $passwd = da_encrypt($passwd);
                                $passwd = '{' . $config[general_encryption_method] . '}' . $passwd;
                                $mod[$attrmap['User-Password']] = $passwd;
+                               if ($config[ldap_debug] == 'true')
+                                       print "<b>DEBUG(LDAP): ldap_mod_replace(): DN='$dn'</b><br>\n";
+                                       print "<b>DEBUG(LDAP): ldap_mod_replace(): Data:";
+                                       print_r($mod);
+                                       print "</b><br>\n";
+                               }
                                @ldap_mod_replace($ds,$dn,$mod);
                                if (@ldap_error($ds) != 'Success')
                                        echo "<b>LDAP ERROR: " . ldap_error($ds) . "</b><br>\n";
index f59eb394d182f1f97f45a4419d032a4b93c46485..00856fe7fe4144d54133174f9a5a46ab7237feb4 100644 (file)
@@ -34,8 +34,12 @@ require_once('../lib/ldap/functions.php3');
                                $new_user_entry[$attrmap['User-Password']]="{clear}" . $passwd;
                        }
 
-                       print_r($new_user_entry);
-
+                       if ($config[ldap_debug] == 'true'){
+                               print "<b>DEBUG(LDAP): ldap_add(): DN='$dn'</b><br>\n";
+                               print "<b>DEBUG(LDAP): ldap_add(): Entry Data:";
+                               print_r($new_user_entry);
+                               print "</b><br>\n";
+                       }
                        @ldap_add($ds,$dn,$new_user_entry);
 
                        foreach($show_attrs as $key => $attr){
@@ -51,6 +55,12 @@ require_once('../lib/ldap/functions.php3');
                                        continue;
                                $mod[$attrmap["$key"]] = $$attrmap["$key"];
 
+                               if ($config[ldap_debug] == 'true'){
+                                       print "<b>DEBUG(LDAP): ldap_mod_add(): DN='$dn'</b><br>\n";
+                                       print "<b>DEBUG(LDAP): ldap_mod_add(): Data:";
+                                       print_r($mod);
+                                       print "</b><br>\n";
+                               }
                                @ldap_mod_add($ds,$dn,$mod);
                        }
                }
index 4b868a3fa15169653b116a787a16f4b89661ff56..0005cb12792c5ab97f11d162ad17324c84ef3b29 100644 (file)
@@ -6,6 +6,8 @@ if ($config[ldap_default_dn] != ''){
        $ds=@ldap_connect("$config[ldap_server]");  // must be a valid ldap server!
        if ($ds) {
                        $r=@da_ldap_bind($ds,$config);
+               if ($config[ldap_debug] == 'true')
+                       print "<b>DEBUG(LDAP): Search Query: BASE='$config[ldap_default_dn]',FILTER='objectclass=*'</b><br>\n";
                        $sr=@ldap_search($ds,"$config[ldap_default_dn]", 'objectclass=*');
                        if ($info = @ldap_get_entries($ds, $sr)){
                                $dn = $info[0]['dn'];
@@ -25,11 +27,15 @@ if ($config[ldap_default_dn] != ''){
                }
                if ($regular_profile_attr != ''){
                        $get_attrs = array("$regular_profile_attr");
+                       if ($config[ldap_debug] == 'true')
+                               print "<b>DEBUG(LDAP): Search Query: BASE='$config[ldap_base]',FILTER='uid=$login'</b><br>\n";
                        $sr=@ldap_search($ds,"$config[ldap_base]","uid=" . $login,$get_attrs);
                        if ($info = @ldap_get_entries($ds,$sr)){
                                for($i=0;$i<$info[0][$regular_profile_attr]["count"];$i++){
                                        $dn2 = $info[0][$regular_profile_attr][$i];
                                        if ($dn2 != ''){
+                                               if ($config[ldap_debug] == 'true')
+                                                       print "<b>DEBUG(LDAP): Search Query: BASE='$dn2',FILTER='objectclass=*'</b><br>\n";
                                                $sr2=@ldap_search($ds,"$dn2",'objectclass=*');
                                                if ($info2 = @ldap_get_entries($ds,$sr2)){
                                                        $dn3 = $info2[0]['dn'];
index 627c805e0236e29775137770e28f4143266c6412..f64042953418e37165d48f35b61b5ac0d2e82d98 100644 (file)
@@ -7,6 +7,8 @@ else
 if ($ds){
        $r = @da_ldap_bind($ds,$config);
        if ($r){
+               if ($config[ldap_debug] == 'true')
+                       print "<b>DEBUG(LDAP): Delete Request: DN='$dn'</b><br>\n";
                @ldap_delete($ds,$dn);
                if (@ldap_error($ds) == 'Success')
                        echo "<b>User Deleted successfully</b><br>\n";
index e1809180c636a0d63aee5925def8c2e5780bba2a..5b9e4a31a602fb772331f8c5c8193ee173c77532 100644 (file)
@@ -9,7 +9,9 @@ if ($ds) {
                require('../lib/ldap/attrmap.php3');
                $attr = $attrmap[$radius_attr];
        }
-       $sr=@ldap_search($ds,"$config[ldap_base]", "(&($attr=*$search*)(uid=*))",array('uid'),0,$max_results);
+       if ($config[ldap_debug] == 'true')
+               print "<b>DEBUG(LDAP): Search Query: BASE='$config[ldap_base]',FILTER='$attr=*$search*'</b><br>\n";
+       $sr=@ldap_search($ds,"$config[ldap_base]", "$attr=*$search*",array('uid'),0,$max_results);
        if (($info = @ldap_get_entries($ds, $sr))){
                for ($i = 0; $i < $info["count"]; $i++)
                        $found_users[] = $info[$i]['uid'][0];
index ac095c6fa4e7866b1a280cb5ab39182a35795c30..01f568b7b28a326f6017f1f1f936728022ace16a 100644 (file)
@@ -15,17 +15,25 @@ function da_ldap_bind($ds,$config)
                        ($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);
+               }
+               if (preg_match('/[\s,]/',$din)){        // It looks like a dn
+                       if ($config[ldap_debug] == 'true')
+                               print "<b>DEBUG(LDAP): Bind Request: DN='$din',PASSWD='$pass'</b><br>\n";
+                       return @ldap_bind($ds,"$din","$pass");
+               }
                else{                           // It's not a DN. Find a corresponding DN
+                       if ($config[ldap_debug] == 'true')
+               print "<b>DEBUG(LDAP): Bind Request: DN='$config[ldap_binddn]',PASSWD='$config[ldap_bindpw]'</b><br>\n";
                        $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);
+                               if ($din != ''){
+                                       if ($config[ldap_debug] == 'true')
+                                               print "<b>DEBUG(LDAP): Bind Request: DN='$din',PASSWD='$pass'</b><br>\n";
+                                       return @ldap_bind($ds,"$din","$pass");
+                               }
                        }
                }
        }
index aa5b52b800e715508bdf38e4e0829027a8f8bf42..e704bc0a90ea1b37985c93440fa5981dbcc127a9 100644 (file)
@@ -30,6 +30,8 @@ if ($config[general_decode_normal_attributes] == 'yes')
 $ds=@ldap_connect("$config[ldap_server]");  // must be a valid ldap server!
 if ($ds) {
        $r=@da_ldap_bind($ds,$config);
+       if ($config[ldap_debug] == 'true')
+               print "<b>DEBUG(LDAP): Search Query: BASE='$config[ldap_base]',FILTER='uid=$login'</b><br>\n";
        $sr=@ldap_search($ds,"$config[ldap_base]", 'uid=' . $login);
        $info = @ldap_get_entries($ds, $sr);
        $dn = $info[0]['dn'];
index 7e91a96866e3fd5d865e6172e2d8fa2f74d38bde..d0f885a747b8a08beb5f28176f197a8ca8e96d5f 100644 (file)
@@ -29,16 +29,25 @@ function da_sql_close($link,$config)
 
 function da_sql_query($link,$config,$query)
 {
+       if ($config[sql_debug] == 'true')
+               print "<b>DEBUG(SQL,PG DRIVER): Query: $query</b><br>\n";
        return @pg_exec($link,$query);
 }
 
 function da_sql_num_rows($result,$config)
 {
+       if ($config[sql_debug] == 'true')
+               print "<b>DEBUG(SQL,PG DRIVER): Query Result: Num rows:: " . @pg_numrows($result) . "</b><br>\n";
        return @pg_numrows($result);
 }
 
 function da_sql_fetch_array($result,$config)
 {
+       if ($config[sql_debug] == 'true'){
+               print "<b>DEBUG(SQL,PG DRIVER): Query Result: ";
+               print_r(@pg_fetch_array($result,$config[tmp_pg_array_num][$result]++,PGSQL_ASSOC));
+               print  "</b><br>\n";
+       }
        $row = @pg_fetch_array($result,$config[tmp_pg_array_num][$result]++,PGSQL_ASSOC);
        if (!$row)
                $config[tmp_pg_array_num][$result] = 0;
@@ -47,6 +56,8 @@ function da_sql_fetch_array($result,$config)
 
 function da_sql_affected_rows($link,$result,$config)
 {
+       if ($config[sql_debug] == 'true')
+               print "<b>DEBUG(SQL,PG DRIVER): Query Result: Affected rows:: " . @pg_cmdtuples($result) . "</b><br>\n";
        return @pg_cmdtuples($result);
 }