Jeff Bert schrieb am Fri, Mar 08, 2002 at 08:02:44AM -0800:
> I'm trying to find a script that will allow me to add users via a single
> command line entry.
> 
> I found "imapcreate.pl" at sourceforge but it seems to choke on every call
> to the Cyrus::IMAP libraries.
> 
> Has anyone done something like this or modified this perl script to work?

I had this tiny one for testing, maybe you find it useful (but is perl as
well and uses Cyrus::IMAP, so if they are broken, you're lost)


Regards,

Birger
#!/usr/bin/perl

# creates new cyrus users with admin account of "dummy" (change this!)
# usage: "echo <user> | ./cyrus-adduser.pl"
#    or: "cat <file with userlist> | ./cyrus-adduser.pl"

use Cyrus::IMAP::Admin;
use Getopt::Std;
our($opt_h, $opt_p);

$admin = "dummy";
$adminpass = "dummypass";

my $client = Cyrus::IMAP::Admin->new('localhost');
$client->authenticate("-mechanism", "login", "-user", "$admin", "-password", 
"$adminpass");
while (<>) {
  chop;
  $client->create("user.$_");
}

Reply via email to