PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Authentication » Auth » Bug #4992

Search for login name is case insensitive (DB, MySQL)

Details

Submitted2005-08-04 05:28 UTC
Fromsojkam1 at fel dot cvut dot cz
StatusWont fix
PackageAuth
PHP VersionIrrelevant
Roadmaps(Not assigned)

Comments

[2005-08-04 05:28 UTC] sojkam1 at fel dot cvut dot cz

Description:
------------
When using DB container and MySQL database, search for login name is not case sensitive. If there are two users in a database, which have the same login name but in different case, one of them can't log in.

Bellow, I include a patch for solving the problem. It is based on information from http://dev.mysql.com/doc/mysql/en/case-sensitivity.html. Unfortunately, I don't know how this affects databases other than MySQL. Maybe, this problem should be solved in DB package where could be added a possibility to execute a case sensitive search.

Test script:
---------------
diff -rN -udp -udp old-userdb_app/pear/Auth/Container/DB.php new-userdb_app/pear/Auth/Container/DB.php
--- old-userdb_app/pear/Auth/Container/DB.php 2005-08-04 07:14:06.000000000 +0200
+++ new-userdb_app/pear/Auth/Container/DB.php 2005-08-04 07:07:08.000000000 +0200
@@ -253,7 +253,7 @@ class Auth_Container_DB extends Auth_Con

$query = "SELECT ".$sql_from.
" FROM ".$this->options['table'].
- " WHERE ".$this->options['usernamecol']." = '".$this->db->quoteString($username)."'";
+ " WHERE BINARY ".$this->options['usernamecol']." = '".$this->db->quoteString($username)."'";

$res = $this->db->getRow($query, null, DB_FETCHMODE_ASSOC);

[2005-11-04 22:04 UTC] php at alterego dot dp dot ua

This problem should be solved at database scheme level, not programming. Column should be defined as BINARY while creating table.