我正在尝试设置 ZfcUser 以通过回退到 LDAP 进行身份验证。我的 zfcuser.global.php 包含:
'auth_adapters' => array(
100 => 'ZfcUser\Authentication\Adapter\Db',
99 => 'ZfcUser\Authentication\Adapter\Ldap',
),
我使用以下设置创建了一个 Ldap.php 作为 AbstractAdapter。为简洁起见,我删除了功能代码:
namespace ZfcUser\Authentication\Adapter;
use DateTime;
use Zend\Authentication\Result as AuthenticationResult;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use Zend\ServiceManager\ServiceManager;
use Zend\Session\Container as SessionContainer;
use ZfcUser\Authentication\Adapter\AdapterChainEvent as AuthEvent;
use ZfcUser\Mapper\User as UserMapperInterface;
use ZfcUser\Options\AuthenticationOptionsInterface;
class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface
{
protected $mapper;
protected $serviceManager;
protected $options;
public function authenticate(AuthEvent $e)
{
...
}
public function getMapper()
{
...
}
public function setMapper(UserMapperInterface $mapper)
{
...
}
public function getServiceManager()
{
return $this->serviceManager;
}
public function setServiceManager(ServiceManager $serviceManager)
{
$this->serviceManager = $serviceManager;
}
public function setOptions(AuthenticationOptionsInterface $options)
{
$this->options = $options;
}
public function getOptions()
{
...
}
}
我还将它作为可调用的模块包含在 Module.php 文件中:
public function getServiceConfig()
{
return array(
'invokables' => array(
'ZfcUser\Authentication\Adapter\Db' => 'ZfcUser\Authentication\Adapter\Db',
'ZfcUser\Authentication\Adapter\Ldap' => 'ZfcUser\Authentication\Adapter\Ldap',
...
),
...
}
如果我翻转优先级值,它会改变谁可以登录。首先执行的适配器允许登录,但另一个适配器永远不会被使用。如果第一个适配器失败,任何人都知道如何让 ZfcUser 回退到下一个适配器?