我试图实现这个包:https ://github.com/BorisMorel/LdapBundle
除了侦听器之外,我已经设置并工作了所有东西 - 它只是不会运行并且探查器显示以下内容:
Not Called Listeners
Event name Listener
imag_ldap.security.authentication.pre_bind LdapSecurityListener::onPreBind
kernel.exception ExceptionListener::onKernelException
kernel.exception ProfilerListener::onKernelException
kernel.exception ExceptionListener::onKernelException
kernel.view TemplateListener::onKernelView
这是我的 service.yml:
services:
ldap.listener:
class: Riviera\PlutusBundle\EventListener\LdapSecurityListener
tags:
- {name: kernel.event_listener, event: imag_ldap.security.authentication.pre_bind, method:onPreBind}
这是我的听众:
<?php
namespace Riviera\PlutusBundle\EventListener;
//use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use IMAG\LdapBundle\Event\LdapUserEvent;
/**
* Performs logic before the user is found to LDAP
*/
class LdapSecurityListener
{
/**
* Modifies the User before binding data from LDAP
*
* @param \IMAG\LdapBundle\Event\LdapUserEvent $event
*/
public function onPreBind(LdapUserEvent $event)
{
$user = $event->getUser();
$config = $this->appContext->getConfig();
throw new \Exception(sprintf('Username: %s', $user->getUsername()));
}
}
我已经尝试了几个小时,并且一直在调试捆绑代码,并且可以 100% 说它连接到 LDAP 并且在以下情况下失败:
//IMAG\LdapBundle\Provider\LdapAuthenticationProvider.php
try {
$this->dispatcher->dispatch(LdapEvents::PRE_BIND, $userEvent);
} catch (\Exception $expt) {
if ($this->hideUserNotFoundExceptions) {
throw new BadCredentialsException('Bad credentials', 0, $expt);
}
throw $expt;
}
有什么想法/想法吗?
编辑
根据下面的评论,没有调用监听器,我认为 ldap 功能依赖于调用监听器。
如果我die()
在此之前放置一个语句,try{}catch{}
我可以在浏览器中看到它,但是如果我将它放在 die 语句之后永远不会触发,这意味着它会抛出错误的凭据异常。