Re: Scripting admin stuff?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

(I'm top posting as the previous posters have set in motion...)

I came across this old posting on the Cyrus mailing list.  It is very close to what
I want to do, simply extracting a list of mailboxes from within Perl.

For some reason our use of IMAP::Admin on Redhat 6 has stopped
working for the old script I've used before.  Most calls work, but
@mailboxlist = $client->list( "*" )  returns an empty list, and
no errors can be forced to appear.

So I'm trying out Cyrus::IMAP::Admin, and rewriting the connection stuff.

In my case I need to specify the authentication info. I found an old web page
which said I need to call it like this:

   $client = Cyrus::IMAP::Admin->new(  "$server" );
   $auth = {
      -mechanism => 'login',
      -service => 'imap',
      -authz => $uid,
      -user => $uid,
      -minssf => 0,
      -maxssf => 10000,
      -password => $pwd,
   };

   $client->authenticate($auth);

When I use this, I get an error:

Error: Please login first

Finding docs and examples on Cyrus::IMAP::Admin is rather thin
on some details.  Does anyone have a sample script which does
authentication/login?

--Donald

On Thu, Mar 26, 2009 at 1:37 PM, Jeff Blaine <jblaine@xxxxxxxxxxxx> wrote:
Thanks.  I shortened it to the following.  For those
using this, it needs to run as cyrus (or whatever your
cyrus user is).

#!/linus/mail/cyrus/bin/perl

$default_quota = 400000;

use Cyrus::IMAP::Admin;
use Cyrus::IMAP;

my $client = Cyrus::IMAP::Admin->new("YOUR_SERVER",143);

$client->authenticate;

@mailboxes = $client->list('%', 'user.');

foreach $mbx ( @mailboxes ) {
    @m = @$mbx;

    $client->setquota($m[0],"STORAGE",$default_quota);
}


Paul M Fleming wrote:
> Save you the work -- had to do the same thing myself.
>
> Modify as needed - for example, i use this with Kerberos auth so no
> username / password is used.
>
>
> #!/usr/bin/perl
>
> use Cyrus::IMAP::Admin;
> use Cyrus::IMAP;
> $default_quota = 200000;
>
> my $client = Cyrus::IMAP::Admin->new("server",143);
> $client->authenticate;
> @mailboxes = $client->list('%', 'user.');
> foreach $mbx ( @mailboxes )
> {
>
>         @m = @$mbx;
>
>         ($root, %quota) = $client->quotaroot($m[0]);
>
>         $cur_usage = $quota{"STORAGE"}[0];
>         $cur_quota = $quota{"STORAGE"}[1];
>
>         if ( defined $cur_quota )
>         {
>                 # quota defined
>                 if ( $cur_quota < $default_quota )
>                 {
>                         print "$m[0] : below default increasing\n";
>                         $client->setquota($m[0],"STORAGE",$default_quota);
>                 }
>                 if ( $cur_quota > $default_quota )
>                 {
>                         print "$m[0] : over default: $cur_quota
> ($cur_usage / $cur_quota)\n";
>                 }
>         }
>         else
>         {
>                 print "$m[0] : NO QUOTA $cur_usage\n";
>         }
>
>
>
> }
>
>
> On 3/26/2009 11:03 AM, Jeff Blaine wrote:
>> In 2000, I wrote a simple script that was fed to cyradm
>> to set all users quota to some value.
>>
>> It appears today that the only option to do something like
>> this is to learn the Cyrus::* Perl modules.
>>
>> Is that correct?
>> ----
>> Cyrus Home Page: http://cyrusimap.web.cmu.edu/
>> Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
>> List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html
>
----
Cyrus Home Page: http://cyrusimap.web.cmu.edu/
Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html

----
Cyrus Home Page: http://www.cyrusimap.org/
List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/

[Index of Archives]     [Cyrus SASL]     [Squirrel Mail]     [Asterisk PBX]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [KDE]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux