From: kkalev Date: Sat, 11 Jan 2003 18:33:10 +0000 (+0000) Subject: * Add a directive ldap_debug. Add debuging statements in the ldap library X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=fb56ed3898af72f6956f0fa715f0ea9a90aebed0;p=freeradius-dialup-admin.git * Add a directive ldap_debug. Add debuging statements in the ldap library * Add debug statements in the pg driver --- diff --git a/Changelog b/Changelog index d0704b3..275255a 100644 --- 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 diff --git a/lib/ldap/change_attrs.php3 b/lib/ldap/change_attrs.php3 index 414e94d..9c4d346 100644 --- a/lib/ldap/change_attrs.php3 +++ b/lib/ldap/change_attrs.php3 @@ -54,12 +54,30 @@ require_once('../lib/ldap/functions.php3'); } } if (isset($mod)){ + if ($config[ldap_debug] == 'true') + print "DEBUG(LDAP): ldap_mod_del(): DN='$dn'
\n"; + print "DEBUG(LDAP): ldap_mod_del(): Data:"; + print_r($mod); + print "
\n"; + } @ldap_mod_del($ds,$dn,$mod); } if (isset($add_r)){ + if ($config[ldap_debug] == 'true') + print "DEBUG(LDAP): ldap_mod_add(): DN='$dn'
\n"; + print "DEBUG(LDAP): ldap_mod_add(): Data:"; + print_r($add_r); + print "
\n"; + } @ldap_mod_add($ds,$dn,$add_r); } if (isset($del)){ + if ($config[ldap_debug] == 'true') + print "DEBUG(LDAP): ldap_mod_replace(): DN='$dn'
\n"; + print "DEBUG(LDAP): ldap_mod_replace(): Data:"; + print_r($del); + print "
\n"; + } @ldap_mod_del($ds,$dn,$del); } } diff --git a/lib/ldap/change_info.php3 b/lib/ldap/change_info.php3 index 8d0e47e..175b460 100644 --- a/lib/ldap/change_info.php3 +++ b/lib/ldap/change_info.php3 @@ -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 "DEBUG(LDAP): ldap_mod_replace(): DN='$dn'
\n"; + print "DEBUG(LDAP): ldap_mod_replace(): Data:"; + print_r($mod); + print "
\n"; + } @ldap_mod_replace($ds,$dn,$mod); if (@ldap_error($ds) != 'Success') echo "LDAP ERROR: " . ldap_error($ds) . "
\n"; diff --git a/lib/ldap/change_passwd.php3 b/lib/ldap/change_passwd.php3 index 8ec3108..e68d526 100644 --- a/lib/ldap/change_passwd.php3 +++ b/lib/ldap/change_passwd.php3 @@ -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 "DEBUG(LDAP): ldap_mod_replace(): DN='$dn'
\n"; + print "DEBUG(LDAP): ldap_mod_replace(): Data:"; + print_r($mod); + print "
\n"; + } @ldap_mod_replace($ds,$dn,$mod); if (@ldap_error($ds) != 'Success') echo "LDAP ERROR: " . ldap_error($ds) . "
\n"; diff --git a/lib/ldap/create_user.php3 b/lib/ldap/create_user.php3 index f59eb39..00856fe 100644 --- a/lib/ldap/create_user.php3 +++ b/lib/ldap/create_user.php3 @@ -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 "DEBUG(LDAP): ldap_add(): DN='$dn'
\n"; + print "DEBUG(LDAP): ldap_add(): Entry Data:"; + print_r($new_user_entry); + print "
\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 "DEBUG(LDAP): ldap_mod_add(): DN='$dn'
\n"; + print "DEBUG(LDAP): ldap_mod_add(): Data:"; + print_r($mod); + print "
\n"; + } @ldap_mod_add($ds,$dn,$mod); } } diff --git a/lib/ldap/defaults.php3 b/lib/ldap/defaults.php3 index 4b868a3..0005cb1 100644 --- a/lib/ldap/defaults.php3 +++ b/lib/ldap/defaults.php3 @@ -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 "DEBUG(LDAP): Search Query: BASE='$config[ldap_default_dn]',FILTER='objectclass=*'
\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 "DEBUG(LDAP): Search Query: BASE='$config[ldap_base]',FILTER='uid=$login'
\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 "DEBUG(LDAP): Search Query: BASE='$dn2',FILTER='objectclass=*'
\n"; $sr2=@ldap_search($ds,"$dn2",'objectclass=*'); if ($info2 = @ldap_get_entries($ds,$sr2)){ $dn3 = $info2[0]['dn']; diff --git a/lib/ldap/delete_user.php3 b/lib/ldap/delete_user.php3 index 627c805..f640429 100644 --- a/lib/ldap/delete_user.php3 +++ b/lib/ldap/delete_user.php3 @@ -7,6 +7,8 @@ else if ($ds){ $r = @da_ldap_bind($ds,$config); if ($r){ + if ($config[ldap_debug] == 'true') + print "DEBUG(LDAP): Delete Request: DN='$dn'
\n"; @ldap_delete($ds,$dn); if (@ldap_error($ds) == 'Success') echo "User Deleted successfully
\n"; diff --git a/lib/ldap/find.php3 b/lib/ldap/find.php3 index e180918..5b9e4a3 100644 --- a/lib/ldap/find.php3 +++ b/lib/ldap/find.php3 @@ -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 "DEBUG(LDAP): Search Query: BASE='$config[ldap_base]',FILTER='$attr=*$search*'
\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]; diff --git a/lib/ldap/functions.php3 b/lib/ldap/functions.php3 index ac095c6..01f568b 100644 --- a/lib/ldap/functions.php3 +++ b/lib/ldap/functions.php3 @@ -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 "DEBUG(LDAP): Bind Request: DN='$din',PASSWD='$pass'
\n"; + return @ldap_bind($ds,"$din","$pass"); + } else{ // It's not a DN. Find a corresponding DN + if ($config[ldap_debug] == 'true') + print "DEBUG(LDAP): Bind Request: DN='$config[ldap_binddn]',PASSWD='$config[ldap_bindpw]'
\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 "DEBUG(LDAP): Bind Request: DN='$din',PASSWD='$pass'
\n"; + return @ldap_bind($ds,"$din","$pass"); + } } } } diff --git a/lib/ldap/user_info.php3 b/lib/ldap/user_info.php3 index aa5b52b..e704bc0 100644 --- a/lib/ldap/user_info.php3 +++ b/lib/ldap/user_info.php3 @@ -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 "DEBUG(LDAP): Search Query: BASE='$config[ldap_base]',FILTER='uid=$login'
\n"; $sr=@ldap_search($ds,"$config[ldap_base]", 'uid=' . $login); $info = @ldap_get_entries($ds, $sr); $dn = $info[0]['dn']; diff --git a/lib/sql/drivers/pg/functions.php3 b/lib/sql/drivers/pg/functions.php3 index 7e91a96..d0f885a 100644 --- a/lib/sql/drivers/pg/functions.php3 +++ b/lib/sql/drivers/pg/functions.php3 @@ -29,16 +29,25 @@ function da_sql_close($link,$config) function da_sql_query($link,$config,$query) { + if ($config[sql_debug] == 'true') + print "DEBUG(SQL,PG DRIVER): Query: $query
\n"; return @pg_exec($link,$query); } function da_sql_num_rows($result,$config) { + if ($config[sql_debug] == 'true') + print "DEBUG(SQL,PG DRIVER): Query Result: Num rows:: " . @pg_numrows($result) . "
\n"; return @pg_numrows($result); } function da_sql_fetch_array($result,$config) { + if ($config[sql_debug] == 'true'){ + print "DEBUG(SQL,PG DRIVER): Query Result: "; + print_r(@pg_fetch_array($result,$config[tmp_pg_array_num][$result]++,PGSQL_ASSOC)); + print "
\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 "DEBUG(SQL,PG DRIVER): Query Result: Affected rows:: " . @pg_cmdtuples($result) . "
\n"; return @pg_cmdtuples($result); }