Results 1 to 7 of 7

Thread: Automatic Address Book Copying

  1. #1
    Join Date
    Mar 2011
    Posts
    17
    Rep Power
    4

    Default Automatic Address Book Copying

    We used a shared address book for company wide contacts. However, this doesn't show up through the Exchange protocol on mobile phones. As a workaround, I'm trying to find a way to automatically create local copies in each users account on a regular basis with a bash script. Here's what I'm thinking:

    - Download the address book with curl or wget
    - Get a list of all users in our staff group
    - Upload a copy to each users account with curl.

    I'm stuck at the first step . . . I cannot get wget or curl to download the address book, I keep getting an authentication error. Here's what I'm trying to use:

    wget https://person:password@zimbra.ourdo...erson/Contacts

    What am I doing wrong? Is there another (better) way to do this?

    Thanks

  2. #2
    Join Date
    Apr 2009
    Posts
    304
    Rep Power
    6

    Default

    Maybe you can use CardDAV?

  3. #3
    Join Date
    Mar 2011
    Posts
    17
    Rep Power
    4

    Default

    Thanks for the suggestion. Whatever solution I use, I need to be able to do it automatically from the server side. Do you know of a CLI tool for exporting a carddav calendar? I'm not coming up with much through googling.

  4. #4
    Join Date
    Apr 2009
    Posts
    304
    Rep Power
    6

    Default

    I'm not sure what you're asking. Whatever is on our users account, it's available through imap, CalDAV, CardDAV on a iPhone. All users do have to accept the shares once with the Web GUi. That's how we do it anyway.

  5. #5
    Join Date
    Mar 2011
    Posts
    17
    Rep Power
    4

    Default

    Using the Exchange protocol, Zimbra's shared folders don't show up. We need to use Exchange, since we need to enforce a PIN policy for our accounts on Android and iOS.

  6. #6
    Join Date
    Mar 2011
    Posts
    17
    Rep Power
    4

    Default

    Can anyone help me figure out how to download an address book with curl or wget? Thanks

  7. #7
    Join Date
    Mar 2011
    Posts
    17
    Rep Power
    4

    Default

    My authentication problem turned out to be related to the fact that we use Active Directory auth for our Zimbra server. Setting a password for a local resource will not work, so I had a create a new user through AD to use. It's now working, in case anyone else needs to do the same thing, here's my bash script:

    Code:
    #!/bin/bash
    tmpdir="./tmp"
    tmpfile="export.csv"
    #Verbose mode: 0 for off, 1 for debugging output, and 2 for debugging without modifying user accounts
    verb=0
    
    #Check for right number of arguments:
    if [ $# -ne 4 ]; then
            echo "copy_contact.sh <sourceaddress@myserver.com> <sourceaddress password> <list_name> <distribution_list@myserver.com>"
            echo ":: <sourceaddress@myserver.com> is where the address book is being copied from. This comes from the default /Contacts folder"
            echo ":: The Zimbra password for <sourceaddress@myserver.com> account"
            echo ":: list_name is the name of the folder the address book will be copied to (e.g. \"Staff Address Book\")"
            echo ":: distribution_list@myserver.com is the list of people that will receive the address book (e.g. staff@myserver.com)"
            echo ""
    
    else
            source_address="$1"
            source_name=$(echo $source_address|sed 's/@.*//')
            source_pw="$2"
            list_name="$3"
            dist_list="$4"
            if [ $verb -ge 2 ]; then echo "WARNING: Running in debug mode (verb=2), no changes will be made to accounts"; fi
    
            if [ ! -d "$tmpdir" ]; then
                    mkdir "$tmpdir"
                    if [ $verb -ge 1 ]; then echo "Temp dir $tmpdir created"; fi
            fi
            #Download latest address book to tmp directory:
            if [ $verb -ge 1 ]; then
                    curl -o "$tmpdir/$tmpfile" -u "$source_address:$source_pw" "http://zimbra.myserver.com/zimbra/home/$source_name/Contacts"
            else
                  #Run curl in silent mode with -s flag:  
                  curl -s -o "$tmpdir/$tmpfile" -u "$source_address:$source_pw" "http://zimbra.myserver.com/zimbra/home/$source_name/Contacts"
            fi
    
            #From distribution list, get list of users:
            USERS=`zmsoap --type admin --zadmin GetDistributionListRequest/dl="$dist_list" @by="name"|grep '<dlm>'|sed 's/<[^>]*>//g'`
            #Upload csv to all users in list:
            for USER in $USERS; do
                    if [ $verb -lt 2 ]; then
                            #Create address book folder (in case it doesn't already exist):
                            zmmailbox -z -m "$USER"  cf -V contact -c green "/$list_name"
                            #Empty folder:
                            zmmailbox -z -m "$USER" ef "/$list_name"
                            #Upload csv file to folder:
                            zmmailbox -z -m "$USER" pru "/$list_name" "$tmpdir/$tmpfile"
                    fi
                    if [ $verb -ge 1 ]; then
                            echo "--------"
                            echo "Address book $list_name created/replaced for $USER"
                    fi
            done
    fi

Similar Threads

  1. Gobal Address List and Personnal Address Book
    By selliott in forum Administrators
    Replies: 3
    Last Post: 05-03-2010, 09:27 AM
  2. Replies: 2
    Last Post: 02-02-2010, 11:13 AM
  3. Replies: 0
    Last Post: 01-08-2010, 08:57 AM
  4. Automatic address completion algorithm ?
    By PhilB in forum Administrators
    Replies: 0
    Last Post: 09-01-2009, 09:07 AM
  5. Replies: 1
    Last Post: 02-02-2009, 10:09 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
  •