Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AutenticacaoController extends Zend_Controller_Action {
- public function init() {
- }
- public function indexAction() {
- $form = new Application_Form_Login();
- if ($this->getRequest()->isPost()) {
- $data = $this->getRequest()->getPost();
- if ($form->isValid($data)) {
- $mm_login = $form->getValue('mm_login');
- $sha512_senha = hash('sha512', $form->getValue('sha512_senha'));
- $auth = Zend_Auth::getInstance();
- $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', 'production');
- $options = $config->ldap->toArray();
- $authAdapter = new Zend_Auth_Adapter_Ldap($options, $mm_login, $sha512_senha);
- $result = $auth->authenticate($authAdapter);
- if ($result->isValid()) {
- $usuario = $authAdapter->getResultRowObject();
- $auth->getStorage()->write($usuario);
- $session = new Zend_Session_Namespace();
- $this->_redirect($session->uri);
- } else {
- $form->getElement('error')->setLabel('Login / Senha Incorretos');
- $this->view->formulario = $form->populate($data);
- }
- }
- }
- $this->view->formulario = $form;
- }
- public function loginAction() {
- $options = array(
- 'host' => 'dc1.dominio.com',
- 'port' => '389',
- 'useStartTls' => true,
- 'username' => 'cleston@dominio.com',
- 'password' => 'santos',
- 'accountDomainName' => 'dominio.com',
- 'accountDomainNameShort' => 'DOMINIO',
- 'accountCanonicalForm' => 4,
- 'baseDn' => 'DC=dominio,DC=com',
- 'bindRequiresDn' => false
- );
- $ldap = new Zend_Ldap($options);
- $acctname = $ldap->getCanonicalAccountName('robson', Zend_Ldap::ACCTNAME_FORM_DN);
- echo "$acctname\n";
- }
- /*
- * ACCTNAME_FORM_DN 1 CN=Alice Baker,CN=Users,DC=example,DC=com
- * ACCTNAME_FORM_USERNAME 2 abaker
- * ACCTNAME_FORM_BACKSLASH 3 EXAMPLE\abaker
- * ACCTNAME_FORM_PRINCIPAL 4 abaker@example.com
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement