Hi,
Since migrating from MariaDB, CentOs 6 to PostgreSQL, Ubuntu 14.04 LTS
RT::Authen:ExternalAuth garbles our beautiful German umlauts:
[24732] [Wed May 11 13:34:00 2016] [debug]: Calling UserExists with $username
(horst) and $service (My_LDAP)
(/opt/rt4/local/plugins/RT-Authen-ExternalAuth/lib/RT/Authen/ExternalAuth.pm:465)
[...]
[24732] [Wed May 11 13:34:00 2016] [debug]: Found LDAP DN: CN=Testmäister\,
Hörst,OU=SBSUsers,OU=Users,OU=MyBusiness,DC=tracetronic,DC=local
(/opt/rt4/local/plugins/RT-Authen-ExternalAuth/lib/RT/Authen/ExternalAuth/LDAP.pm:221)
[...]
[24732] [Wed May 11 13:34:00 2016] [info]:
RT::Authen::ExternalAuth::CanonicalizeUserInfo returning EmailAddress: , Name:
horst, RealName: Testmäister, Hörst
(/opt/rt4/local/plugins/RT-Authen-ExternalAuth/lib/RT/Authen/ExternalAuth.pm:868)
[24732] [Wed May 11 13:34:00 2016] [debug]: UPDATED user horst: User horst:
RealName changed from 'Testmäister, Hörst' to 'Testmäister, Hörst'
(/opt/rt4/local/plugins/RT-Authen-ExternalAuth/lib/RT/Authen/ExternalAuth.pm:665)
I found that when running the value from LDAP through an additional
$value_from_ldap = decode('utf-8', $value_from_ldap), the value gets
ungarbled...(see attached patch). Which is an okay workaround for us, but maybe
you know of a better workaround? Unfortunately my perl foo is not good enough
to found the root cause of this issue.
Cheers,
Vinzenz
Vinzenz Sinapius
Information Technology | Informationstechnik
tracetronic GmbH
Stuttgarter Str. 3
01189 DRESDEN
GERMANY
Phone: +49 351 205768-167
Fax: +49 351 205768-999
E-mail: [email protected]<mailto:[email protected]>
Head Office | Hauptsitz: Stuttgarter Str. 3, 01189 DRESDEN, GERMANY
Managing Directors | Geschäftsführer: Dr.-Ing. Rocco Deutschmann, Dr.-Ing.
Peter Strähle
Registration Court | Registergericht: Amtsgericht Dresden, HRB 23 086
diff --git
a/local/plugins/RT-Authen-ExternalAuth/lib/RT/Authen/ExternalAuth/LDAP.pm
b/local/plugins/RT-Authen-ExternalAuth/lib/RT/Authen/ExternalAuth/LDAP.pm
index 912e8e6..6770221 100644
--- a/local/plugins/RT-Authen-ExternalAuth/lib/RT/Authen/ExternalAuth/LDAP.pm
+++ b/local/plugins/RT-Authen-ExternalAuth/lib/RT/Authen/ExternalAuth/LDAP.pm
@@ -3,6 +3,7 @@ package RT::Authen::ExternalAuth::LDAP;
use Net::LDAP qw(LDAP_SUCCESS LDAP_PARTIAL_RESULTS);
use Net::LDAP::Util qw(ldap_error_name escape_filter_value);
use Net::LDAP::Filter;
+use Encode;
use strict;
@@ -401,8 +402,18 @@ sub CanonicalizeUserInfo {
if ($RT::LdapAttrMap and $RT::LdapAttrMap->{$key} eq 'dn') {
$params{$key} = $entry->dn();
} else {
- $params{$key} =
- ($entry->get_value($config->{'attr_map'}->{$key}))[0];
+ my $val =
($entry->get_value($config->{'attr_map'}->{$key}))[0];
+ # Sometimes Net::LDAP returns garbled data which can be
ungarbled
+ # by runnning it through decode.
+ # This is an ugly fix, but it works for us...
+ if (defined($val)) {
+ my $val_decoded = decode('utf-8', $val);
+ if($val ne $val_decoded) {
+ $RT::Logger->warning("Whoops: " . $val . " vs " .
$val_decoded);
+ $val = $val_decoded;
+ }
+ }
+ $params{$key} = $val;
}
}
$found = 1;
---------
RT 4.4 and RTIR Training Sessions https://bestpractical.com/training
* Washington DC - May 23 & 24, 2016