Results 1 to 9 of 9

Thread: [SOLVED] Listing Distribution List Members

  1. #1
    Join Date
    Sep 2005
    Location
    Ocala, FL, USA
    Posts
    29
    Rep Power
    10

    Lightbulb [SOLVED] Listing Distribution List Members

    We have been using the distribution lists feature via the Admin UI for a while now, and we keep finding more and more uses for them. The only problem that we have come across (caused by us) is that we need to periodically audit the members of each distribution list. We do this to make sure that all required users are on each list, and that no one is on a list that they shouldn't be.

    I did not see anything already available that did this so I put together a real basic LDAP query to accomplish this task. I figured that if I needed to do this someone else would also, so here is the basic query to list the members of all distribution lists:

    Code:
    ldapsearch -x -v -H 'ldap://localhost/' -b 'ou=people,dc=mydomain,dc=com' "objectClass=zimbraDistributionList" mail zimbraMailForwardingAddress
    If you only want to list a single distribution list you can run the query as follows:

    Code:
    ldapsearch -x -v -H 'ldap://localhost/' -b 'uid=distributionlistname,ou=people,dc=mydomain,dc=com' "objectClass=zimbraDistributionList" mail zimbraMailForwardingAddress
    These commands need to be run as the zimbra user. Also, make sure you replace these strings:
    mydomain - should be your domain name
    distributionlistname - should be the name of the distribution list you are trying to list

    Hopefully, someone else will get some use out of this.

    RobertJ

  2. #2
    Join Date
    May 2006
    Location
    USA
    Posts
    6,242
    Rep Power
    21

    Default

    Simpler would be to :
    su zimbra
    zmprov gdl list@domain.com

    If you forget the list names:
    zmprov gadl (or zmprov gadl domain.com)

  3. #3
    Join Date
    Jul 2006
    Location
    New York, NY
    Posts
    122
    Rep Power
    9

    Default

    Funny enough I prefer the ldap search query over the zmprov's method since usually the people who ask for such information do not need to know all the information the it provides.

    Code:
    zmprov gadl > /tmp/distlist.tmp
    for list in `cat /tmp/distlist.tmp`; do  
    zmprov gdl $list > /home/zimbra/temp/$list; 
    done
    Which will give you a directory full of text files for each distribution list.

    Which I might now modify with the ldap queries.
    Because we all can't be geniuses, I'll go first.

  4. #4
    Join Date
    Aug 2010
    Posts
    29
    Rep Power
    5

    Default

    Hello,
    glitch23 I have ran your script but getting an error:
    "ambiguous redirect".

    Maybe you know how to solve it?

    Thank You

  5. #5
    phoenix is offline Zimbra Consultant & Moderator
    Join Date
    Sep 2005
    Location
    Vannes, France
    Posts
    23,587
    Rep Power
    58

    Default

    Quote Originally Posted by Mindaugas View Post
    Maybe you know how to solve it?
    How about one of these: site:zimbra.com +"ambiguous redirect" - Yahoo! Search Results

    If that doesn't work an internet search for the error message should find an answer.
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

  6. #6
    Join Date
    Jul 2006
    Location
    New York, NY
    Posts
    122
    Rep Power
    9

    Default

    Quote Originally Posted by Mindaugas View Post
    Hello,
    glitch23 I have ran your script but getting an error:
    "ambiguous redirect".

    Maybe you know how to solve it?

    Thank You
    Make sure you use back ticks(sp?) " ` " versus apostrophes " ' "

    for list in 'cat /tmp/distlist.tmp'; do (This will give you an error)
    ...
    for list in `cat /tmp/distlist.tmp`; do (This will not)
    Because we all can't be geniuses, I'll go first.

  7. #7
    Join Date
    Aug 2010
    Posts
    29
    Rep Power
    5

    Default

    Thank you very much.

  8. #8
    Join Date
    Jul 2008
    Posts
    6
    Rep Power
    7

    Default

    I made this:

    for lista in `zmprov gadl`; do
    echo -e "$lista\n" >> /tmp/listmembers.txt

    for usuario in `zmprov gdl $lista | grep zimbraMailForwardingAddress | cut -d" " -f2`; do
    member=`zmprov ga $usuario | grep displayName | cut -d: -f2`
    echo -e "$usuario $member" >> /tmp/listmembers.txt
    done
    echo -e "----------\n\n" >> /tmp/listmembers.txt
    done

    It creates a file (/tmp/listmembers.txt) in a very readable format.

    Regards
    Antonio Díaz Meneses
    EDITY S. A.
    Guayaquil - Ecuador

  9. #9
    Join Date
    Jun 2013
    Location
    Vietnam
    Posts
    28
    Rep Power
    2

    Default

    Thank for sharing this. Could you please let me know how to import all distribution lists and members to new zimbra server using shell script?

Similar Threads

  1. Adding Members to a distribution list through batch!
    By roberth in forum Administrators
    Replies: 3
    Last Post: 07-16-2008, 09:08 PM
  2. "replay as" distribution list question
    By redbaron in forum Administrators
    Replies: 0
    Last Post: 09-05-2007, 05:18 AM
  3. Reply To for Distribution List
    By alivebyscience in forum Administrators
    Replies: 3
    Last Post: 10-28-2006, 11:35 AM
  4. Orphaned alias for a distribution list
    By area in forum Administrators
    Replies: 0
    Last Post: 09-17-2006, 09:22 PM
  5. Distribution list members seeing
    By lalas in forum Administrators
    Replies: 1
    Last Post: 07-03-2006, 01:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •