Configurable Matomo plugin to create an LDAP connection, which can be reused by other plugins. It uses the ZF2 Ldap component: http://framework.zend.com/manual/2.3/en/index.html#zend-ldap

Currently used by https://github.com/plesk/Piwik-LdapVisitorInfo

What does this plugin do?

It creates based on your configuration a connection to LDAP. Not more and not less :-)

How can i use this LDAP connection in another plugin?

This is an example to retrieve the connection. For documentation please see http://framework.zend.com/manual/2.3/en/index.html#zend-ldap

namespace Matomo (Piwik)\Plugins\YourPlugin;

use Matomo\Plugin;
use Matomo\Plugins\LdapConnectionPlesk\API as APILdapConnectionPlesk;
use Zend\Ldap\Ldap;

class YourPlugin extends Plugin
{
    private function doSomething()
    {
        /* @var $ldap \Zend\Ldap\Ldap */
        $ldap = APILdapConnectionPlesk::getInstance()->getConnection();
        $ldap->connect();

        $filter = sprintf('(&(objectclass=user)(samAccountName=%s))', $visitorUsername);
        $collection = $ldap->search($filter, null, Ldap::SEARCH_SCOPE_SUB, ['displayname']);

        if ($collection->count() >= 1) {
            $result = $collection->getFirst();
            //do something with the result...
        }
    }
}
Free Download for Matomo On-Premise This plugin is not available for Matomo for WordPress

Please share