Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. namespace AppBundle\Manager;
  5.  
  6.  
  7. use Symfony\Component\Config\Definition\Exception\Exception;
  8.  
  9. class Ldap
  10. {
  11. protected $link;
  12.  
  13. public function connect()
  14. {
  15. $host = $this->container->getParameter('ldap_host');
  16. $port = $this->container->getParameter('ldap_port');
  17. $this->link = @ldap_connect($host, $port );
  18. if (!$this->link)
  19. {
  20. throw $this->createNotFoundException('Le serveur ldap ne repond pas');
  21. }
  22. }
  23.  
  24. public function bind()
  25. {
  26. $username = $this->container->getParameter('ldap_rdn');
  27. $password = $this->container->getParameter('ldap_pass');
  28. if (@ldap_bind($this->link, $username, $password))
  29. {
  30. return $this;
  31. } else {
  32. throw $this->createNotFoundException('Authentification Ldap failed');
  33. }
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement