@param string $primaryEmailAddress

@return GmailUserInterface|null
557118
public function findGmailUserByPrimaryEmail(string $primaryEmailAddress)
    {
        /** @var GmailUserInterface $user */
        foreach ($this->gmailUsers as $user) {
            if ($user->getPrimaryEmailAddress() === $primaryEmailAddress) {
                return $user;
            }
        }

        return;
    }
1102694
public function single($userAddress)
    {
        $entry = new Entry($userAddress);

        $entry
            ->conditionalField('id', function () {
                return Subbly::api('subbly.user')->hasAccess('subbly.backend.auth');
            })

            // TODO stringField, integerField, ...
            ->field('uid')
            ->field('name')
            ->field('firstname')
            ->field('lastname')
            ->field('address1')
            ->field('address2')
            ->field('zipcode')
            ->field('city')
            ->field('country')
            ->field('phone_work')
            ->field('phone_home')
            ->field('phone_mobile')
            ->field('others_informations')

            ->dateField('created_at')
            ->dateField('updated_at')
        ;

        return $entry->toArray();
    }
36646
public function setEmail($value)
    {
        $primaryAddress = $this->getPrimaryAddress();
        $email = Email::createFromData([
            'label' => 'main',
            'value' => $value,
            'primary' => true,
        ]);

        if ($primaryAddress !== null) {
            $primaryAddress->setEmails([$email]);
        } else {
            $primaryAddress = Address::createFromData(['emails' => [$email]]);
        }

        $this->setPrimaryAddress($primaryAddress);
        $this->setAttribute('email', $value);

        return $this;
    }
1117031
@Nullable
  public IUser getUserOfEmailAddressIgnoreCase (@Nullable final String sEmailAddress)
  {
    if (StringHelper.hasNoText (sEmailAddress))
      return null;

    return findFirst (x -> sEmailAddress.equalsIgnoreCase (x.getEmailAddress ()));
  }
112020
public function findOneByEmail($email)
    {
        $user = $this
            ->findOneBy([
                'email' => $email,
            ]);

        return ($user instanceof AbstractUserInterface)
            ? $user
            : null;
    }
348808
public static function tryParse(string $ipAddress): ?IPAddressInterface
    {
        if (!self::myParse($ipAddress, $octets)) {
            return null;
        }

        return new self($octets);
    }
421407
private function createGoogleBatchClient(string $userEmail)
    {
        if (array_key_exists($userEmail, $this->googleBatchClients)) {
            return $this->googleBatchClients[$userEmail];
        }

        $googleClient = new \Google_Client();
        $googleClient->setScopes(static::SCOPES);
        $googleClient->setAuthConfig($this->configFileLocation);
        $googleClient->setSubject($userEmail);
        $googleClient->setUseBatch(true);

        $this->googleBatchClients[$userEmail] = $googleClient;

        return $googleClient;
    }
385386
public function callback($primaryCallbackURL)
    {
        if (is_string($primaryCallbackURL)) {
            $this->setPrimaryCallbackURL($primaryCallbackURL)
                ->setSecondaryCallbackURL($primaryCallbackURL);
        }

        return $this;
    }
277899
public function getByEmail($emailAddress)
    {
        $path = new ResourcePathServiceOperation($this->getContext(),$this->getResourcePath(),"getByEmail",array($emailAddress));
        return new User($this->getContext(),$path);
    }
731174
public function nextIf($primary, $secondary = null)
    {
        if ($this->tokens[$this->current]->test($primary, $secondary)) {
            return $this->next();
        }
    }
523664
static function fetchForUser( $address, $asObject = true )
    {
        eZDebug::writeStrict(
            'Method ' . __METHOD__ . ' has been deprecated in 5.0',
            'Deprecation'
        );
        $user = eZUser::fetchByEmail( $address );
        if ( $user instanceof eZUser )
        {
            return self::fetchByUserId( $user->attribute( 'contentobject_id' ), $asObject );
        }
        return null;
    }
582484
public function findByUser(UserInterface $user, $ipAddress = null)
	{
		$model = $this->createModel();
		$query = $model->where('user_id', '=', ($userId = $user->getId()));

		if ($ipAddress)
		{
			$query->where(function($query) use ($ipAddress) {
				$query->where('ip_address', '=', $ipAddress);
				$query->orWhere('ip_address', '=', NULL);
			});
		}

		if ( ! $throttle = $query->first())
		{
			$throttle = $this->createModel();
			$throttle->user_id = $userId;
			if ($ipAddress) $throttle->ip_address = $ipAddress;
			$throttle->save();
		}

		return $throttle;
	}
