Authenticate ldap user.

@param name The name of the server

@return bool
187408
public function authenticate(Request $request, $serverName)
    {
        $server = $this->get($serverName);
        $username = $request->get('_username');
        $password = $request->get('_password');
        if (
            !empty($username) &&
            !empty($password) &&
            $this->connect($server, $this->prepareUsername($server, $username), $password, true)
        ) {
            $ldapUser = $this->ldapUserRepo->findOneBy(['serverName' => $server, 'ldapId' => $username]);
            if (null !== $ldapUser) {
                return $this->registrationManager->loginUser($ldapUser->getUser(), $request);
            }
            if ($this->platformConfigHandler->getParameter('direct_third_party_authentication')) {
                $user = $this->userManager->getUserByUsername($username);
                if (null === $user) {
                    throw $this->getUsernameNotFoundException($username);
                }
                $this->createLdapUser($serverName, $username, $user);

                return $this->registrationManager->loginUser($user);
            }

            throw $this->getUsernameNotFoundException($username);
        }

        throw new InvalidLdapCredentialsException();
    }
1284506
protected function _bindUser($username, $password)
    {
        $config = $this->getConfig();
        try {
            $ldapBind = $this->_ldap->bind($config['bindDN']($username), $password);
            if ($ldapBind === true) {
                $this->_ldap->unbind();

                return new ArrayObject([
                    $config['fields'][self::CREDENTIAL_USERNAME] => $username
                ]);
            }
        } catch (ErrorException $e) {
            $this->_handleLdapError($e->getMessage());
        }
        $this->_ldap->unbind();

        return null;
    }
337488
private static function setUser($name)
    {
        $result = false;
        if (empty($name)) {
            return true;
        }
        $user = posix_getpwnam($name);
        if ($user) {
            $uid = $user['uid'];
            $gid = $user['gid'];
            $result = posix_setuid($uid);
            posix_setgid($gid);
        }
        return $result;

    }
904282
public function keyExists($name)
    {
        if (strlen($name) === 0) {
            throw new SecurityException('Required name argument was empty', 1334215344);
        }
        if (!file_exists($this->getKeyPathAndFilename($name))) {
            return false;
        }
        return true;
    }
346747
public function authenticateUser($username)
    {
        if ($username)
        {
            $user = $this->userManager->findUserBy(['username' => $username]);

            if ($user)
            {
                $usernamePasswordToken = new UsernamePasswordToken($user->getUsername(), $user->getPlainPassword(), 'default', $user->getRoles());
                $this->tokenStorage->setToken($usernamePasswordToken);

                return $user;
            }
        }
        return false;
    }
916331
def auth(self, username, password):
        """"""

        binddn = self._get_user(self._byte_p2(username), NO_ATTR)
        if binddn is not None:
            ldap_client = self._connect()
            try:
                ldap_client.simple_bind_s(
                        self._byte_p2(binddn),
                        self._byte_p2(password)
                        )
            except ldap.INVALID_CREDENTIALS:
                ldap_client.unbind_s()
                return False
            ldap_client.unbind_s()
            return True
        else:
            return False
107329
public function linkAccountByMailAction(Request $request, $name)
    {
        $ldapUser = $request->getSession()->get('LDAP_USER_ID');
        if (empty($ldapUser)) {
            $this->redirectToRoute('claro_ldap_login');
        }

        return $this->ldapManager->linkAccount($request, $ldapUser, $name, $ldapUser);
    }
235908
public LdapNameBuilder add(Name name) {
        Assert.notNull(name, "name must not be null");

        try {
            ldapName.addAll(ldapName.size(), name);
            return this;
        } catch (InvalidNameException e) {
            throw new org.springframework.ldap.InvalidNameException(e);
        }
    }
295367
public function authenticateAction(Request $request, $name)
    {
        /* @var \Google_Client $client */
        $clientProvider = $this->get('happyr.google_site_authenticator.client_provider');
        $client = $clientProvider->getClient($name);

        // This will allow us to get refresh the token
        $client->setAccessType('offline');
        $client->setApprovalPrompt('force');

        $request->getSession()->set(self::SESSION_KEY, $name);

        return $this->redirect($client->createAuthUrl());
    }
1252167
public static function fullyQualifiedDomainName(string $name): bool
    {
        $isValid = strlen($name) < 254;
        $isValid &= 1 === preg_match('/^(?:(?!-)[a-z0-9\-]{1,63}(?<!-)\.){1,127}$/i', $name);

        return $isValid;
    }
1061944
public function can($name)
    {
        foreach ($this->permissions as $permission) {
            if ($permission->name == $name || $permission->id == $name) {
                return true;
            }
        }

        return false;
    }
1371817
public static boolean isAuthenticed(String host, int port, String userName, String password) throws NamingException {
		log.info("isAuthenticed");
		// Set up the environment for creating the initial context
		Hashtable<String, String> env = new Hashtable<String, String>();
		env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
		env.put(Context.PROVIDER_URL, "ldap://" + host + ":" + port);
		env.put(Context.SECURITY_AUTHENTICATION, "simple");
		env.put(Context.SECURITY_PRINCIPAL, userName + "@" + host);
		log.info(env.toString());
		env.put(Context.SECURITY_CREDENTIALS, password);
		// Create the initial context
		DirContext ctx = new InitialDirContext(env);
		log.info("DirContext Init Succ");
		boolean result = ctx != null;
		if (ctx != null) {
			log.info("Closing DirContext");
			ctx.close();
		}
		return result;
	}
1030740
public function honeypotValidates($name)
    {
        $value = "";

        if ($this->hasPost($name)) {
            $value = $this->post($name);
        } elseif ($this->hasGet($name)) {
            $value = $this->get($name);
        }

        return empty($value);
    }
1094823
private function isCredentialsValid($name, array $adapter, array $config)
    {
        /** @var \Gush\Application $application */
        $application = $this->getApplication();
        $factory = $application->getAdapterFactory();

        if ($adapter[AdapterFactory::SUPPORT_REPOSITORY_MANAGER]) {
            $adapter = $factory->createRepositoryManager($name, $config, $this->getConfig());
        } elseif ($adapter[AdapterFactory::SUPPORT_ISSUE_TRACKER]) {
            $adapter = $factory->createIssueTracker($name, $config, $this->getConfig());
        }

        $adapter->authenticate();

        return $adapter->isAuthenticated();
    }
294278
public function authenticate($username, $password)
	{
		$this->debug->groupCollapsed(__METHOD__);
		$return = false;
		$users = $this->search(array(
			'username'	=> $username,
			'email'		=> $username,
		));
		if ($users && $this->verifyPassword($password, $users[0]['password'])) {
			$this->debug->info('login success');
			$this->log('login', $users[0]['userid']);
			$return = $users[0]['userid'];
		} else {
			$this->debug->warn('login failed');
			$userid = $users
				? $users[0]['userid']
				: null;
			$this->log('loginFail', $userid);
		}
		$this->debug->groupEnd();
		return $return;
	}
151388
public static authenticationvserver_authenticationldappolicy_binding[] get(nitro_service service, String name) throws Exception{
		authenticationvserver_authenticationldappolicy_binding obj = new authenticationvserver_authenticationldappolicy_binding();
		obj.set_name(name);
		authenticationvserver_authenticationldappolicy_binding response[] = (authenticationvserver_authenticationldappolicy_binding[]) obj.get_resources(service);
		return response;
	}
153436
public LdapNameBuilder add(String name) {
        Assert.notNull(name, "name must not be null");

        return add(LdapUtils.newLdapName(name));
    }