Hey guys i am trying to run the following script:
The output i get is the following:Code:#!/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="injjdowns.com" 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.0.5.30" BASEDN="dc=injjdowns,dc=com" BINDDN="CN=Dani Cela,CN=Users,DC=injjdowns,DC=com" BINDPW="SECRET" FILTER="(&(sAMAccountName=*)(objectClass=user)(givenName=*))" 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 -l $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
What i cant figure out is why it is finding no users?Code:zimbra@JJDZCS01:~$ /opt/zimbra/zsync_ad.sh Quering ADS... Found 0 users (/tmp/users_ads_800087391.lst) Quering ZCS... ^CFound 0 users (/tmp/users_zcs_800087391.lst) Generating diff file (/tmp/users_dif_800087391.lst) New users: 0 Old users: 0
If i run the following script separately
The output i get is all of my usersCode:ldapsearch -x -H ldap://10.0.5.30 -b "dc=injjdowns,dc=com" -D "CN=Dani Cela,CN=Users,DC=injjdowns,DC=com" -w SECRET "(&(sAMAccountName=*)(objectClass=user)(givenName=*))"
Can anyone assist with this?
Thanks,
Dani C


LinkBack URL
About LinkBacks


