LdapAuthComponent.php 514 Bytes
<?php
namespace App\Controller\Component;

use Cake\Controller\Component\AuthComponent;
use Cake\Core\Exception\Exception;
use Cake\ORM\TableRegistry;

class LdapAuthComponent extends AuthComponent {

	public function connection() {
		try {
			$login = $this->request->getData('ldap');
			$password = $this->request->getData('password'); 
			$resp = TableRegistry::get('LdapConnections')->ldapAuthentication($login, $password);
			return $resp;
		}
		catch(Exception $e) {
			return $e->getMessage();
		}
	}
	
}
?>