Earlier in the year I posted inquiring about how to do an LDAP integration for my users to log in to Manager.
http://modxcms.com/forums/index.php?topic=49996.0
OpenGeek suggested a plugin attached to the events ’OnUserNotFound’ and ’OnManagerAuthentication’, and linked to a sample code snippet that used this method.
https://gist.github.com/421232.
Anyway, I finally got around to doing this last week. Using the code example, I got a plugin to work with our LDAP directory. It looks up users in the directory if the OnUserNotFound event is triggered, and if they are found and their credentials successfully authenticate against LDAP, a new MODx user is created and saved.
As I worked through the process of translating the concepts from the example into something that would meet my specific needs, I ran in to a few concepts that I didn’t fully grasp. I’m hoping someone can clarify these.
1. In the OnUserNotFound case of the switch statement, there is this block of code:
if ($userexists) {
$user = & $scriptProperties['user'];
$user = $modx->newObject('modCrowdUser');
$user->set('username', $username);
$up = $modx->newObject('modUserProfile');
$user->addOne($up);
$modx->event->_output= $user;
$modx->event->stopPropagation();
}
First, I’m not at all sure what that first inner line ($user = & $scriptProperties[’user’];). Is that just something specific to the code example, or is it an essential step? Presumably the [’user’] info is getting passed in from somewhere...
I understand the next few lines, defining a new user object & a new profile.
Then the last two lines... it looks like the $user object is being set as the output of this event, and then the event is being manually stopped? Is that correct?
Is this so that the $user variable can be made available to the next event that uses this plugin (OnManagerAuthenticate)?? I’m not exactly clear on how that hand-off works, from OnUserNotFound to OnManagerAuthenticate.