View Issue Details

IDProjectCategoryView StatusLast Update
0017528mantisbtldappublic2014-08-02 14:54
ReporterCrayon Assigned Toatrol  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionno change required 
Product Version1.2.17 
Summary0017528: Application error 0000401 with $g_use_ldap_realname set to ON
Description

Hello, I was able to configure Mantis to work with LDAP. But when I set $g_use_ldap_realname to ON I get an APPLICATION ERROR 0000401.

The message is:
Database query failed. Error received from database was 0001366: Incorrect string value: '\xE9phane' for column 'realname' at row 1 for the query: UPDATE mantis_user_table SET password=? , realname=? , email=? WHERE id=?.

The 'realname' is Stéphane and it seems the 'é' causes the problem. When setting $g_use_ldap_realname to OFF, I have no problem entering the same name in Mantis. The name appears correctly in my MySQL database.

Steps To Reproduce

Setup LDAP with $g_use_ldap_realname to ON.
Try to login with a user that has a 'realname' with a 'é' character.

TagsNo tags attached.

Activities

atrol

atrol

2014-07-21 15:17

developer   ~0040947

Maybe this is a problem with your database definition, make sure the collation for tables and columns is utf8.

Run admin/check.php which might show some errors / warnings

Crayon

Crayon

2014-07-21 15:55

reporter   ~0040948

The same name could be entered with the Web interface. We use utf8_general_ci in the MySQL database.

admin/check.php does not give relevant information.

In database_api.php before it stops working.

$p_query = UPDATE mantis_user_table SET password=? , realname=? , email=? WHERE id=?

And $arr_parms ~=
Array
(
[0] => f3a972xxxxxxx
[1] => St�phane
[2] => xxxx@xxxxx.com
[3] => 36
)

Crayon

Crayon

2014-07-21 17:00

reporter   ~0040950

Just for fun I tried to get the binary result from ldap_realname. I used bin2hex like this:

function ldap_realname( $p_user_id ) {
$t_username = user_get_field( $p_user_id, 'username' );
$temp = ldap_realname_from_username( $t_username );
die(bin2hex($temp));
return $temp;
}

The result is something like this:
53 74 e9 70 68 61 6e 65

E9 is é with ISO 8859-1 (ISO Latin-1).

If I use this code, it is now working:
function ldap_realname( $p_user_id ) {
$t_username = user_get_field( $p_user_id, 'username' );
$temp = ldap_realname_from_username( $t_username );
return mb_convert_encoding($temp, "UTF-8", "ISO-8859-1");
}

Of course this is not a generic fix because it is hardcoded to use ISO-8859-1.

At least it works for me :)

Crayon

Crayon

2014-07-21 18:50

reporter   ~0040951

For some reason setting:
$g_ldap_protocol_version = 3;

Will fix the problem with special characters. Previously I was was using the default setting (0).

So I'm not really sure if this is really a bug or not. If you think this is not a problem, just close the issue.

atrol

atrol

2014-07-22 08:49

developer   ~0040953

Thanks for telling the solution.

$g_ldap_protocol_version = 3 is the recommended setting, at least for Active Directory
http://www.mantisbt.org/docs/master-1.2.x/en/administration_guide.html#ADMIN.CONFIG.AUTH.LDAP
and also what Microsoft is telling about it
http://msdn.microsoft.com/en-us/library/aa366099%28v=vs.85%29.aspx

Do you use Active Directory?
If so, I will close the issue.

Crayon

Crayon

2014-07-22 09:13

reporter   ~0040954

Yes we are using Active Directory. From the link you gave about LDAP 2 vs LDAP 3:

"Use of UTF-8 for all text string attributes to support extended character sets."

So it makes sens that it is now working when $g_ldap_protocol_version is set to 3.