PHP code example of ldaptools / ldaptools-bundle

1. Go to this page and download the library: Download ldaptools/ldaptools-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ldaptools / ldaptools-bundle example snippets


// app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new LdapTools\Bundle\LdapToolsBundle\LdapToolsBundle(),
        );

        // ...
    }
}

# It will prompt for some basic questions (LDAP server, username/password to use, etc)
php bin/console ldaptools:generate:config


class DefaultController extends Controller
{
    public function indexAction()
    {
        $ldap = $this->get('ldap_tools.ldap_manager');
        
        $users = $ldap->buildLdapQuery()->fromUsers()->getLdapQuery()->getResult();
        
        $users->count();
        foreach ($users as $user) {
            $user->getFirstName();
            $user->getLastName();
            $user->getUsername();
        }
        
        # ...
    }
}

# Just supply your LDAP server name...
php bin/console ldaptools:generate:sslcert --server "servername"