shijinmon Pallikal
shijinmon Pallikal

Reputation: 994

0x7002: LDAP extension not loaded in ZF2

This is my Action

public function loginAction()
{
    $request= $this->getRequest();
    if($request->isPost())
    {
        $username= $request->getPost('email');
        $password= $request->getPost('password');

        $auth = new AuthenticationService();
        $adapter = new AuthAdapter(
            array('server1'=>array(
                'host' => '192.168.1.4',
                'useStartTls' => false,
                'useSsl' => false,
                'accountDomainName' => 'coasting',
                'accountDomainNameShort' => 'DOMAIN',
                'accountCanonicalForm' => 3,
                'accountFilterFormat' => '(&(objectClass=user)(sAMAccountName=%s))',
                'baseDn' => 'CN=Users,DC=domain,DC=local',
                'bindRequiresDn' => false,
                'optReferrals' => false
            )), 
            $username, 
            $password
        );
        $result = $auth->authenticate($adapter);

        print_r($result);
    }

}

after running this action following error will showing '0x7002: LDAP extension not loaded',

/var/www/coasting/vendor/zendframework/zendframework/library/Zend/Authentication/Adapter/Ldap.php(140): Zend\Ldap\Ldap->__construct()

/var/www/coasting/vendor/zendframework/zendframework/library/Zend/Authentication/Adapter/Ldap.php(205): Zend\Authentication\Adapter\Ldap->getLdap()

/var/www/coasting/vendor/zendframework/zendframework/library/Zend/Authentication/AuthenticationService.php(110): Zend\Authentication\Adapter\Ldap->authenticate()

How can i solve this error. If any other settings?

Upvotes: 5

Views: 3803

Answers (1)

heiglandreas
heiglandreas

Reputation: 3861

Install the PHP LDAP extension.

It seems that your PHP installation is missing te LDAP extension. Have a look at your Phpinfo and you will notice that there is no "ldap" section available. Therefore the basic functions for LDAP connections are missing. Hence the error.

How to install the extension depends on the used system. It might be something like "brew php-ldap" on Mac or "apt-get install php5-ldap" on a debian or ubuntu linux. Have a look at your favourite search engine on the web to find more information on that.

Upvotes: 5

Related Questions