shi*_*kal 5 ldap zend-framework2
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);
}
}
Run Code Online (Sandbox Code Playgroud)
运行此操作后,以下错误将显示“0x7002:未加载 LDAP 扩展”,
/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()
我该如何解决这个错误。如果还有其他设置?
安装 PHP LDAP 扩展。
您的 PHP 安装似乎缺少 LDAP 扩展。查看您的 Phpinfo,您会注意到没有可用的“ldap”部分。因此缺少 LDAP 连接的基本功能。因此错误。
如何安装扩展取决于使用的系统。它可能类似于 Mac 上的“brew php-ldap”或 debian 或 ubuntu linux 上的“apt-get install php5-ldap”。在网络上查看您最喜欢的搜索引擎,以找到更多相关信息。