Directory
API reference › LDAP › Directory
Registers named service-account connections for native LdapRecord models and explicit membership changes.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$connections | array<array-key, | Trusted application configuration keyed by connection name. Default: []. | Directory |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | yii\ |
__call() | Calls the named method which is not a class method. | yii\ |
__get() | Returns the value of an object property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets value of an object property. | yii\ |
__unset() | Sets an object property to null. | yii\ |
bootstrap() | Registers this application’s connections without replacing any existing connection or changing the default. | Directory |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
disconnect() | Closes this component’s open LDAP handles without changing the registry. | Directory |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined. | yii\ |
init() | Initializes the object. | yii\ |
isReadConnection() | Confirms that a query uses one of this component’s read connections. | Directory |
setMembership() | Adds or removes one direct membership through an explicitly writable connection. | Directory |
unregister() | Releases owned names and closes their handles before the application is recreated. | Directory |
createConnection() protected | Creates an unconnected LdapRecord connection using this package’s service-account transport. | Directory |
Method details
Section titled “Method details”bootstrap()
Section titled “bootstrap() ”public function bootstrap(yii\base\Application $app): voidRegisters this application’s connections without replacing any existing connection or changing the default.
Parameters
| Parameter | Type | Description |
|---|---|---|
$app | yii\ | Application bootstrapping this component. |
Throws
yii\base\InvalidConfigException: if a name or endpoint is invalid or the name is already registered.
disconnect()
Section titled “disconnect() ”public function disconnect(): voidCloses this component’s open LDAP handles without changing the registry.
Subsequent operations reconnect as the original configured service account. Every handle is closed even if one of them fails; the first failure is then rethrown.
Throws
Throwable: if a connection cannot be closed.
isReadConnection()
Section titled “isReadConnection() ”public function isReadConnection(string $name, LdapRecord\Connection $connection): boolConfirms that a query uses one of this component’s read connections.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Name used to register the connection. |
$connection | LdapRecord\ | Connection instance used by the query. |
Returns
bool: Whether the registry still owns the exact connection and it is not enabled for writes.
setMembership()
Section titled “setMembership() ”public function setMembership(LdapRecord\Models\ActiveDirectory\Group|LdapRecord\Models\OpenLDAP\Group $group, LdapRecord\Models\ActiveDirectory\User|LdapRecord\Models\OpenLDAP\User $user, bool $member): boolAdds or removes one direct membership through an explicitly writable connection.
Both persisted models must be loaded on that connection and use the same supported schema. This does not change AD primary groups, follow nested groups, replace an entire member list, or delete any directory entry.
Parameters
| Parameter | Type | Description |
|---|---|---|
$group | LdapRecord\ | Persisted group to modify. |
$user | LdapRecord\ | Persisted user whose direct membership is changed. |
$member | bool | Whether to add the membership instead of removing it. |
Returns
bool: Whether the LDAP modification succeeded.
Throws
yii\base\InvalidConfigException: if the models or write connection do not meet those requirements.Exception: if LdapRecord cannot bind or perform the requested write.
unregister()
Section titled “unregister() ”public function unregister(): voidReleases owned names and closes their handles before the application is recreated.
Does not remove another component’s replacement connection. Call only after the application has stopped using native LDAP models and queries.
createConnection()
Section titled “createConnection() ”protected function createConnection(yii2\extensions\ldap\Endpoint $endpoint): LdapRecord\ConnectionCreates an unconnected LdapRecord connection using this package’s service-account transport.
Parameters
| Parameter | Type | Description |
|---|---|---|
$endpoint | yii2\ | Validated settings for one connection. |
Returns
LdapRecord\Connection: Service connection with no open LDAP handle.