subscribing for a user

Matt Bernstein mb/cyrus at dcs.qmul.ac.uk
Wed Jul 16 11:33:47 EDT 2003


At 10:59 -0400 Mike Cathey wrote:

>> What I ended up doing was , since I would know the passwd of the user I 
>> logged on as the user using Mail::IMAPCLient module
>> and sucscribed to the folder
>
>Same here.  I think there is a way to "proxy" as a user from an admin
>account (ie. cyrus) though.
>
>Would anyone more informed than myself care to elaborate?

I hacked the IMAP::Admin (nb not Cyrus::IMAP::Admin) module to do this. I
sent my hack to its author, but I don't think it made it in:

--- /usr/lib/perl5/site_perl/5.6.1/IMAP/Admin.pm~       2002-09-13 13:31:45.000000000 +0100
+++ /usr/lib/perl5/site_perl/5.6.1/IMAP/Admin.pm        2002-09-13 13:48:44.000000000 +0100
@@ -128,7 +128,13 @@
                   $try, "]");
     return;
   }
-  if ($self->{'CRAM'} > 0) {
+  if ((defined $self->{'Proxy'}) && ($self->{'Capability'} =~ /PLAIN/)) {
+    my $plain64 = "use MIME::Base64;";
+    eval $plain64;
+    print $fh "try AUTHENTICATE PLAIN\n";
+    $try = $self->_read;
+    print $fh (encode_base64($self->{'Proxy'}."\000".$self->{'Login'}."\000".$self->{'Password'})."\n");
+  } elsif ($self->{'CRAM'} > 0) {
     if ($self->{'Capability'} =~ /CRAM-MD5/) {
       _do_cram_login($self);
     } else {


...then call it using something like...

my $imap = IMAP::Admin->new(
        'Server' => $server,
        'Proxy' => $username,
        'Login' => $superuser,
        'Password' => $superpass,
        'Port' => '993',
        'SSL' => 1
                # and any of the SSL_ options from IO::Socket::SSL
) or die "aargh: IMAP::Admin error";
 
while ($_ = shift) {
        $imap->subscribe($_)
                and carp "subscribe: $_: " . $imap->error;
}




More information about the Info-cyrus mailing list