Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
 
Go Back   Zimbra - Forums > Zimbra Collaboration Suite > Administrators

Welcome to the Zimbra - Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 07-04-2009, 01:26 AM
Elite Member
 
Posts: 469
Default Improved version

This version deals gracefully with situations where Calendar or Meeting Notifications folder have already been mounted by assistant.

Code:
# ! /bin/sh
#
# Script to perform Calendar delegation between accounts
# Author: Elliot Wilen
#
# Usage ./zmdelegate source_account delegate_account
#
#
# Name of notifications folder
notifications="Meeting Notifications"
# Name of filter used on boss's account
filtername="Meeting Notifications"
# variable to look at response to interactive prompt
response=
# Note: could do all checking and then output list of all problems
# instead of exiting after first detected problem
#
# Verify exactly two arguments
# (Could use shell Shift command to allow multiple delegation)
if test $# -ne 2
then
echo "Must supply exactly two arguments."
exit 1
fi
# Assign variables
boss_account=$1
assistant_account=$2
# Verify <boss_account> and <assistant_account> exist on the server
if ! zmmailbox -z -m $boss_account gms 1>/dev/null 2>/dev/null
then
echo "Boss account doesn't exist. Exiting."
exit 1
fi
if ! zmmailbox -z -m $assistant_account gms 1>/dev/null 2>/dev/null
then
echo "Assistant account doesn't exist. Exiting."
exit 1
fi
# Check if Meeting Notifications folder already exists; if it does, then post warning and ask if want to continue.
# Otherwise Create Meeting Notifications folder
if zmmailbox -z -m $boss_account gf "$notifications" 1>/dev/null 2>/dev/null
then
        while [ "$response" != "y"  -a "$response" != "n" ]
                do
                        echo -e 'Folder "\c'
                        echo -e "$notifications\c"
                        echo -e '" already exists, use it to store/share notification messages? (y/n) \c'
                        read response
        done
        if [ "$response" = n ]
        then
                echo "Command cancelled."
                exit 1
        fi
else
        echo -e 'Creating folder "\c'
        echo -e "$notifications\c"
        echo -e '".'
        zmmailbox -z -m $boss_account cf -V message "/$notifications" 1>/dev/null 2>/dev/null
fi

# Share Meeting Notifications folder and Calendar to assistant with Manager rights.
echo "Sharing Meeting Notifications folder."
zmmailbox -z -m $boss_account mfg "/$notifications" account $assistant_account rwidx
echo "Sharing Calendar."
zmmailbox -z -m $boss_account mfg "/Calendar" account $assistant_account rwidx

# I have to use account names in names of mountpoints because I don't see
# a way to discover display names via CLI. Could prompt for  user-defined sharepoint
# names.

# Check if Meeting Notifications is already mounted. (Edge case: it could be mounted but in the Trash.)
if zmmailbox -z -m $assistant_account gaf | grep \($boss_account\:`zmmailbox -z -m $boss_account gaf | awk '/\/Meeting\ Notifications$/ {print $1}'`\) 1>/dev/null
then
        echo "Meeting Notifications is already mounted in assistant account...proceeding..."
else
# Check for name conflict.
        if zmmailbox -z -m $assistant_account gf "/$boss_account $notifications" 1>/dev/null 2>/dev/null
        then
                echo -e 'Naming conflict--delete or rename folder "\c'
                echo -e "$boss_account $notifications\c"
                echo -e '" on assistant account.'
                exit 1
        else
# Accept mail folder share by assistant (only for web interface; Outlook must be done at the workstation)
                echo "Mounting Meeting Notifications folder on assistant account. Right-click in Zimbra Web Client to change name."
                zmmailbox -z -m $assistant_account cm -F# "/$boss_account $notifications" $boss_account "/$notifications" 1>/dev/null
        fi
fi
# Check if Calendar is already mounted.
if zmmailbox -z -m $assistant_account gaf | grep \($boss_account\:`zmmailbox -z -m $boss_account gaf | awk '/\/Calendar$/ {print $1}'`\) 1>/dev/null
then
        echo "Calendar is already mounted in boss account...proceeding..."
else
# Check for name conflict.
        if zmmailbox -z -m $assistant_account gf "/$boss_account Calendar" 1>/dev/null 2>/dev/null
        then
                echo -e 'Naming conflict--delete or rename calendar "\c'
                echo -e "$boss_account Calendar\c"
                echo -e '" on assistant account.'
                exit 1
        else
