]> git.entuzijast.net Git - freeradius-dialup-admin.git/commitdiff
Allow for normal ldap user attributes to be utf8 encoded instead of ascii. Changing...
authorkkalev <kkalev>
Sat, 5 Oct 2002 09:04:52 +0000 (09:04 +0000)
committerkkalev <kkalev>
Sat, 5 Oct 2002 09:04:52 +0000 (09:04 +0000)
user_info will not work in that case.

Changelog
conf/admin.conf
htdocs/user_finger.php3
lib/ldap/functions.php3
lib/ldap/user_info.php3

index a6c79012dd0f50119c92d332c29ceedf272eaa15..ac79fbc7e050ae0d3fa9d71040399d0e0de1ee41 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -22,6 +22,8 @@ Ver 1.60:
 * Fix a small issue with the general_accounting_info_order
 * Fix a problem in failed_logins when NASIPAddress is not set.
 * Allow for multiple regular profile attributes in a user entry.
+* Allow for normal ldap user attributes to be utf8 encoded instead of ascii. Changing attribute values through
+  user_info will not work in that case.
 Ver 1.59:
 * 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
index 3f19e11787064930d02f0100e8c6ad6e09e1c9ab..7992edcbf8b1b42f4a1f7c482078f1ece6ae8872 100644 (file)
@@ -8,6 +8,13 @@
 general_prefered_lang: el
 general_prefered_lang_name: Greek
 #
+# Uncomment this if normal attributes (not the ;lang-xx ones) in ldap
+# are utf8 encoded.
+# Changing user attribute through user_info will *not* work in that case,
+# but you will at least be able to see user attributes.
+#
+#general_decode_normal_attributes: yes
+#
 general_base_dir: /usr/local/dialup_admin
 general_radiusd_base_dir: /usr/local/radiusd
 general_domain: company.com
index 9d242050bf93d09a7e1fae6e61cf9bd453807607..fbcf78a0e04d4d4adcdaba1b21463b224e92b91b 100644 (file)
@@ -11,6 +11,14 @@ User Finger Facility
 </head>
 
 <?php
+if ($config[general_decode_normal_attributes] == 'yes'){
+       if (is_file("../lib/lang/$config[general_prefered_lang]/utf8.php3"))
+               include_once("../lib/lang/$config[general_prefered_lang]/utf8.php3");
+       else
+               include_once('../lib/lang/default/utf8.php3');
+       $k = init_decoder();
+       $decode_normal = 1;
+}
 require('../lib/functions.php3');
 require("../lib/$config[general_lib_type]/functions.php3");
 
@@ -90,7 +98,7 @@ if ($link){
                                if ($finger_info[$servers_num][$num]['callerid'] == '')
                                        $finger_info[$servers_num][$num]['callerid'] = '-';
                                if ($user_info["$user"] == ''){
-                                       $user_info["$user"] = get_user_info($link2,$user,$config);
+                                       $user_info["$user"] = get_user_info($link2,$user,$config,$decode_normal,$k);
                                        if ($user_info["$user"] == '' || $user_info["$user"] == ' ')
                                                $user_info["$user"] = 'Unknown User';
                                }
index 14481f418a28bf204b55c7f6baba66fe5d898194..a1170d69925bf63ac516882db4be7651467a0894 100644 (file)
@@ -35,13 +35,15 @@ function connect2db($config)
        return $ds;
 }
 
-function get_user_info($ds,$user,$config)
+function get_user_info($ds,$user,$config,$decode_normal,$k)
 {
        if ($ds){
                $attrs = array('cn');
                $sr=@ldap_search($ds,"$config[ldap_base]", "uid=" . $user,$attrs);
                $info = @ldap_get_entries($ds, $sr);
                $cn = $info[0]["cn"][0];
+               if ($cn != '' && $decode_normal == 1)
+                       $cn = decode_string($cn,$k);
                if ($cn == '')
                        $cn = '-';
                return $cn;
index f14ef3dc5e5e5342ba344ca9be833c59b1144750..aa5b52b800e715508bdf38e4e0829027a8f8bf42 100644 (file)
@@ -24,6 +24,9 @@ $mobile = '-';
 $mail = '-';
 $mailalt = '-';
 
+if ($config[general_decode_normal_attributes] == 'yes')
+       $decode_normal = 1;
+
 $ds=@ldap_connect("$config[ldap_server]");  // must be a valid ldap server!
 if ($ds) {
        $r=@da_ldap_bind($ds,$config);
@@ -38,12 +41,16 @@ if ($ds) {
                unset($item_vals);
                $k = init_decoder();
                $cn = ($info[0]['cn'][0]) ? $info[0]['cn'][0] : '-';
+               if ($decode_normal)
+                       $cn = decode_string($cn,$k);
                $cn_lang = $info[0]["cn;lang-$config[general_prefered_lang]"][0];
                $cn_lang = decode_string("$cn_lang", $k);
                $cn_lang = ($cn_lang) ? $cn_lang : '-';
                $telephonenumber = ($info[0]['telephonenumber'][0]) ? $info[0]['telephonenumber'][0] : '-';
                $homephone = ($info[0]['homephone'][0]) ? $info[0]['homephone'][0] : '-';
                $address = ($info[0]['postaladdress'][0]) ? $info[0]['postaladdress'][0] : '-';
+               if ($decode_normal)
+                       $address = decode_string($address,$k);
                $address_lang = $info[0]["postaladdress;lang-$config[general_prefered_lang]"][0];
                $address_lang = decode_string("$address_lang",$k);
                $address_lang = ($address_lang) ? $address_lang : '-';
@@ -55,11 +62,15 @@ if ($ds) {
                $fax = ($info[0]['facsimiletelephonenumber'][0]) ? $info[0]['facsimiletelephonenumber'][0] : '-';
                $url = ($info[0]['labeleduri'][0]) ? $info[0]['labeleduri'][0] : '-';
                $ou = $info[0]['ou'][0];
+               if ($decode_normal)
+                       $ou = decode_string($ou,$k);
                $ou_lang = $info[0]["ou;lang-$config[general_prefered_lang]"][0];
                $ou_lang = decode_string("$ou_lang", $k);
                $ou_lang = ($ou_lang) ? $ou_lang : '-';
                $mail = ($info[0]['mail'][0]) ? $info[0]['mail'][0] : '-';
                $title = ($info[0]['title'][0]) ? $info[0]['title'][0] : '-';
+               if ($decode_normal)
+                       $title = decode_string($title,$k);
                $title_lang = $info[0]["title;lang-$config[general_prefered_lang]"][0];
                $title_lang = decode_string("$title_lang", $k);
                $title_lang = ($title_lang) ? $title_lang : '-';