using the latest dev as at 30 May. I have a mapping to Staff role but it doesn't get mapped because the LdapAuthorizationConsumerDrupalRole class defined in LdapAuthorizationConsumerRole.class.php is lowercasing the role names which then don't match the role names from the drupal role Mapping.
The change below fixed it for me.

  public function refreshConsumerIDs() {
    $this->drupalRolesByName = array();
    foreach (array_flip(user_roles()) as $role_name => $rid) {
//      $this->drupalRolesByName[drupal_strtolower($role_name)] = $rid;
      $this->drupalRolesByName[$role_name] = $rid;
    }
    $this->_availableConsumerIDs = array(); // array_values(user_roles(TRUE));
    foreach (array_values(user_roles(TRUE)) as $role_name) {
      $this->_availableConsumerIDs[] = $role_name;
    }
  }

Comments

johnbarclay’s picture

Status: Active » Needs review
StatusFileSize
new3.58 KB

Thanks for noticing this. I'm working through some case sensitivity and escaping issues. The general idea is to make comparisons case insensitive and keep storage and display of roles in mixed case. Since ->drupalRolesByName() is just an index for getting role ids from role names, I think the following patch which accomplishes the same thing is better. It basically stores the keys in lower case and converts to lowercase when comparing.

e.g.
- $result = ($user && !isset($user->roles[$this->drupalRolesByName[$role_name]]));
+ $result = ($user && !isset($user->roles[$this->drupalRolesByName[drupal_strtolower($role_name)]]));

Does that approach and patch work for you?

kasperl’s picture

We applied this patch manually, after an update broke all our Drupal role management. Unfortunately, it did not fix our issues. However, I think the approach of storing all the roles as mixed case but comparing with lowercase should help a lot of sites (and obsolete the mapping process for some).

jzornig’s picture

I backed out my original change and applied the patch from #1. This is working for me.

johnbarclay’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

thisisjoe’s picture

Experienced this issue when using 7.x-1.0-beta11. I ended up creating a utility function instead of calling str_to_lower everywhere. Figured I'd provide my patch in case it's useful. Thanks.

macman824’s picture

Status: Closed (fixed) » Needs review

thisisjoe,

That is an excellent patch, and is the first one that has actually completely solved the problem. Nice work! The only issue with it is that you left some debug code in there that dumps out the user roles arrays after login, which I had to go back in and comment out.

I recommend Joe's patch be reviewed and assuming no strange regressions occur, it be committed (without the debug lines) to head in time for RC1, as this case-sensitivity issue is a major impediment to implementing D7 in production environments with AD authentication and authorization.

johnbarclay’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs review » Needs work

Thanks. This is committed to 7.x-1.x-dev. Still needs to be moved to 7.x-2.x so am moving version tag. All simpletests still work fine after this patch.

johnbarclay’s picture

Status: Needs work » Fixed

This is committed to 7.x-2.x-dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.