[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Mailing list query



Pierangelo Masarati wrote:

SA> What I want is somehow to get all uid of the users belonging to each
SA> of my groups in order to build a mailing list with postfix.

PM> In LDAP, the only way to do it is:

PM> - search the group
PM> - take its members
PM> - for each member:
PM> 	- search for the member entry
PM> 	- take its uid

We've implemented approximately this method for systems administered
with GOsa.  It has an auxiliary objectclass called "gosaMailAccount"
which it adds to groups and to users when the GUI enables mail for that
object.

Using Exim, rather than Postfix, you can for example do something like:

gosa_mailgroup_expand:
    driver = redirect
    allow_fail
    allow_defer
    check_ancestor
    address_data = ${lookup ldapm \
      {user=LDAP_USER pass=LDAP_PASS \
      ldap:///LDAP_BASE?memberUid,gosaMailForwardingAddress?sub?\
      (&(objectClass=gosaMailAccount)(objectClass=posixGroup)\
      (|(mail=$local_part@$domain)\
      (gosaMailAlternateAddress=$local_part@$domain)))} \
      }
    # Now get the canonical mail addresses for all the members
    data = ${expand:${lookup ldapm \
      {user=LDAP_USER pass=LDAP_PASS \
      ldap:///LDAP_BASE?mail?sub?\
      (&(objectClass=gosaMailAccount)(objectClass=gosaAccount)\
      (|(uid=${sg{${extract{memberUid}{$address_data}\
      }}{,\\s*}{)(uid=}})))}\
      }},\
      (&(objectClass=gosaMailAccount)\
      (objectClass=gosaAccount)(uid=%l))\}\
      }{,\\s*}{\n}}\
      }},\
      ${extract{gosaMailForwardingAddress}{$address_data}}


ie find a posixGroup whose "mail" or "gosaMailAlternateAddress" matches
the list address, then use memberUid to look up the mail addresses of
members who are local users, and deliver to them plus any external
addresses listed in the group's "gosaMailForwardingAddress".

An equivalent with groupOf(Unique)Names rather than posixGroup might be
simpler because having the user DNs in the group removes the need for
the second-level search.

You may be able to write an MTA config which looks less horrible using
PostFix.  The upshot either way is something simple to administer with
the web GUI.


Cheers


Duncan

-- 
Duncan Gibb, Technical Director
Sirius Corporation plc - The Open Source Experts
http://www.siriusit.co.uk/
Tel: +44 870 608 0063