Connect to LDAP server.

@param mixed[] $config LDAP configuration
@return resource|false LDAP connection
432055
protected function _ldapConnect(array $config)
    {
        $result = false;

        // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
        $connection = @ldap_connect($config['host'], $config['port']);
        if (!is_resource($connection)) {
            Log::critical("Unable to connecto LDAP at [" . $config['host'] . ":" . $config['port'] . "]");

            return $result;
        }

        // set LDAP options
        ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, (int)$config['version']);
        ldap_set_option($connection, LDAP_OPT_REFERRALS, 0);
        ldap_set_option($connection, LDAP_OPT_NETWORK_TIMEOUT, 5);

        // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
        $bind = @ldap_bind($connection, $config['domain'] . '\\' . $config['username'], $config['password']);
        if ($bind === false) {
            Log::critical('Cannot bind with user: ' . $config['username']);

            return $result;
        }

        return $connection;
    }
421030
public function connect(array $config){

		// Defaults
		$defaults = array(
			'resource' => null,
			'charset' => 'utf8',
			'username' => ini_get('mysqli.default_user'),
			'password' => ini_get('mysqli.default_pw'),
			'database' => '',
			'socket' => ini_get('mysqli.default_socket'),
			'port' => ini_get('mysqli.default_port'),
			'host' => ini_get('mysqli.default_host'),
			'persistent' => false,
			'unbuffered' => false
		);

		$config += $defaults;

		// Connect
		if($config['resource'] instanceof mysqli)
			$this->resource = $config['resource'];
		else
			$this->resource = new mysqli($config['host'], $config['username'], $config['password'], $config['database'], $config['port'], $config['socket']);

		if($this->resource->connect_errno)
			throw new DriverException($this->resource->connect_error, $this->resource->connect_errno);

		// Set charset
		if($this->resource instanceof mysqli){
			$ok = @$this->resource->set_charset($config['charset']);
			if(!$ok)
				$this->runQuery("SET NAMES " . $config['charset']);
		}

		$this->unbuffered = $config['unbuffered'];
	}
1110256
protected function getClient(array $config)
    {
        $client = new CloudsearchClient( 
            $config['client_id'], 
            $config['client_secret'], 
            $config['host'],
            'aliyun'
        );

        $search = new CloudsearchSearch($client);
        $search->addIndex($config['app']);

        return $search;
    }
1285342
public function connect(array $config)
    {
        $tns = ! empty($config['tns']) ? $config['tns'] : $this->getDsn($config);

        $options = $this->getOptions($config);

        if (array_get($options, 'session_mode') === OCI_CRED_EXT) {
            // External connections can only be used with user / and an empty password
            $config['username'] = '/';
            $config['password'] = null;
        }

        $connection = $this->createConnection($tns, $config, $options);

        return $connection;
    }
599020
public function connect($config = array())
    {
        if (empty($this->mongo)) {
            $options = array();
            if (!empty($config['options'])) {
                $options = $config['options'];
            }
            $this->mongo = new \MongoClient($config['dsn'], $options);

        }
    }
634190
public function connect($server, $user = null, $password = null, $isAuthentication = false)
    {
        if ($server && isset($server['host'])) {
            if (isset($server['port']) && is_numeric($server['port'])) {
                $this->connect = ldap_connect($server['host'], $server['port']);
            } else {
                $this->connect = ldap_connect($server['host']);
            }

            ldap_set_option($this->connect, LDAP_OPT_PROTOCOL_VERSION, $server['protocol_version']);

            try {
                if ($isAuthentication && $this->connect && $user && $password) {
                    $user = $this->findDnFromUserName($server, $user);

                    return (false === $user) ? $user : ldap_bind($this->connect, $user, $password);
                } elseif ($this->connect) {
                    return ldap_bind($this->connect);
                }
            } catch (\Exception $e) {
                throw new InvalidLdapCredentialsException();
            }
        }
    }
544504
public function connect(array $config)
    {
        $queue = new PHPRedisQueue(
            $this->redis, $config['queue'], Arr::get($config, 'connection', $this->connection)
        );

        $queue->setExpire(Arr::get($config, 'expire', 60));

        return $queue;
    }
768815
public static function configure(array $config)
    {
        if (!is_null(static::$instance)) {
            return static::$instance;
        }

        static::$config = $config;

        static::$session = Session::getInstance();

        return static::$instance = new Auth($config[$config['default']]);
    }
