Hi,<br><br>(I'm top posting as the previous posters have set in motion...)<br><br>I came across this old posting on the Cyrus mailing list. It is very close to what<br>I want to do, simply extracting a list of mailboxes from within Perl.<br>
<br>For some reason our use of IMAP::Admin on Redhat 6 has stopped<br>working for the old script I've used before. Most calls work, but<br>@mailboxlist = $client->list( "*" ) returns an empty list, and<br>
no errors can be forced to appear.<br><br>So I'm trying out Cyrus::IMAP::Admin, and rewriting the connection stuff.<br><br>In my case I need to specify the authentication info. I found an old web page<br>which said I need to call it like this:<br>
<br> $client = Cyrus::IMAP::Admin->new( "$server" );<br> $auth = {<br> -mechanism => 'login',<br> -service => 'imap',<br> -authz => $uid,<br> -user => $uid,<br>
-minssf => 0,<br> -maxssf => 10000,<br> -password => $pwd,<br> };<br><br> $client->authenticate($auth);<br><br>When I use this, I get an error:<br><br>Error: Please login first<br><br>Finding docs and examples on Cyrus::IMAP::Admin is rather thin <br>
on some details. Does anyone have a sample script which does<br>authentication/login?<br><br>--Donald<br><br><div class="gmail_quote">On Thu, Mar 26, 2009 at 1:37 PM, Jeff Blaine <span dir="ltr"><<a href="mailto:jblaine@kickflop.net">jblaine@kickflop.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Thanks. I shortened it to the following. For those<br>
using this, it needs to run as cyrus (or whatever your<br>
cyrus user is).<br>
<br>
#!/linus/mail/cyrus/bin/perl<br>
<br>
$default_quota = 400000;<br>
<div class="im"><br>
use Cyrus::IMAP::Admin;<br>
use Cyrus::IMAP;<br>
<br>
</div>my $client = Cyrus::IMAP::Admin->new("YOUR_SERVER",143);<br>
<div class="im"><br>
$client->authenticate;<br>
<br>
@mailboxes = $client->list('%', 'user.');<br>
<br>
foreach $mbx ( @mailboxes ) {<br>
@m = @$mbx;<br>
<br>
</div><div class="im"> $client->setquota($m[0],"STORAGE",$default_quota);<br>
}<br>
<br>
<br>
</div><div><div></div><div class="h5">Paul M Fleming wrote:<br>
> Save you the work -- had to do the same thing myself.<br>
><br>
> Modify as needed - for example, i use this with Kerberos auth so no<br>
> username / password is used.<br>
><br>
><br>
> #!/usr/bin/perl<br>
><br>
> use Cyrus::IMAP::Admin;<br>
> use Cyrus::IMAP;<br>
> $default_quota = 200000;<br>
><br>
> my $client = Cyrus::IMAP::Admin->new("server",143);<br>
> $client->authenticate;<br>
> @mailboxes = $client->list('%', 'user.');<br>
> foreach $mbx ( @mailboxes )<br>
> {<br>
><br>
> @m = @$mbx;<br>
><br>
> ($root, %quota) = $client->quotaroot($m[0]);<br>
><br>
> $cur_usage = $quota{"STORAGE"}[0];<br>
> $cur_quota = $quota{"STORAGE"}[1];<br>
><br>
> if ( defined $cur_quota )<br>
> {<br>
> # quota defined<br>
> if ( $cur_quota < $default_quota )<br>
> {<br>
> print "$m[0] : below default increasing\n";<br>
> $client->setquota($m[0],"STORAGE",$default_quota);<br>
> }<br>
> if ( $cur_quota > $default_quota )<br>
> {<br>
> print "$m[0] : over default: $cur_quota<br>
> ($cur_usage / $cur_quota)\n";<br>
> }<br>
> }<br>
> else<br>
> {<br>
> print "$m[0] : NO QUOTA $cur_usage\n";<br>
> }<br>
><br>
><br>
><br>
> }<br>
><br>
><br>
> On 3/26/2009 11:03 AM, Jeff Blaine wrote:<br>
>> In 2000, I wrote a simple script that was fed to cyradm<br>
>> to set all users quota to some value.<br>
>><br>
>> It appears today that the only option to do something like<br>
>> this is to learn the Cyrus::* Perl modules.<br>
>><br>
>> Is that correct?<br>
>> ----<br>
>> Cyrus Home Page: <a href="http://cyrusimap.web.cmu.edu/" target="_blank">http://cyrusimap.web.cmu.edu/</a><br>
>> Cyrus Wiki/FAQ: <a href="http://cyrusimap.web.cmu.edu/twiki" target="_blank">http://cyrusimap.web.cmu.edu/twiki</a><br>
>> List Archives/Info: <a href="http://asg.web.cmu.edu/cyrus/mailing-list.html" target="_blank">http://asg.web.cmu.edu/cyrus/mailing-list.html</a><br>
><br>
----<br>
Cyrus Home Page: <a href="http://cyrusimap.web.cmu.edu/" target="_blank">http://cyrusimap.web.cmu.edu/</a><br>
Cyrus Wiki/FAQ: <a href="http://cyrusimap.web.cmu.edu/twiki" target="_blank">http://cyrusimap.web.cmu.edu/twiki</a><br>
List Archives/Info: <a href="http://asg.web.cmu.edu/cyrus/mailing-list.html" target="_blank">http://asg.web.cmu.edu/cyrus/mailing-list.html</a><br>
</div></div></blockquote></div><br>