This bundle helps you to use adldap2 library with Symfony.
Install the library via Composer by running the following command:
composer require sgomez/adldap2-bundle
Next, enable the bundle in your app/AppKernel.php
file:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Sgomez\Bundle\Adldap2Bundle\Adldap2Bundle(),
// ...
);
}
You need to configure your connection. The parameters are the same that use Adldap2.
This is a sample configuration that you need to add in the app/config/config.yml
file:
adldap2:
connection_settings:
domain_controllers: ["domain_controller_1", "domain_controller_2"]
base_dn: "dc=domain,dc=com"
admin_username: "username"
admin_password: "password"
account_suffix: "domain.com"
port: 389
follow_referrals: false
use_ssl: false
use_tls: false
use_sso: false
auto_connect: true
You don't need to configure all values. See the original adldap2 documentation for more information.
Note: auto_connect
configuration option is not part of the adldap2 library but instead an option for this bundle
to configure whether you want the 'adldap2' service to automatically connect on application boot or not.
A new service called 'adldap2' has been created. It's a configured instance of Adldap class. You can use it as usual:
class DefaultController extends Controller
{
public function indexAction()
{
$user = $this->get('adldap2')->search()->find('username');
}
}
Note: if you have auto_connect: false
in your adldap2 configuration you will need to manually call connect()
before you can perform any queries on the library.
- UserProvider