Get a user id given its username.

@param string $username
@param array  $params   to allow offset/limit (and more) to be passed

@return int|bool
515027
public function getIdByUsername($username, array $params = [])
    {
        $arr = $this->listing(false, $params);
        if (!isset($arr[$username])) {
            return false;
        }

        return $arr[(string) $username];
    }
1070232
def get_username(self, userid):
        '''
        '''

        username = self.user_map.get(userid)
        if not username:
            users = self.get_users()
            if users:
                members = {
                    m['id']: m['name']
                    for m in users.get('members', [{}])
                    if m.get('id')
                    and m.get('name')
                }
                if members:
                    self.user_map.update(members)

                username = self.user_map.get(userid, userid)

        return username
125700
protected function getUserInfo(string $username)
    {
        if (!isset($this->users[$username])) {
            return null;
        }

        return $this->users[$username];
    }
685466
public static function getByLogin($username)
    {    
        $fields = self::getDbConnection()->fetchAssoc( 'SELECT * FROM '.User::TABLE.' WHERE login = ?', array( $username ) );
        if (!$fields) return false;
        return self::fetch($fields);    
  	}
134821
public function find($username, $expand = true)
    {
        $parameters['username'] = $username;
        $parameters['expand'] = $expand;
        return $this->apiClient->callEndpoint('user', $parameters);
    }
413701
public function getIdNameListByUsername( $username, $config = [] ) {

		$modelClass	= static::$modelClass;
		$modelTable	= $this->getModelTable();

		$config[ 'query' ]	= isset( $config[ 'query' ] ) ? $config[ 'query' ] : $modelClass::find();

		$config[ 'nameColumn' ]		= "$modelTable.id";
		$config[ 'valueColumn' ]	= "concat($modelTable.username, ', ', $modelTable.email)";

		$config[ 'query' ]->andWhere( "$modelTable.username LIKE :uname", [ ':uname' => "$username%" ] );

		return static::findIdNameList( $config );
	}
1012531
public function getByUsername($username)
    {
        $filter = new IteratorFilter();
        $filter->addRelation($this->getUserDefinition()->getUsername(), Relation::EQUAL, $username);
        return $this->getUser($filter);
    }
1055846
public function username($username = null)
    {
        if (func_num_args() === 0) {
            return $this->_username;
        }
        $this->_username = $username ?: null;
        return $this;
    }
593665
private function _get_id_from_user(string $request, $params): ?string
  {
    if ( $this->id_user && $this->check() ){
      $sql = '
        SELECT `o`.`id`
        FROM bbn_observers AS `o`
          LEFT JOIN bbn_observers AS `ro`
            ON `o`.`id_alias` = `ro`.`id`
        WHERE `o`.`id_user` = ?
        AND (
          (
            `o`.`request` LIKE ?
            AND `o`.`params` '.($params ? 'LIKE ?' : 'IS NULL').'
          )
          OR (
            `ro`.`request` LIKE ?
            AND `ro`.`params` '.($params ? 'LIKE ?' : 'IS NULL').'
          )
        )';
       $args = [hex2bin($this->id_user), $request, $request];
       if ( $params ){
         array_splice($args, 2, 0, $params);
         array_push($args, $params);
       }
       return $this->db->get_one($sql, $args);
    }
    return null;
  }
409867
protected function getUserInfo($username)
    {
        if (!isset(self::$users[$username])) return null;
    
        $user = compact('username') + self::$users[$username];
        unset($user['password']);
        
        return $user;
    }
202443
public static function find($username)
    {
        $user = json_decode(self::get("/users/{$username}")->getBody(), true);
        
        return new self($user);
    }
702141
public function postUser($username, $originId, $parameters = [])
    {
        $user = [
            'username' => $username,
            'originId' => $originId,
        ];

        $user += $parameters;

        return $this->jsonCall('POST', 'users', $user);
    }
423797
public function getUser($username)
    {
        $resellers = $this->getUsers();
        return isset($resellers[$username]) ? $resellers[$username] : null;
    }
24427
public function usernameToGuid($username)
    {
        $this->adldap->utilities()->validateNotNull('Username', $username);

        $this->adldap->utilities()->validateLdapIsBound();

        $filter = $this->adldap->getUserIdKey().'='.$username;

        $fields = ['objectGUID'];

        $results = $this->connection->search($this->adldap->getBaseDn(), $filter, $fields);

        $numEntries = $this->connection->countEntries($results);

        if ($numEntries > 0) {
            $entry = $this->connection->getFirstEntry($results);

            $guid = $this->connection->getValuesLen($entry, 'objectGUID');

            $strGUID = $this->adldap->utilities()->binaryToText($guid[0]);

            return $strGUID;
        }

        return false;
    }
664930
def get_user(self, username):
        
        for user in self.users:
            if user.id.name == username:
                return user
        return None
952431
public function get($user_id, $params = [])
    {
        return User::make($this->client, $user_id)
            ->setParams($params);
    }
812923
public function getByUsername ($username)
    {
        $entity = $this->er->findOneBy(array('username' => $username));

        if (NULL == $entity) {
            throw new Exception("User not found: username=$username");
        }

        return $this->getModel($entity);
    }