currently the username stored in the htpasswd file is the same as the one stored in drupal. However, drupal does not care about case, but htpasswd do.

Solution is to store both the username as stored in the drupal database and as lowercase.