Nathaniel Price wrote:
> 
> Anyway, here's the extension I came up with (saved in app/controllers/
> components/ldap_auth.php):
> <?php
> App::import('Component', 'Auth');
> 
> class LdapAuthComponent extends AuthComponent {
>       var $ldapModel = 'LdapUser';
> 
>       function startup(&$controller) {
>               if (isset($controller->data[$this->userModel])) {
>                       $username = $controller->data[$this->userModel][$this-
>>fields['username']];
>                       $password = $controller->data[$this->userModel][$this-
>>fields['password']];
>                       $res = $this->preauthUser($username, $password);
> 
>                       if (!$res) {
>                               //set password to blank to ensure the auth fails
>                               
> $controller->data[$this->userModel][$this->fields['password']] =
> '';
>                       }
>               }
>               //Continue with standard auth process
>               return parent::startup($controller);
>       }
> ..
> ..
> ..
> 

I think you're going to auth against LDAP and update your database on every
page load by doing it this way.  Maybe that's the way you want to do it, but
another thing you could do is just add another condition to the if statement
in the startup method:

if ($controller->action == 'login' &&
isset($controller->data[$this->userModel])) { 

In my application, I'm not going to worry too much about them changing
things on the LDAP server minute to minute, so I use the above if statement.

Thanks so much for volunteering all this code.  It's been very helpful.

-- 
View this message in context: 
http://n2.nabble.com/Extending-built-in-Auth-Component--tp1369764p2342959.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to