# Accept Calendar share by assistant (only for web interface; Outlook must be done at the workstation)
                echo "Mounting Calendar folder on assistant account. Right-click in Zimbra Web Client to change name."
                zmmailbox -z -m $assistant_account cm -F# "/$boss_account Calendar" $boss_account "/Calendar" 1>/dev/null
        fi
fi
echo "(In Outlook, use File>Open>Other User's Mailbox to access.)"

# Verify that filter rule with same name doesn't already exist
if zmmailbox -z -m $boss_account gfrl | grep ^\"Meeting\ Notifications\" 1>/dev/null
then
echo -e 'Naming conflict--delete or rename filter "\c'
echo -e "$filtername\c"
echo -e '" on boss account.'
exit 1
fi
# Create filter to file meeting messages into folder
echo "Creating filter in boss account."
zmmailbox -z -m $boss_account afrl -f "$filtername" body contains "Content-Type: text/calendar" body contains "method=" body contains "METHOD:" body contains "BEGIN:VEVENT" body contains "BEGIN:VCALENDAR" fileinto "/$notifications" stop
echo "Delegation complete!"
__________________
Elliot Wilen
Berkeley, CA

Last edited by ewilen : 07-04-2009 at 01:40 AM.
Reply With Quote
  #12 (permalink)  
Old 07-08-2009, 04:27 AM
Elite Member
 
Posts: 469
Default

Ah, turns out that you can extract personal names using zmprov. I can post the code if anyone wants it, but the real reason I'm posting is because this bugfix may impact the workaround: Bug 30217 - Need to prevent outlook from sending mail on behalf of another person within the organization. See comment #14.
__________________
Elliot Wilen
Berkeley, CA
Reply With Quote
  #13 (permalink)  
Old 07-12-2009, 10:24 AM
Elite Member
 
Posts: 469
Default

Test of behavior after upgrading to ZCS 5.0.18 NE suggests that things are still working. See comments I added to bug #30217.
__________________
Elliot Wilen
Berkeley, CA
Reply With Quote
  #14 (permalink)  
Old 07-13-2009, 06:39 PM
Elite Member
 
Posts: 469
Default

Okay, I better understand how bug #30217 works now. The upshot is that ZWC users aren't affected by the fix, but Outlook users are.

I don't have time at the moment to revise the script. So after running it, you must go into the admin GUI and add the boss's email address under Accounts>assistant_account>Edit>Preferences>Sendin g mail>Allow sending mail only from these.
__________________
Elliot Wilen
Berkeley, CA

Last edited by ewilen : 07-13-2009 at 06:50 PM.
Reply With Quote
  #15 (permalink)  
Old 09-16-2009, 03:15 PM
Elite Member
 
Posts: 469
Default

Above step may not be necessary if you are running ZCO 5.0.18_GA_3064_5.0.3066 or later. See Bug 40031 - Back out prevention of "Send on Behalf Of" without server pref
__________________
Elliot Wilen
Berkeley, CA
Reply With Quote
  #16 (permalink)  
Old 11-02-2009, 05:29 PM
Zimbra Employee
 
Posts: 16
Default

Quote:
Originally Posted by ewilen View Post
Okay, based on some reading of the RFCs, I think this will capture any meeting-related message from any source (even Google Calendar), with a fairly low chance of capturing anything else.

Code:
If ALL of the following conditions are met:

Body contains Content-Type: text/calendar
Body contains method=
Body contains METHOD:
Body contains VEVENT
Body contains VCALENDAR

Perform the following actions:

File into Folder <folder_name>
I'll test in the morning with the "assistant" using various clients.



In 6.0.x, bug 18104 has been implemented, so these filter rules will not work (see bug 42304). Additionally, bug 19898 has been implemented in 6.0.2+.

To continue filtering invitations, users need to convert existing filter rules to the new bug 19898 format.
Reply With Quote
  #17 (permalink)  
Old 11-02-2009, 10:48 PM
Elite Member
 
Posts: 469
Default

Thanks for the heads-up. I don't think this will be a problem since GnR directly implements enhancements for this scenario (right?). That is: Bug 23336 - Admin should get email on meeting requests sent to boss and Bug 36481 - Support delegate accept/decline in Outlook/ZCO.

But if I read correctly, the workaround in [SOLVED] Dealing with meeting confirmations isn't going to work anymore in 6.0 since 19898 only provides a filter for invites. I'll need a filter for invitation acceptance/decline messages. Should I file an RFE?
__________________
Elliot Wilen
Berkeley, CA
Reply With Quote
Reply


Thread Tools
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

Zimbrablog.com




 

Search Engine Optimization by vBSEO 3.1.0