Skip to Content.
Sympa Menu

en - [sympa-users] Re: Re: [Internet] automatic list creation, further integration with LDAP for list settings

Subject: The mailing list for listmasters using Sympa

List archive

Chronological Thread  
  • From: Thomas Berry <address@concealed>
  • To: address@concealed
  • Subject: [sympa-users] Re: Re: [Internet] automatic list creation, further integration with LDAP for list settings
  • Date: Fri, 30 Mar 2007 14:00:45 -0700

--correction--

Don't forget to include [% USE Alf %] in the config.tt2 before calling
[% listname FILTER $Alf %].


For example:

# load filter
[% USE Alf %]

subject [% listname %]

# some parameters come from our filter :
[% listname FILTER $Alf %]


Thomas

Sylvain Amrani wrote:
Hi,

Actually we do something like that, here.

In fact you need to "teach" TT2 to use your LDAP directory.

The easy way to do it, is to define your own TT2 FILTER. It's quite easy
(really, it is). Usually filters do basic things like UPPERCASE. [%
"hello" FILTER upper %] will write "HELLO". We create a new FILTER, that
will take the listname as argument, and returns a complete list config !

Say we want to create a new "Alf" TT2 filter (Alf, for "automatic list
feature", e.g.)

Create a new Alf.pm module in your perl @INC, and in the
Template::Plugin scope (for example, on a debian server, I put it in
/etc/perl/Template/Plugin/Alf.pm)

You must define an Alf::filter sub that will be called by the TT2 Process.

Alf.pm :
###############################################
package Template::Plugin::Alf;

use strict;

use Template::Plugin::Filter;
use base qw( Template::Plugin::Filter );

# you can use ldap here
use Net::LDAP;

sub filter {
# you get the listname in the parameter
my ($self, $parameter) = @_;


# do everything perl can do here :
# ldap queries, computation...

# looking for 'send' value in our ldap directory :
my $ldap = Net::LDAP->new('ldap.server.com') or die "$@";
my $mesg = $ldap->bind(...
$mesg = $ldap->search('filter'=>"(&(cn=$parameter)(...))", 'attrs'=>['send'],
'base'=>...

my $entity = $mesg->entries[0];
my $send_parameter = $entity->get_value('send');

# compute the ldap filter and put it in $filter
my $filter = "(&(something very complicated))";

# then, return the result :

my $r = "
send $send_parameter

include_ldap_query
host ldap.server.com
suffix dc=com
user cn=admin
filter $filter
attrs mail
scope sub
select all

";

return $r

# if you want to break the TT2 process for some reason,
# simply die, and the automatic list won't be created

die if ($some_reason);

}
1;
###############################################

Now here is your config.tt2 :

###############################################
subject [% something %]

# some parameters come from our filter :
[% listname FILTER $Alf %]

###############################################

And your list config will be :
###############################################
subject computed_the_traditional_way

send public

include_ldap_query
host ldap.server.com
suffix dc=com
user cn=admin
filter (&(something very complicated))
attrs mail
scope sub
select all

###############################################

That's it ! You can do everything Perl can do in during your automatic
list creation !

Regards,
Sylvain





Thomas Berry a écrit :
Using the automatic list creation, is it possible to store various
list settings in LDAP and have the automatic list creation process
retrieve the values to configure each list in a family?

Let's say for example, "testlist" does not exist as a mailing list.
A new message is sent to "testlist@list". The automatic list creation
process identifies "testlist" as new mailing list and starts the list
creation process.

During that process, the some of the settings for that mailing list
are based on the attribute values in the LDAP entry "testlist". For
example, the LDAP entry "testlist" has an attribute "send" with a value
of "open". The automatic list creation uses the value in "send" and
adds it to the "testlist" mailing list config as "send open".

In short, I need to read some of the mailing list settings from the
same LDAP entry that the list's members are obtained.

Thomas






Archive powered by MHonArc 2.6.19+.

Top of Page