#!/usr/bin/perl -w
#
# List a user's folders in Cyrus
#

if ($#ARGV < 0) {
	print "Usage: $0 username\n";
	print "  Lists a user's folders in Cyrus\n";
	exit(-1);
}

use IMAP::Admin;

require "/private/admin/acct/email/prefs.pl";
require "/private/admin/acct/email/utils.pl";

my $imap = IMAP::Admin->new('Server' => $prefs{'cyrushost'},
			'Login' => $prefs{'cyrususer'},
			'Password' => $prefs{'cyruspass'},
			);

if (! $imap) {
	print "Error connecting to IMAP server.\n";
	exit;
}

my $username = $ARGV[0];

# Look for matching mailboxes
@mailboxes = $imap->list("user.$username");
push @mailboxes, $imap->list("user.$username.*");

foreach $mailbox (@mailboxes) {
	print "$mailbox\n";
}


$imap->close;

