This question about Missing functionality: Asked
It would be nice if the email of a user could come from the user topic with LdapUserMapping
We have an Active Directory running, but without email addresses stored in it.
I've set up Foswiki with SSO via Apache Login.
I would like now the LdapUserMapping to take the email addresses from the User topics as they are not available in LDAP.
Currently I work-arounded by creating an own UserMappingManager.
To clarify what I suggest, here is my custom code in /var/lib/foswiki/lib/Foswiki/Users/LdapWithEmailsFromTopicUserMapping.pm, but be aware that this is a quick hack and maybe not an optimal implementation:
package Foswiki::Users::LdapWithEmailsFromTopicUserMapping;
use strict;
use Foswiki::Users::LdapUserMapping;
our @ISA = qw( Foswiki::Users::LdapUserMapping );
sub new {
my ($class, $session) = @_;
my $this = bless($class->SUPER::new( $session ), $class);
return $this;
}
sub getEmails {
my ($this, $user, $emails) = @_;
$emails ||= {};
return values %$emails if $emails->{$user};
if ($this->isGroup($user)) {
my $it = $this->eachGroupMember($user);
while ($it->hasNext()) {
$this->getEmails($it->next(), $emails);
}
} else {
foreach ( Foswiki::Users::TopicUserMapping::mapper_getEmails( $this->{session}, $user ) ) {
$$emails{$user} = $_;
}
return values %$emails if $emails->{$user} and (index($emails->{$user}, '%LDAP{') == -1);
# get emails from the password manager
my $login = $this->getLoginName($user);
if ($login) {
foreach ($this->{passwords}->getEmails($login, $emails)) {
$$emails{$user} = $_;
}
}
}
return values %$emails;
}
1;
--
BjoernKautler - 10 Apr 2012
I changed the code I posted to include a return line if something was found in the
TopicUserMapping, so that topic email addresses have precedence over ldapp addresses.
--
BjoernKautler - 19 Apr 2012
Another change to make it possible to use the
LdapNgPlugins %LDAP macro in the topics Mail field and not get an error message on mail sending.
--
BjoernKautler - 27 May 2012