Joe Dennick wrote:
We've got Cyrus-Imap 2.1.12 running very well for our company Red Hat 8.0. We are authenticating against a MySQL database that we use as a master Security Container for all of our application authentication and entitlements. We've already populated the database with all of the user information required including usernames, passwords, shadow passwords, email addresses, etc. Now we need to create Cyrus-Imap mailboxes for each user (close to 3,000 mailboxes). I've seen several articles that talk about scripting CYRADM to read a text file containing usernames, but I can't get any of the scripting examples to work. It appears as though Cyrus-Imap, or specifically CYRADM has changed since the examples were created. Is there a way to script or batch create users? All I really need to do is create the mailbox and set the ACL so cyrus (admin account) has admin control over the mailbox. I can manually create the mailboxes with the following commands:
cyradm --user cyrus localhost IMAP Password: ******* localhost.localdomain> createmailbox user.12345 localhost.localdomain> setacl user.12345 cyrus all localhost.localdomain> quit
Thank you in advance for your assistance.
Joe Dennick [EMAIL PROTECTED]
We use a variant of the following script to add new users but in your case you should be able to use this as all your MySQL accounts need a Cyrus user created.
#!/usr/bin/perl -w #
use File::Basename; use Net::IMAP; use DBI; my $cyrususer = "user"; my $cyruspass = "pass"; my $mysqluser = "user"; my $mysqlpass = "pass"; my $mysqlhost = "host"; my $mysqldatabase = "database"; my $mysqluserfield = "field"; my $mysqlusertable = "table"; my $IMAPSERVER = "localhost"; $dbh = DBI->connect("DBI:mysql:$mysqldatabase:$mysqlhost","$mysqluser","$mysqlpass") || die "SEM: MySQL database connected failed: $DBI::errstr\n"; my $select = "SELECT $mysqluserfield FROM $mysqlusertable"; my $sth = $dbh->prepare($select) || die "Can't prepare select statement: $DBI::errstr"; my $rc = $sth->execute || die "Can't execute statement: $DBI::errstr"; if ($sth->rows == 0) { exit 1; } # Login to IMAP server $imap = new Net::IMAP($IMAPSERVER, Synchronous => 1) || die "no go $! !"; $response = $imap->login($cyrususer, $cyruspass); print "Login: ", $response->status, "-", $response->status_text, "\n"; while ($userid = $sth->fetchrow) { print "user.$userid\n"; # Create the new mailbox $response = $imap->create(user.$userid); print "Create: ", $response->status, "-", $response->status_text, "\n"; } # Disconnect from IMAP server $response = $imap->logout(); print "Logout: ", $response->status, "-", $response->status_text, "\n"; $dbh->disconnect();