1 package FS::part_export::cyrus;
6 @ISA = qw(FS::part_export);
11 my($self, $svc_acct) = (shift, shift);
12 $self->cyrus_queue( $svc_acct->svcnum, 'insert',
13 $svc_acct->username, $svc_acct->quota );
17 my( $self, $new, $old ) = (shift, shift, shift);
18 return "can't change username using Cyrus"
19 if $old->username ne $new->username;
21 # #return '' unless $old->_password ne $new->_password;
22 # $self->cyrus_queue( $new->svcnum,
23 # 'replace', $new->username, $new->_password );
27 my( $self, $svc_acct ) = (shift, shift);
28 $self->cyrus_queue( $svc_acct->svcnum, 'delete',
29 $svc_acct->username );
32 #a good idea to queue anything that could fail or take any time
34 my( $self, $svcnum, $method ) = (shift, shift, shift);
35 my $queue = new FS::queue {
37 'job' => "FS::part_export::cyrus::cyrus_$method",
40 $self->option('server'),
41 $self->option('username'),
42 $self->option('password'),
47 sub cyrus_insert { #subroutine, not method
48 my $client = cyrus_connect(shift, shift, shift);
49 my( $username, $quota ) = @_;
50 my $rc = $client->create("user.$username");
51 my $error = $client->error;
52 die "creating user.$username: $error" if $error;
54 $rc = $client->setacl("user.$username", $username => 'all' );
55 $error = $client->error;
56 die "setacl user.$username: $error" if $error;
59 $rc = $client->setquota("user.$username", 'STORAGE' => $quota );
60 $error = $client->error;
61 die "setquota user.$username: $error" if $error;
66 sub cyrus_delete { #subroutine, not method
67 my ( $server, $admin_username, $password_username, $username ) = @_;
68 my $client = cyrus_connect($server, $admin_username, $password_username);
70 my $rc = $client->setacl("user.$username", $admin_username => 'all' );
71 my $error = $client->error;
74 $rc = $client->delete("user.$username");
75 $error = $client->error;
81 my( $server, $admin_username, $admin_password ) = @_;
83 eval "use Cyrus::IMAP::Admin;";
85 my $client = Cyrus::IMAP::Admin->new($server);
86 $client->authenticate(
87 -user => $admin_username,
88 -mechanism => "login",
89 -password => $admin_password,
95 #sub cyrus_replace { #subroutine, not method