387527
public function connect(array $config)
    {
        $config = $this->getDefaultConfiguration($config);

        if ($config['key'] && $config['secret']) {
            $config['credentials'] = Arr::only($config, ['key', 'secret']);
        }

        return new SqsQueue(
            new SqsClient($config), $config['queue'], $config['prefix'] ?? ''
        );
    }
546741
public function connect(array $config)
	{
		$sqsConfig = array_only($config, array('key', 'secret', 'region', 'default_cache_config'));

		$sqs = SqsClient::factory($sqsConfig);

		return new SqsQueue($sqs, $config['queue']);
	}
187027
public function init(array $config = [])
    {
        if (!extension_loaded('redis')) {
            return false;
        }

        if (!empty($config['host'])) {
            $config['server'] = $config['host'];
        }

        parent::init($config);

        return $this->_connect();
    }
152380
public function connect(array $config)
    {
        $queue = new RedisQueue(
            $this->redis, $config['queue'], array_get($config, 'connection', $this->connection)
        );

        $queue->setExpire(array_get($config, 'expire', 60));

        return $queue;
    }
466372
protected function createPdoResolverWithHosts( array $config )
	{
		return function () use ( $config ) {

			foreach( Arr::shuffle( $hosts = $this->parseHosts( $config ) ) as $key => $host )
			{
				$config['host'] = $host;
				try
				{
					return $this->createConnector( $config )->connect( $config );
				}
				catch( PDOException $e )
				{
					if( count( $hosts ) - 1 === $key )
					{
						App::Log($e);
					}
				}
			}

			if(!isset($e)) {
				$e = new PDOException("Empty connection");
			}

			throw $e;
		};
	}
164062
public function connect(array $config)
    {
        $connection = $this->createConnection($config);

        $this->validateCredentials($config);

        // For basic authentication we need an Authorization
        // header to be set. We add it to the request here.
        $this->addHeader(
            'Authorization',
            'Basic ' . base64_encode(
                array_get($config, 'identifier') . ':' . array_get($config, 'secret')
            )
        );

        return $connection;
    }
229096
public function setConfig(array $config = [])
    {
        // 设置App Key
        $this->appKey = isset($config['appKey']) ? $config['appKey'] : '';

        // 设置App Secret
        $this->appSecret = isset($config['appSecret']) ? $config['appSecret'] : '';

        // 沙箱环境
        $this->sandbox = isset($config['sandbox']) ? (bool)$config['sandbox'] : false;

        // 使用HTTPS
        $this->secure = isset($config['secure']) ? (bool)$config['secure'] : false;

        return $this;
    }
1321020
public function connect(array $config)
    {
        if (isset($config[ 'path' ])) {
            $config[ 'path' ] = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $config[ 'path' ]);

            if (is_dir($config[ 'path' ])) {
                $this->path = $config[ 'path' ];
            } elseif (defined('PATH_CACHE')) {
                if (is_dir($config[ 'path' ])) {
                    $this->path = $config[ 'path' ];
                } else {
                    $this->path = PATH_CACHE . str_replace(PATH_CACHE, '', $config[ 'path' ]);
                }
            } else {
                $this->path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $config[ 'path' ];
            }
        } elseif (defined('PATH_CACHE')) {
            $this->path = PATH_CACHE;
        } else {
            $this->path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . implode(
                    DIRECTORY_SEPARATOR,
                    ['o2system', 'cache']
                );
        }

        $this->path = rtrim($this->path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;

        if ($this->isSupported() === false) {
            throw new OverflowException('CACHE_FILE_E_UNABLE_TO_WRITE', 0, [$this->path]);
        }
    }
934508
public function connect(array $config)
    {
        // This connection string format can also be used to connect
        // to Azure SQL Server databases.
        $port = (isset($config['port'])) ? ',' . $config['port'] : '';

        //check for dblib for mac users connecting to mssql
        if (isset($config['dsn_type']) && !empty($config['dsn_type']) && $config['dsn_type'] == 'dblib') {
            $dsn = "dblib:host={$config['host']}{$port};dbname={$config['database']}";
        } else {
            $dsn = "sqlsrv:Server={$config['host']}{$port};Database={$config['database']}";
        }

        return new \Pimf\Database($dsn, $config['username'], $config['password'], $this->options($config));
    }