original_string: private function is_role($username, $role) {
          if (empty($this->config->{$role['settingname']}) or empty($this->config->memberattribute)) {
              return null;
          }
  
          $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding);
  
          $ldapconnection = $this->ldap_connect();
  
          if ($this->config->memberattribute_isdn) {
              if (!($userid = $this->ldap_find_userdn($ldapconnection, $extusername))) {
                  return false;
              }
          } else {
              $userid = $extusername;
          }
  
          $groupdns = explode(';', $this->config->{$role['settingname']});
          $isrole = ldap_isgroupmember($ldapconnection, $userid, $groupdns, $this->config->memberattribute);
  
          $this->ldap_close();
  
          return $isrole;
      }
code: private function is_role($username, $role) {
          if (empty($this->config->{$role['settingname']}) or empty($this->config->memberattribute)) {
              return null;
          }
  
          $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding);
  
          $ldapconnection = $this->ldap_connect();
  
          if ($this->config->memberattribute_isdn) {
              if (!($userid = $this->ldap_find_userdn($ldapconnection, $extusername))) {
                  return false;
              }
          } else {
              $userid = $extusername;
          }
  
          $groupdns = explode(';', $this->config->{$role['settingname']});
          $isrole = ldap_isgroupmember($ldapconnection, $userid, $groupdns, $this->config->memberattribute);
  
          $this->ldap_close();
  
          return $isrole;
      }
code_tokens: private function is_role ( $ username , $ role ) { if ( empty ( $ this -> config -> { $ role [ 'settingname' ] } ) or empty ( $ this -> config -> memberattribute ) ) { return null ; } $ extusername = core_text :: convert ( $ username , 'utf-8' , $ this -> config -> ldapencoding ) ; $ ldapconnection = $ this -> ldap_connect ( ) ; if ( $ this -> config -> memberattribute_isdn ) { if ( ! ( $ userid = $ this -> ldap_find_userdn ( $ ldapconnection , $ extusername ) ) ) { return false ; } } else { $ userid = $ extusername ; } $ groupdns = explode ( ';' , $ this -> config -> { $ role [ 'settingname' ] } ) ; $ isrole = ldap_isgroupmember ( $ ldapconnection , $ userid , $ groupdns , $ this -> config -> memberattribute ) ; $ this -> ldap_close ( ) ; return $ isrole ; }
docstring: Check if user has LDAP group membership.
  
  Returns true if user should be assigned role.
  
  @param mixed $username username (without system magic quotes).
  @param array $role Array of role's shortname, localname, and settingname for the config value.
  @return mixed result null if role/LDAP context is not configured, boolean otherwise.
docstring_tokens: Check if user has LDAP group membership .