Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Easy way to search distribution lists?

  1. #1
    Join Date
    Dec 2007
    Location
    Stockton, CA
    Posts
    164
    Rep Power
    8

    Default Easy way to search distribution lists?

    Hey All,

    Is there an easy way to search distribution lists to see if a user/e-mail address exists in any of them?

    We have a problem where an account doesn't exist any more, but they still reside in a distribution list. Thus, when people send mail to that list, they always get a bounce message for the user who no longer exists. The problem is trying to figure out what list the user exists in!

    Thanks!!

  2. #2
    Join Date
    Jul 2007
    Location
    Baltimore
    Posts
    1,649
    Rep Power
    11

    Default

    easy way? no, but you could accomplish it with a bit of shell scripting. something like

    Code:
    #!/bin/bash
    
    for i in `zmprov gadl`
    do
      zmprov gdlm $i | grep -i username
    done
    this code may need a bit of tweaking I havn't tested it just wrote it off the top of my head to provide you with the logic. Basicly it lists all distribution lists, then lists the memberso f each one grepping for the username you're trying to find. this could take a while if you have a ton of distribution lists.

  3. #3
    Join Date
    Sep 2007
    Location
    Richmond, Ky
    Posts
    281
    Rep Power
    8

    Default

    Anybody come up with a way of doing this. I tried the script listed but it never returns anything to me. I am not a script person in linux so I really can't say for sure what I need to fix. Also for the username, does it need to be in quotes or anything like that?

    dj

  4. #4
    Join Date
    Jul 2007
    Location
    Baltimore
    Posts
    1,649
    Rep Power
    11

    Default

    hrm, it appears that zmprov gdlm isn't working like it should. i just tested it with a few distribution lists that i know have members and it returns nothing, thats why the script isn't working.

    i'm not running 5.0.11 can anyone that is test and see if gdlm works? just do

    Code:
    zmprov gdlm <distributionlist>
    run that as zimbra. probably too late to file a bug for 5.0.12 but oh well.

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

    Default

    You want this:
    Code:
    zmprov gdl list@domain | grep zimbraMailForwardingAddress
    - see comment #1: Bug 21604 &ndash; zmprov gdlm doesn't produce any results
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

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

    Default

    I would also guess that the answer to your likely follow-up question is in comment #2 here: Bug 9032 &ndash; zmprov gdlm returns empty result
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

  7. #7
    Join Date
    Sep 2007
    Location
    Richmond, Ky
    Posts
    281
    Rep Power
    8

    Default

    Quote Originally Posted by phoenix View Post
    You want this:
    Code:
    zmprov gdl list@domain | grep zimbraMailForwardingAddress
    - see comment #1: Bug 21604 &ndash; zmprov gdlm doesn't produce any results
    So I need to run this for every list I have? Kind of defeats the purpose to me. I have over 30 list. I guess I could put every list in the script.

    dj

  8. #8
    Join Date
    Sep 2007
    Location
    Richmond, Ky
    Posts
    281
    Rep Power
    8

    Default

    So I ran this script against one of my mailing list and it returned everyone in it. I can do a search like that from the admin gui. Is there anyway I can give it an email address and it search all of the list and return which list that address is in?

    dj

  9. #9
    Join Date
    Dec 2007
    Location
    Missouri
    Posts
    30
    Rep Power
    8

    Default

    This shell script should do what you're looking for. We have the same problem you do with bounced messages but I never thought to write a script to help with it. This works for me on 5.0.11:

    Code:
    #!/bin/bash
    
    SEARCHSTRING="user@domain.tld"
    
    for list in `zmprov gadl`
    do
      results=`zmprov gdl $list | grep "Address" | cut -d " " -f 2 | grep "$SEARCHSTRING"`
      if [ ! -z $results ]
      then
        echo $list - $results
      fi
    done

  10. #10
    Join Date
    Dec 2007
    Location
    Missouri
    Posts
    30
    Rep Power
    8

    Default

    I took this one step further and wrote a script that actively finds distribution list members who do not have an account. There may be a few situations it doesn't catch correctly, but I just used it to clean up a dozen entries left over from migrating to Zimbra on one of our customers' systems.

    Code:
    #!/bin/bash
    
    # This script finds distribution list members who do not have a local account or alias
    # Matching entries meet the following criteria:
    # 1) Member does not have a local mailbox or alias
    # 2) Member is not a local distribution list
    # 3) Member's domain is local
    
    # Get a list of local accounts and aliases
    localaccounts=`zmprov gaa -v | grep -E '^(# name|zimbraMailAlias)' | cat -s | sed 's/^zimbraMailAlias: //; s/^# name //'`
    
    # Get a list of distribution lists
    distlists=`zmprov gadl`
    
    # Combine the account and distribution lists
    accounts=`echo $localaccounts; echo $distlists`
    
    # Get a list of local domains
    domains=`zmprov gad`
    
    # Find all lists and verify their members
    for list in `zmprov gadl`
    do
      # First get a list of members of this list
      members=`zmprov gdl $list | grep "Address" | cut -d " " -f 2`
    
      # Check each member of this list to be sure they have a local account
      for member in $members
      do
        # Does this member have a local account (or alias)?
        if [ `echo $accounts | grep $member -c` -ne 1 ]
    	then
    	  # Found an entry in this list which doesn't have a matching local account
    	  # Verfiy that the domain of this member is local
          thisDomain=`echo $member | sed 's/.*@//'` 
    	  if [ `echo $domains | grep $thisDomain -c` -eq 1 ]
    	  then
    	    # This domain is local
            echo $member in $list does not have a local zimbra account
    	  fi
    	fi
      done
    done

Similar Threads

  1. Nested distribution lists
    By Britt in forum Administrators
    Replies: 6
    Last Post: 05-10-2013, 05:01 AM
  2. Search Distribution Lists
    By thunder04 in forum Administrators
    Replies: 1
    Last Post: 08-20-2008, 03:06 PM
  3. Replies: 4
    Last Post: 01-29-2008, 08:43 PM
  4. More about distribution lists
    By peng1can in forum Administrators
    Replies: 3
    Last Post: 12-17-2007, 07:33 PM
  5. Distribution Lists
    By swu in forum Administrators
    Replies: 1
    Last Post: 07-12-2007, 08:08 PM

Posting Permissions

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