ServiceConnection
API reference › LDAP › ServiceConnection
Opens a service-account connection only after requiring and establishing verified StartTLS.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
auth() | Creates a guard without sending service credentials to global authentication event listeners. | ServiceConnection |
connect() | Establishes a bound session or fails outside the native query retry handler. | ServiceConnection |
initialize() | Sets options on the specific LDAP handle, not on the process-wide defaults. | ServiceConnection |
query() | Creates the native query builder with strict paged-result handling. | ServiceConnection |
Method details
Section titled “Method details”auth()
Section titled “auth() ”public function auth(): LdapRecord\Auth\GuardCreates a guard without sending service credentials to global authentication event listeners.
Returns
LdapRecord\Auth\Guard: Authentication guard for this connection.
Throws
DirectoryUnavailableException: if the connection cannot establish verified StartTLS.
connect()
Section titled “connect() ”public function connect(string|null $username = null, string|null $password = null): voidEstablishes a bound session or fails outside the native query retry handler.
Parameters
| Parameter | Type | Description |
|---|---|---|
$username | string| | Explicit bind name. When both arguments are null, uses the configured account. |
$password | string| | Password corresponding to the explicit bind name. |
Throws
DirectoryUnavailableException: if the service account could not bind.
initialize()
Section titled “initialize() ”public function initialize(): voidSets options on the specific LDAP handle, not on the process-wide defaults.
Throws
DirectoryUnavailableException: if StartTLS or a required option fails.
query()
Section titled “query() ”public function query(): LdapRecord\Query\BuilderCreates the native query builder with strict paged-result handling.
Returns
LdapRecord\Query\Builder: Query builder configured with this connection’s base DN and cache.