### Install Adldap2 via Composer Source: https://adldap2.github.io/Adldap2 Use Composer to install the Adldap2 package into your PHP project. ```bash composer require adldap2/adldap2 ``` -------------------------------- ### Basic Adldap2 Usage and Connection Source: https://adldap2.github.io/Adldap2 Demonstrates how to construct an Adldap instance, configure connections, and perform basic LDAP operations like searching and creating entries. Includes error handling for connection issues. ```php // Construct new Adldap instance. $ad = new \Adldap\Adldap(); // Create a configuration array. $config = [ // An array of your LDAP hosts. You can use either // the host name or the IP address of your host. 'hosts' => ['ACME-DC01.corp.acme.org', '192.168.1.1'], // The base distinguished name of your domain to perform searches upon. 'base_dn' => 'dc=corp,dc=acme,dc=org', // The account to use for querying / modifying LDAP records. This // does not need to be an admin account. This can also // be a full distinguished name of the user account. 'username' => 'admin@corp.acme.org', 'password' => 'password', ]; // Add a connection provider to Adldap. $ad->addProvider($config); try { // If a successful connection is made to your server, the provider will be returned. $provider = $ad->connect(); // Performing a query. $results = $provider->search()->where('cn', '=', 'John Doe')->get(); // Finding a record. $user = $provider->search()->find('jdoe'); // Creating a new LDAP entry. You can pass in attributes into the make methods. $user = $provider->make()->user([ 'cn' => 'John Doe', 'title' => 'Accountant', 'description' => 'User Account', ]); // Setting a model's attribute. $user->cn = 'John Doe'; // Saving the changes to your LDAP server. if ($user->save()) { // User was saved! } } catch (\ Adldap\Auth\BindException $e) { // There was an issue binding / connecting to the server. } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.