{"$schema":"https://yii2-framework.github.io/docs/reference/reference.schema.json","schemaVersion":1,"package":"ldap","title":"LDAP","repository":"https://github.com/yii2-extensions/ldap","ref":"main","commit":"d0e3b1737d8aa62071dc52956e777307daf33838","generatedAt":"2026-12-03","url":"https://yii2-framework.github.io/docs/extensions/ldap/reference/","types":{"yii2\\extensions\\ldap\\Directory":{"kind":"class","url":"https://yii2-framework.github.io/docs/extensions/ldap/reference/directory/","summary":"Registers named service-account connections for native LdapRecord models and explicit membership changes.","extends":"yii\\base\\BaseObject","implements":["yii\\base\\BootstrapInterface","yii\\base\\Configurable"],"properties":{"connections":{"type":"array<array-key, mixed>","default":"[]","description":"Trusted application configuration keyed by connection name."}},"methods":{"bootstrap":{"signature":"public function bootstrap(yii\\base\\Application $app): void","summary":"Registers this application's connections without replacing any existing connection or changing the default.","params":[{"name":"$app","type":"yii\\base\\Application","description":"Application bootstrapping this component."}],"return":{"type":"void"},"throws":[{"type":"yii\\base\\InvalidConfigException","description":"if a name or endpoint is invalid or the name is already registered."}]},"createConnection":{"signature":"protected function createConnection(yii2\\extensions\\ldap\\Endpoint $endpoint): LdapRecord\\Connection","summary":"Creates an unconnected LdapRecord connection using this package's service-account transport.","params":[{"name":"$endpoint","type":"yii2\\extensions\\ldap\\Endpoint","description":"Validated settings for one connection."}],"return":{"type":"LdapRecord\\Connection","description":"Service connection with no open LDAP handle."},"visibility":"protected"},"disconnect":{"signature":"public function disconnect(): void","summary":"Closes this component's open LDAP handles without changing the registry.","return":{"type":"void"},"throws":[{"type":"Throwable","description":"if a connection cannot be closed."}]},"isReadConnection":{"signature":"public function isReadConnection(string $name, LdapRecord\\Connection $connection): bool","summary":"Confirms that a query uses one of this component's read connections.","params":[{"name":"$name","type":"string","description":"Name used to register the connection."},{"name":"$connection","type":"LdapRecord\\Connection","description":"Connection instance used by the query."}],"return":{"type":"bool","description":"Whether the registry still owns the exact connection and it is not enabled for writes."}},"setMembership":{"signature":"public function setMembership(LdapRecord\\Models\\ActiveDirectory\\Group|LdapRecord\\Models\\OpenLDAP\\Group $group, LdapRecord\\Models\\ActiveDirectory\\User|LdapRecord\\Models\\OpenLDAP\\User $user, bool $member): bool","summary":"Adds or removes one direct membership through an explicitly writable connection.","params":[{"name":"$group","type":"LdapRecord\\Models\\ActiveDirectory\\Group|LdapRecord\\Models\\OpenLDAP\\Group","description":"Persisted group to modify."},{"name":"$user","type":"LdapRecord\\Models\\ActiveDirectory\\User|LdapRecord\\Models\\OpenLDAP\\User","description":"Persisted user whose direct membership is changed."},{"name":"$member","type":"bool","description":"Whether to add the membership instead of removing it."}],"return":{"type":"bool","description":"Whether the LDAP modification succeeded."},"throws":[{"type":"yii\\base\\InvalidConfigException","description":"if the models or write connection do not meet those requirements."},{"type":"Exception","description":"if LdapRecord cannot bind or perform the requested write."}]},"unregister":{"signature":"public function unregister(): void","summary":"Releases owned names and closes their handles before the application is recreated.","return":{"type":"void"}}},"inherited":{"methods":{"__call":"yii\\base\\BaseObject","__construct":"yii\\base\\BaseObject","__get":"yii\\base\\BaseObject","__isset":"yii\\base\\BaseObject","__set":"yii\\base\\BaseObject","__unset":"yii\\base\\BaseObject","canGetProperty":"yii\\base\\BaseObject","canSetProperty":"yii\\base\\BaseObject","className":"yii\\base\\BaseObject","hasMethod":"yii\\base\\BaseObject","hasProperty":"yii\\base\\BaseObject","init":"yii\\base\\BaseObject"}}},"yii2\\extensions\\ldap\\DirectoryConnection":{"kind":"class","url":"https://yii2-framework.github.io/docs/extensions/ldap/reference/directoryconnection/","summary":"Binds the exact supplied credentials on a LdapRecord transport without dispatching authentication events.","extends":"LdapRecord\\Ldap","methods":{"bind":{"signature":"public function bind(string|null $dn = null, string|null $password = null, array<array-key, mixed>|null $controls = null): LdapRecord\\LdapResultResponse","summary":"Binds a service account without transforming its password or allowing anonymous fallback.","params":[{"name":"$dn","type":"string|null","default":"null","optional":true,"description":"Service-account bind name. A missing or empty name is rejected."},{"name":"$password","type":"string|null","default":"null","optional":true,"description":"Exact password supplied for the bind. A missing or empty password is rejected."},{"name":"$controls","type":"array<array-key, mixed>|null","default":"null","optional":true,"description":"Optional LDAP request controls."}],"return":{"type":"LdapRecord\\LdapResultResponse","description":"Parsed bind response after validation."},"throws":[{"type":"yii2\\extensions\\ldap\\DirectoryUnavailableException","description":"If the transport is not secure or the bind cannot be performed."}]},"bindResultCode":{"signature":"public function bindResultCode(string $principal, string $password): int","summary":"Returns the LDAP result code without interpreting account or server diagnostics.","params":[{"name":"$principal","type":"string","description":"Directory bind name."},{"name":"$password","type":"string","description":"Password to submit unchanged."}],"return":{"type":"int","description":"LDAP result code; empty or NUL-containing credentials are treated as invalid credentials (49)."},"throws":[{"type":"yii2\\extensions\\ldap\\DirectoryUnavailableException","description":"when StartTLS has not completed, or the result cannot be obtained."}]},"connect":{"signature":"public function connect(array<array-key, mixed>|string $hosts = [], int $port = 389, string|null $protocol = null): bool","summary":"Opens a new handle after discarding the previous one, so its TLS state never carries over.","params":[{"name":"$hosts","type":"array<array-key, mixed>|string","default":"[]","optional":true,"description":"Directory host or hosts."},{"name":"$port","type":"int","default":"389","optional":true,"description":"Directory port."},{"name":"$protocol","type":"string|null","default":"null","optional":true,"description":"URI scheme prefix, or `null` for the transport default."}],"return":{"type":"bool","description":"Whether a handle was allocated."}},"setOption":{"signature":"public function setOption(int $option, mixed $value): bool","summary":"Refuses to continue an operation if its requested server controls cannot be installed.","params":[{"name":"$option","type":"int","description":"LDAP option identifier."},{"name":"$value","type":"mixed","description":"Value accepted by that LDAP option."}],"return":{"type":"bool","description":"Whether the option was set."},"throws":[{"type":"yii2\\extensions\\ldap\\DirectoryUnavailableException","description":"when the LDAP client rejects the server controls."}]}}},"yii2\\extensions\\ldap\\DirectoryUnavailableException":{"kind":"class","modifiers":["final"],"url":"https://yii2-framework.github.io/docs/extensions/ldap/reference/directoryunavailableexception/","summary":"Signals an operational directory failure without exposing backend diagnostics or the submitted credentials.","extends":"RuntimeException","methods":{"__construct":{"signature":"public function __construct()","summary":"Creates an exception with a generic message safe to expose to application callers."}}},"yii2\\extensions\\ldap\\PasswordVerifier":{"kind":"class","url":"https://yii2-framework.github.io/docs/extensions/ldap/reference/passwordverifier/","summary":"Verifies credentials for an existing application's directory identity without creating a Yii session.","extends":"yii\\base\\BaseObject","implements":["yii\\base\\Configurable"],"properties":{"host":{"type":"string","default":"''","description":"Directory hostname matching the server certificate, without a scheme or port."},"port":{"type":"int","default":"389","description":"LDAP port accepting StartTLS, not an implicit TLS port."},"timeout":{"type":"int","default":"5","description":"Seconds allowed for the network connection and for each directory reply."}},"methods":{"init":{"signature":"public function init(): void","summary":"Validates the endpoint and timeout without opening a connection.","return":{"type":"void"},"throws":[{"type":"yii\\base\\InvalidConfigException","description":"when the endpoint or timeout is invalid."}]},"newConnection":{"signature":"protected function newConnection(): yii2\\extensions\\ldap\\DirectoryConnection","summary":"Creates an unconnected transport for one verification attempt.","return":{"type":"yii2\\extensions\\ldap\\DirectoryConnection","description":"Transport with no open LDAP handle."},"visibility":"protected"},"verify":{"signature":"public function verify(string $principal, string $password): bool","summary":"Checks the password against a principal obtained from the application's trusted identity mapping.","params":[{"name":"$principal","type":"string","description":"Bind name resolved from the application's trusted identity mapping."},{"name":"$password","type":"string","description":"Password submitted by the user."}],"return":{"type":"bool","description":"Whether the directory accepted the credentials."},"throws":[{"type":"yii2\\extensions\\ldap\\DirectoryUnavailableException","description":"when the connection cannot be secured or the directory fails."}]}},"inherited":{"methods":{"__call":"yii\\base\\BaseObject","__construct":"yii\\base\\BaseObject","__get":"yii\\base\\BaseObject","__isset":"yii\\base\\BaseObject","__set":"yii\\base\\BaseObject","__unset":"yii\\base\\BaseObject","canGetProperty":"yii\\base\\BaseObject","canSetProperty":"yii\\base\\BaseObject","className":"yii\\base\\BaseObject","hasMethod":"yii\\base\\BaseObject","hasProperty":"yii\\base\\BaseObject"}}},"yii2\\extensions\\ldap\\ServiceConnection":{"kind":"class","modifiers":["final"],"url":"https://yii2-framework.github.io/docs/extensions/ldap/reference/serviceconnection/","summary":"Opens a service-account connection only after requiring and establishing verified StartTLS.","extends":"LdapRecord\\Connection","methods":{"auth":{"signature":"public function auth(): LdapRecord\\Auth\\Guard","summary":"Creates a guard without sending service credentials to global authentication event listeners.","return":{"type":"LdapRecord\\Auth\\Guard","description":"Authentication guard for this connection."},"throws":[{"type":"yii2\\extensions\\ldap\\DirectoryUnavailableException","description":"if the connection cannot establish verified StartTLS."}]},"connect":{"signature":"public function connect(string|null $username = null, string|null $password = null): void","summary":"Establishes a bound session or fails outside the native query retry handler.","params":[{"name":"$username","type":"string|null","default":"null","optional":true,"description":"Explicit bind name. When both arguments are null, uses the configured account."},{"name":"$password","type":"string|null","default":"null","optional":true,"description":"Password corresponding to the explicit bind name."}],"return":{"type":"void"},"throws":[{"type":"yii2\\extensions\\ldap\\DirectoryUnavailableException","description":"if the service account could not bind."}]},"initialize":{"signature":"public function initialize(): void","summary":"Sets options on the specific LDAP handle, not on the process-wide defaults.","return":{"type":"void"},"throws":[{"type":"yii2\\extensions\\ldap\\DirectoryUnavailableException","description":"if StartTLS or a required option fails."}]},"query":{"signature":"public function query(): LdapRecord\\Query\\Builder","summary":"Creates the native query builder with strict paged-result handling.","return":{"type":"LdapRecord\\Query\\Builder","description":"Query builder configured with this connection's base DN and cache."}}}},"yii2\\extensions\\ldap\\ServiceQuery":{"kind":"class","modifiers":["final"],"url":"https://yii2-framework.github.io/docs/extensions/ldap/reference/servicequery/","summary":"Rejects incomplete paged results so partial directory reads cannot look like a completed synchronization.","extends":"LdapRecord\\Query\\Builder","methods":{"run":{"signature":"public function run(string $filter): mixed","summary":"Runs an LDAP query and checks the server's paging response when paging is requested.","params":[{"name":"$filter","type":"string","description":"LDAP filter to execute."}],"return":{"type":"mixed","description":"Native search result, unchanged when paging is not requested."},"throws":[{"type":"yii2\\extensions\\ldap\\DirectoryUnavailableException","description":"if a requested page fails or does not carry a paging cookie."}]}}},"yii2\\extensions\\ldap\\UserSynchronizer":{"kind":"class","modifiers":["final"],"url":"https://yii2-framework.github.io/docs/extensions/ldap/reference/usersynchronizer/","summary":"Reads explicitly mapped LDAP user attributes in batches and passes them to application-owned persistence.","methods":{"__construct":{"signature":"public function __construct(yii2\\extensions\\ldap\\Directory $directory)","summary":"Creates a synchronizer restricted to the directory component's registered read connections.","params":[{"name":"$directory","type":"yii2\\extensions\\ldap\\Directory"}]},"sync":{"signature":"public function sync(LdapRecord\\Query\\Model\\Builder $query, array<non-empty-string, non-empty-string> $attributes, Closure(string, string, array<string, mixed>): void $upsert, int $pageSize = 500): int","summary":"Upserts each row using the configured connection name and the directory's stable user identifier.","params":[{"name":"$query","type":"LdapRecord\\Query\\Model\\Builder","description":"User query built on an explicitly named read connection."},{"name":"$attributes","type":"array<non-empty-string, non-empty-string>","description":"Map of application field to LDAP attribute."},{"name":"$upsert","type":"Closure(string, string, array<string, mixed>): void","description":"Persists one user using the connection and GUID as the key."},{"name":"$pageSize","type":"int","default":"500","optional":true,"description":"LDAP page size; the server must support paged results."}],"return":{"type":"int","description":"Number of users passed successfully to the persistence callback."},"throws":[{"type":"yii\\base\\InvalidConfigException","description":"if the mapping, query, or page size is invalid."},{"type":"yii2\\extensions\\ldap\\DirectoryUnavailableException","description":"if a result lacks a stable identifier or paging does not complete."},{"type":"LdapRecord\\LdapRecordException","description":"if LdapRecord cannot bind or query the directory. Upsert exceptions propagate unchanged."}]}}},"yii2\\extensions\\ldap\\exception\\Message":{"kind":"enum","url":"https://yii2-framework.github.io/docs/extensions/ldap/reference/exception/message/","summary":"Defines LDAP exception message templates.","backingType":"string","cases":{"CONNECTION_MANAGER_CHANGED":{"value":"'Unregister this directory before changing the LDAP connection manager.'","description":"Error when the LdapRecord connection manager changed while this directory still owns registrations."},"CONNECTION_NAME_ALREADY_REGISTERED":{"value":"'An LDAP connection with this name is already registered.'","description":"Error when another component already registered the connection name."},"CONNECTION_NAME_INVALID":{"value":"'Specify a valid LDAP connection name.'","description":"Error when a connection name is not a string of letters, digits, underscores or hyphens starting with a letter."},"DIRECTORY_UNAVAILABLE":{"value":"'The directory operation could not be completed.'","description":"Error when a directory operation fails; it carries no backend diagnostics or credentials."},"ENDPOINT_INVALID":{"value":"'Specify a valid LDAP endpoint, base DN, and service-account credentials.'","description":"Error when the host, port, timeout, base DN, credentials or writable flag of an endpoint is invalid."},"ENDPOINT_MUST_BE_ARRAY":{"value":"'Specify LDAP endpoint settings as an array.'","description":"Error when the settings of a connection are not an array."},"LDAP_ATTRIBUTE_NAME_INVALID":{"value":"'Map only explicit LDAP attribute names.'","description":"Error when a synchronization mapping names something other than one explicit LDAP attribute."},"MEMBERSHIP_MODELS_INVALID":{"value":"'Use persisted models of the same schema on an enabled LDAP write connection.'","description":"Error when the group and user are not persisted models of one schema on a writable connection."},"MEMBERSHIP_MODELS_NOT_ON_WRITE_CONNECTION":{"value":"'The models must resolve to the registered LDAP write connection.'","description":"Error when the group or user resolves to a connection other than the registered write connection."},"SYNC_SOURCE_INVALID":{"value":"'Sync requires a mapped user query on a named LDAP read connection and a positive ' . 'page size.'","description":"Error when the synchronization query, mapping or page size is invalid."},"VERIFIER_HOST_INVALID":{"value":"'Specify one LDAP hostname without a scheme or port.'","description":"Error when the password verifier host is not a bare hostname."},"VERIFIER_PORT_OR_TIMEOUT_INVALID":{"value":"'Specify a valid LDAP port and a positive network timeout.'","description":"Error when the password verifier port or timeout is out of range."}},"methods":{"getMessage":{"signature":"public function getMessage(int|string ...$argument): string","summary":"Returns the formatted message string for the error case.","params":[{"name":"$argument","type":"int|string","optional":true,"variadic":true,"description":"Values to insert into the message template."}],"return":{"type":"string"}}}}}}
