ldap_connect

FunctionReturn type changed in PHP 8.1

Connect to an LDAP server.

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1
Improved
PHP 8.2
PHP 8.3
PHP 8.4
PHP 8.5
PHP 8.6

ldap_connect Function synopsis

ldap_connect(?string $uri = null, int $port = 389): LDAP\Connection|false

Parameters

$uri

OptionalType?stringDefault valuenull

A full LDAP URI of the form ldap://hostname:port or ldaps://hostname:port for SSL encryption.

$port

OptionalTypeintDefault value389

The port to connect to.

Return value

TypeLDAP\Connection|false

Returns an LDAP\Connection instance when the provided LDAP URI seems plausible. It's a syntactic check of the provided parameter but the server(s) will not be contacted! If the syntactic check fails it returns false. ldap_connect will otherwise return a LDAP\Connection instance as it does not actually connect but just initializes the connecting parameters. The actual connect happens with the next calls to ldap_* functions, usually with ldap_bind.

If no argument is specified then the LDAP\Connection instance of the already opened connection will be returned.

Changes to the ldap_connect Function

PHP 8.1

  • Return type added: LDAP\Connection|false
- ldap_connect(?string $uri = null, int $port = 389)
+ ldap_connect(?string $uri = null, int $port = 389): LDAP\Connection|false

PHP 8.0

  • Parameter name of parameter #1 changed: $hostname to $uri
  • Parameter type added for parameter #1 ($uri): ?string
  • Parameter default value added for position #1 ($uri): null
  • Parameter type added for parameter #2 ($port): int
  • Parameter default value added for position #2 ($port): 389
- ldap_connect($hostname, $port)
+ ldap_connect(?string $uri = null, int $port = 389)

ldap_connect Function Availability

PHP VersionAvailability
PHP 8.6Future Release Yes
PHP 8.5Upcoming Release Yes
PHP 8.4Supported (Latest) Yes
PHP 8.3Supported Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Security-Fixes Only Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported Yes
PHP 7.1Unsupported Yes
PHP 7.0Unsupported Yes
PHP 5.6Unsupported Yes
PHP 5.5Unsupported Yes
PHP 5.4Unsupported Yes
PHP 5.3Unsupported Yes