Zend framework2 0x7002:ZF2中未加载LDAP扩展

Zend framework2 0x7002:ZF2中未加载LDAP扩展,zend-framework2,ldap,Zend Framework2,Ldap,运行此操作后,以下错误将显示“0x7002:LDAP扩展未加载” /var/www/coasting/vendor/zendframework/zendframework/library/Zend/Authentication/Adapter/Ldap.php(140):Zend\Ldap\Ldap-> /var/www/coasting/vendor/zendframework/zendframework/library/Zend/Authentication/Adapter/Ldap.php

运行此操作后,以下错误将显示“0x7002:LDAP扩展未加载”

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

/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()


如何解决此错误。如果有其他设置

安装PHP LDAP扩展

您的PHP安装似乎缺少LDAP扩展。看看您的Phpinfo,您会注意到没有可用的“ldap”部分。因此,LDAP连接的基本功能缺失。因此出现了错误


如何安装扩展取决于使用的系统。它可能类似于Mac上的“brew php ldap”或debian或ubuntu linux上的“apt get install php5 ldap”。看看你最喜欢的网络搜索引擎,找到更多的信息

如果它解决了您的问题,请随意将其标记为正确答案。
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);
    }

}