661862
public function resolveUserIdFromEmail(string $email, int $mode)
    {
        switch ($mode) {
            case self::MODE_RESOLVE_PRIMARY_ONLY:
                $gmailUser = $this->getGmailDomain()->findGmailUserByPrimaryEmail($email);

                break;

            case self::MODE_RESOLVE_ALIASES_ONLY:
                $gmailUser = $this->getGmailDomain()->findGmailUserByEmailAlias($email);

                break;

            case self::MODE_RESOLVE_PRIMARY_PLUS_ALIASES:
                $gmailUser = $this->getGmailDomain()->findGmailUserByEmail($email);

                break;

            default:
                throw new \InvalidArgumentException();
        }

        return $gmailUser ? $gmailUser->getUserId() : null;
    }
1122053
public function getSiteByDomain($domain)
    {
        $queryBuilder = $this->_em->createQueryBuilder();
        $queryBuilder->select('domain, site, primaryDomain')
            ->from(\Rcm\Entity\Domain::class, 'domain')
            ->leftJoin('domain.site', 'site')
            ->leftJoin('domain.primaryDomain', 'primaryDomain')
            ->where('domain.domain = :domainName')
            ->setParameter('domainName', $domain);

        try {
            /** @var \Rcm\Entity\Domain $domain */
            $domain = $queryBuilder->getQuery()->getSingleResult();
        } catch (NoResultException $e) {
            return null;
        }

        if ($domain->getPrimary()) {
            $site = $domain->getPrimary()->getSite();
            $this->_em->detach($site);
            $this->_em->detach($domain);
            $site->setDomain($domain);
        } else {
            $site = $domain->getSite();
        }

        return $site;
    }
351779
public static function get($entity, $primaryValue)
    {
        $query = new Query($entity);
        $column = self::getInstance()->getEntityStructure($entity)->primaryColumn;
        $query->where($column->name, $primaryValue);
        return $query->one();
    }
968348
function user_info($username,$fields=NULL){
        if ($username==NULL){ return (false); }
        if (!$this->_bind){ return (false); }
        if  ('' == $this->_users_dn) {
            $this->_users_dn = $this->_base_dn;
        }

        $filter = "(&(".$this->_cn_identifier."=".$username."))";
        if ($fields==NULL){ $fields=array($this->_cn_identifier,"mail",$this->_group_attribute,"department","description","displayname","gecos","telephonenumber","primarygroupid"); }
        $sr=ldap_search($this->_conn,$this->_users_dn,$filter,$fields);
        $entries = $this->ldap_get_entries_raw($sr);
        
        // AD does not return the primary group in the ldap query, we may need to fudge it
        // SysCo/al added a test to check if $entries[0]["primarygroupid"][0] exists
        $add_primary_group = FALSE;
        if ($this->_real_primarygroup){
            if (isset($one_entry["primarygroupid"][0])) {
                $pri_grp_rid = $one_entry["primarygroupid"][0];
                if (isset($this->_cache_group_dn[$pri_grp_rid])) {
                    $dn_group = $this->_cache_group_dn[$pri_grp_rid];
                    $one_entry[$this->_group_attribute][] = $dn_group;
                    $add_primary_group = TRUE;
                } else {
                    $r = ldap_read($this->_conn, $this->_base_dn, "(objectclass=*)", array("objectSid")) or exit();
                    $data = ldap_get_entries($this->_conn, $r);
                    if (isset($data[0]["objectsid"][0])) {
                        $domain_sid = $data[0]["objectsid"][0];
                        $domain_sid_s = sid2str($domain_sid);
                        $r = ldap_search($this->_conn, $this->_base_dn, "objectSid=".$domain_sid_s."-".$pri_grp_rid, array("distinguishedname")) or exit();
                        $data = ldap_get_entries($this->_conn, $r);
                        if (isset($data[0]["distinguishedname"][0])) {
                            $dn_group = $data[0]["distinguishedname"][0];
                            $one_entry[$this->_group_attribute][] = $dn_group;
                            $add_primary_group = TRUE;
                                if (count($this->_cache_group_dn) < 1000) { // Don't overload the memory cache
                                $this->_cache_group_dn[$pri_grp_rid] = $dn_group;
                            }
                        }
                    }
                }
            }
        } else {
            $entries[0][$this->_group_attribute][]="CN=Domain Users,CN=Users,".$this->_base_dn;
            $add_primary_group = TRUE;
        }
        if ($add_primary_group) {
            @$entries[0][$this->_group_attribute]["count"]++;
        }

        return ($entries);
    }
468841
public function getGoogleBatchServiceGmailForUserId(string $userId)
    {
        $email = $this->directory->resolvePrimaryEmailFromUserId($userId);
        if (array_key_exists($email, $this->googleBatchServiceGmails)) {
            return $this->googleBatchServiceGmails[$email];
        }

        $googleServiceGmail = new \Google_Service_Gmail($this->serviceAccount->getGoogleBatchClientForEmail($email));
        $this->googleBatchServiceGmails[$email] = $googleServiceGmail;

        return $googleServiceGmail;
    }