Results 1 to 2 of 2

Thread: sync AD with Zimbra

  1. #1
    Join Date
    Nov 2011
    Posts
    1
    Rep Power
    3

    Default sync AD with Zimbra

    Hi,

    I've just installed zimbra and configured authentication with an AD running on Windows 2003 Server. It works fine. However, I cannot find a solution to maintain both directories synchronized. I've found a script, which allows zimbra to get all users in AD by means of comparing them with existing users in zimbra-ldap, but when i run that scripts i got some error. Here's my script :

    #!/bin/bash
    # zsync_ad.sh is a script thant syncs AD users and Zimbra users
    # It is unidirectional, just replicates changes from AD to ZCS
    # Developed on 20081006 by Eduardo Gonzalez <egrueda@gmail.com>
    # Testing version 0.6 - Use at your own risk

    LDAPSEARCH=/usr/bin/ldapsearch
    ZMPROV=/opt/zimbra/bin/zmprov
    DOMAIN_NAME="test.csf.co.id"
    TIMESTAMP=`date +%N`
    TMP_DIR=/tmp
    ADS_TMP=$TMP_DIR/users_ads_$TIMESTAMP.lst
    ZCS_TMP=$TMP_DIR/users_zcs_$TIMESTAMP.lst
    DIF_TMP=$TMP_DIR/users_dif_$TIMESTAMP.lst

    # Server values
    LDAP_SERVER="ldap://10.10.1.10:389"
    BASEDN="dc=csf,dc=co,dc=id"
    BINDDN="CN=administrator,DC=csf,DC=co,DC=id"
    BINDPW="secret"
    FILTER="(&(sAMAccountName=*)(objectClass=user)(giv enName=*))"
    FIELDS="mail"

    # Extract users from ADS
    echo -n "Quering ADS... "
    $LDAPSEARCH -x -H $LDAP_SERVER -b $BASEDN -D "$BINDDN" -w $BINDPW "$FILTER" $FIELDS | \
    grep "@$DOMAIN_NAME" | \
    awk '{print $2}' | \
    sort > $ADS_TMP
    echo "Found `cat $ADS_TMP | wc -l` users ($ADS_TMP)"

    # Extract users from ZCS
    echo -n "Quering ZCS... "
    $ZMPROV gaa $DOMAIN_NAME > $ZCS_TMP
    echo "Found `cat $ZCS_TMP | wc -l` users ($ZCS_TMP)"

    # Generate diff
    echo "Generating diff file ($DIF_TMP)"
    diff -u $ZCS_TMP $ADS_TMP | grep "$DOMAIN_NAME" > $DIF_TMP

    # Clean up users list
    rm -f $ADS_TMP $ZCS_TMP

    # Import new users
    echo -n "New users: "
    cat $DIF_TMP | grep ^+ | wc -l
    for i in $(cat $DIF_TMP | grep ^+ | sed s/^+//g);
    do
    echo -n " - Adding $i ";
    $ZMPROV createAccount $i passwd > /dev/null;
    RES=$?
    if [ "$RES" == "0" ]; then echo "[Ok]"; else echo "[Err]"; fi
    done

    # Delete old users
    echo -n "Old users: "
    cat $DIF_TMP | grep ^- | wc -l
    for i in $(cat $DIF_TMP | grep ^- | sed s/^-//g);
    do
    echo -n " - Deleting $i ";
    $ZMPROV deleteAccount $i > /dev/null;
    RES=$?
    if [ "$RES" == "0" ]; then echo "[Ok]"; else echo "[Err]"; fi
    done


    # Clean up diff list
    #rm -f $DIF_TMP


    and here's the errors :
    Quering ADS... /opt/zimbra/zsync_ad.sh: line 26: /usr/bin/ldapsearch: No such file or directory
    Found 0 users (/tmp/users_ads_272682961.lst)
    Quering ZCS... ERROR: service.INVALID_REQUEST (invalid request: can only be used with "zmprov -l/--ldap")
    Found 0 users (/tmp/users_zcs_272682961.lst)
    Generating diff file (/tmp/users_dif_272682961.lst)
    New users: 0
    Old users: 0

    please help me
    Thanks

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

    Default

    Quote Originally Posted by sinchan83 View Post
    and here's the errors :
    Quering ADS... /opt/zimbra/zsync_ad.sh: line 26: /usr/bin/ldapsearch: No such file or directory
    Found 0 users (/tmp/users_ads_272682961.lst)
    Quering ZCS... ERROR: service.INVALID_REQUEST (invalid request: can only be used with "zmprov -l/--ldap")]
    The error messages tell you exactly what's wrong in the script, you need to add the missing package for the first error and modify the command in the script for the second error.
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

Similar Threads

  1. [SOLVED] Help, I think I am running Zimbra as root!
    By primaxx in forum Administrators
    Replies: 9
    Last Post: 10-06-2010, 11:04 AM
  2. Old Backup stay in TO_DELETE status and no clearing..
    By bartounet in forum Administrators
    Replies: 0
    Last Post: 10-05-2010, 07:40 AM
  3. zmtlsctl give LDAP error
    By sourcehound in forum Administrators
    Replies: 5
    Last Post: 03-11-2007, 03:48 PM
  4. Zimbra server crashed
    By goetzi in forum Administrators
    Replies: 6
    Last Post: 03-25-2006, 12:00 PM
  5. Mail logs
    By Rick Baker in forum Installation
    Replies: 8
    Last Post: 01-17-2006, 03:33 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
  •