Complete support for UTF-8
Internally we're still assuming ASCII-8 on all string, so when doing manipulations between a UTF-8 response from the server and internal strings it will fail with EncodingError on 1.9.
This is likely going to be a huge overhaul and should be a release in itself.
We're using this Gem and the names of the users have unwanted characters, when we should have Latin characters. I guess this is due to the UTF-8 / ASCII-8 conversion.
Is there a workaround for this?
Thanks.
Could you give an example on what's actually in the LDAP server, and the incorrect string that's getting returned?
Hi,
Thanks you for your time.
For example, in the LDAP server I have "Inês Gonçalves" and I get "In\xC3\xAAs Gon\xC3\xA7alves".
We also encountered this issue.
As a workaround: the gem seems to be returning valid UTF-8 text, just in the wrong encoding -- i.e., using force_encoding("UTF-8") on the results returned from LDAP will yield properly encoded text (I've been testing this with Japanese text).
(Ironically, plain ASCII text will be encoded in UTF-8 already, so the force_encoding shouldn't cause issues where there already wasn't one.)
Thanks! It works.
I've also seen this now. Doing like this:
user = ldap.search(
base: filter_base,
filter: user_filter,
attributes: ['samaccountname', 'displayname', 'memberof']
).first
{
username: user.samaccountname.first,
name: user.displayname.first.force_encoding('UTF-8')
}
...works, but it's incredibly ugly to have to force encoding like that. Without it, it "works" for users with ASCII (7-bit) safe names, but users with e.g. scandinavian umlauts (åäö) get problems. (#<Encoding::InvalidByteSequenceError: ""\xC3"" on ASCII-8BIT>) when trying to convert the string to JSON)
Is there a plan to resolve this proper in net-ldap at some point? :+1: from my end on such a thing...
Get the same result on ruby 2.1.6, net-ldap 0.11, windows 8.1 x64 I connect to a French AD server and need to force encoding to UTF-8. (same remark as @doubt72)
ldap returned string "Frédéric" in ASCII-8BIT and I compared it with "Frédéric" in UTF-8 and it matched never.....
Any progress to resolve this is welcome !
@RoryO - care to provide some more details on why this was closed? Has this been fixed, and if so, in what PR?
I encountered the same problem on version 0.12.0. Like @net1957, french LDAP too, problem coming from characters like 'ç', 'é' or 'è'.
For those interested, this bug was fixed directly in Redmine : https://www.redmine.org/issues/21453 with this patch : https://www.redmine.org/projects/redmine/repository/revisions/15025/diff/trunk/app/models/auth_source_ldap.rb
I am having the same issue regarding underscores...