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

Thread: How can I get a list of all "account alias" ?

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Maringá, Paraná, Brasil
    Posts
    8
    Rep Power
    9

    Default How can I get a list of all "account alias" ?

    Hi,

    I need to list all "valid" accounts on my box. I can get my "distribution lists" using "zmprov gadl" and can get my "account" using "zmprov gaa". But, "zmprov gaa" don't return the "account alias", how can I get a list of the "account alias" ?

  2. #2
    Join Date
    Feb 2006
    Posts
    61
    Rep Power
    9

    Default

    I'd be interested in finding this too :/ did you ever get an answer or does anyone know?

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

    Default

    A search of the forums would have found it for you:

    Code:
    zmprov ga address@domain | grep Alias
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

  4. #4
    Join Date
    Jun 2008
    Posts
    3
    Rep Power
    7

    Default

    Kind of a dead thread, but this seemed like a good place to document a quick hack I put together that retrieves all accounts in a zimbra instance and then lists all of the aliases associated with that account. As the Zimbra user:

    Code:
    for i in `zmprov gaa`; do echo ""; echo "$i:"; zmprov ga $i | grep MailAlias; done > acounts.txt
    "accounts.txt" will then contain the list of accounts in a nice readable format.

    Hope this helps somebody.

  5. #5
    Join Date
    Aug 2008
    Location
    Brisbane, Australia
    Posts
    168
    Rep Power
    7

    Default

    Quote Originally Posted by qhartman View Post
    Kind of a dead thread, but this seemed like a good place to document a quick hack I put together that retrieves all accounts in a zimbra instance and then lists all of the aliases associated with that account. As the Zimbra user:

    Code:
    for i in `zmprov gaa`; do echo ""; echo "$i:"; zmprov ga $i | grep MailAlias; done > acounts.txt
    "accounts.txt" will then contain the list of accounts in a nice readable format.

    Hope this helps somebody.
    Tried to run this but got a permission denied message (yes running as zimbra user).

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

    Default

    i believe by default the zimbra user doesn't have write access to /opt/zimbra, which is probably the diretory yyou're trying to run that in. so it can't create the acounts file. i make a /opt/zimbra/scripts dir for mine and chown it to the zimbra user. run the script from there

  7. #7
    Join Date
    May 2009
    Location
    Boulder CO
    Posts
    16
    Rep Power
    6

    Default

    Here is one more option, building on the same theme. To list just the distribution lists for one domain, and the members of each list:

    for i in `zmprov gadl domain.com`; do echo ""; echo "$i:"; zmprov gdl $i | grep 'Forwarding' | awk '{print $2}'; done > aliases.txt

    The output looks like:

    list1@domain.com:
    user1@domain.com
    user2@domain.com

    list2@domain.com:
    user3@domain.com
    user4@domain.com

  8. #8
    Join Date
    Mar 2007
    Posts
    20
    Rep Power
    8

    Default

    As long as we're adding to this thread -- here are another couple of ways to get a list of accounts and their aliases.

    They should be faster than the previously mentioned program, since they employ a single zmprov command instead of spawing a new program to check each mailbox. The overhead of the latter can be huge on large systems. I created these when I was looking for a command-line way to list the aliases of my distribution lists. That seems to be missing from the zmprov inventory.


    For folks who like basic Unix scripts, here's the first one I wrote:

    Code:
    DOMAIN=mydomain.com
    
    zmprov  sa  -v zimbraMailDeliveryAddress="*@$DOMAIN" \
        | egrep '^(# name |cn:|zimbraMailAlias|$)' \
        | cat -s  \
        | sed 's/^zimbraMailAlias:/     /; s/^# name /Mailbox: /; s/^cn: /Name: /'
    The last two lines (and the trailing backslash at the end of the second line) aren't really necessary; they just pretty up the output a bit.

    The third line (cat -s) will remove extra blank lines; you can get a lot of these if your users have mail filters. This command will work on many systems, but not all. If your system doesn't have "cat -s" you can get the same functionality with a one-line awk or perl script.

    The fourth line (sed) cleans up the labels.

    I actually prefer to do all of this in Perl; it's simpler, more flexible, and probably faster. Here's what I now run:

    Code:
    #
    # aliasList:  Lists all aliases for mailboxes and distribution lists associated with a particular domain
    #
    #   Syntax:  aliasList someMailDomain.com
    #
    #
    # The settings for the LDAP queries are guesses.  They work for me, but if I have overlooked
    # something, please let me know!
    #  --
    # Phil Freed <url-zimbra@freed.com>
    #
    ########
    
    DOMAIN="$1"
    OUTFILE="$DOMAIN.alias"
    
    if [ -z "$DOMAIN" ]; then
      echo
      echo "ERROR!"
      echo "Syntax:  `basename $0`  yourMailDomain.com"
      echo
      exit 2
    fi
    
    
    (
      echo Listing mailbox aliases....  >&2
      echo
      echo "==================== Mailbox Aliases for $DOMAIN ========================"
      echo
    
      zmprov  sa  -v zimbraMailDeliveryAddress="*@$DOMAIN"  | perl -ne \
         '
           if ( s/^# name /\nMailbox: /  or
                s/^cn: /Name: /        or
                s/^zimbraMailAlias:/    / ) { print $_; }
         '
    
      echo Listing distribution list aliases....  >&2
      echo
      echo
      echo "==================== Distribution List Aliases for $DOMAIN ========================"
      echo
    
      zmprov  sa  -v "(&(objectClass=zimbraDistributionList)(mail=*@$DOMAIN))"  | perl -ne \
         '
           if ( s/^# distributionList /\nMailingList: /  or
                s/^cn: /Name: /        or
                s/^zimbraMailAlias:/    / ) { print $_; }
         '
    ) > $OUTFILE
    
    echo
    echo " -- The list of aliases is now stored in '$OUTFILE'"
    echo

  9. #9
    Join Date
    Aug 2008
    Location
    Brisbane, Australia
    Posts
    168
    Rep Power
    7

    Default

    Rather than running a script, is there a command like the zmprov ga user@domain | grep Alias that will list ALL aliases? I need to provide a list but not sure how to create and run the script examples above.

  10. #10
    Join Date
    Mar 2007
    Posts
    20
    Rep Power
    8

    Default

    Quote Originally Posted by sdrury View Post
    Rather than running a script, is there a command like the zmprov ga user@domain | grep Alias that will list ALL aliases? I need to provide a list but not sure how to create and run the script examples above.
    The first script in my previous post will work stand-alone; you can cut and paste it right into your terminal window. Just change the first line (DOMAIN=...) to the domain for which you want to view aliases. The script is really a one-liner, but it's been broken into multiple lines (each with a trailing backslash) to improve readability.


    Code:
    DOMAIN=mydomain.com
    
    zmprov  sa  -v zimbraMailDeliveryAddress="*@$DOMAIN" \
        | egrep '^(# name |cn:|zimbraMailAlias|$)' \
        | cat -s  \
        | sed 's/^zimbraMailAlias:/     /; s/^# name /Mailbox: /; s/^cn: /Name: /'

    If you want all aliases, regardless of domain, you can do it this way (note that DOMAIN is no longer used):

    Code:
    zmprov  sa  -v objectClass="zimbraAccount" \
        | egrep '^(# name |cn:|zimbraMailAlias|$)' \
        | cat -s  \
        | sed 's/^zimbraMailAlias:/     /; s/^# name /Mailbox: /; s/^cn: /Name: /'
    These two scripts will display all mailbox aliases. If you are one of those rare individuals that uses aliases for mailing lists, it won't show them. I can craft a "one-liner" that includes these as well, but I'll have to do it later. (I'm late for a meeting.) At the same time I'll talk a bit about how to set up and run a script. It's awfully handy to be able to do that.

Similar Threads

  1. Reply To for Distribution List
    By alivebyscience in forum Administrators
    Replies: 3
    Last Post: 10-28-2006, 10:35 AM
  2. Orphaned alias for a distribution list
    By area in forum Administrators
    Replies: 0
    Last Post: 09-17-2006, 08:22 PM
  3. Replies: 1
    Last Post: 05-24-2006, 11:22 AM
  4. Distribution list problem
    By achow in forum Users
    Replies: 1
    Last Post: 05-15-2006, 08:45 PM
  5. Reading attachments problem
    By lenjacobs in forum Users
    Replies: 2
    Last Post: 12-27-2005, 10:24 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
  •