1
我想安裝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回退到下一個適配器?