summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2002-02-15 19:33:41 +0000
committerivan <ivan>2002-02-15 19:33:41 +0000
commit0dc8c09556f5e74b5a58931e40c2da06619a6be7 (patch)
tree3abaa1775a2b599a0226a187f57f041f9a5f5a39
parente72b1302bd8af9968a0520e1ab5f77d98571a4e6 (diff)
CP provisioning!!
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/svc_acct.pm130
-rw-r--r--Makefile4
3 files changed, 139 insertions, 2 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 5de25510c..d5c00467d 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -268,6 +268,13 @@ httemplate/docs/config.html
},
{
+ 'key' => 'cp_app',
+ 'section' => 'mail',
+ 'description' => 'Integration with <a href="http://www.cp.net/">Critial Path Account Provisioning Protocol</a>, four lines: "host:port", username, password, and workgroup (for new users).',
+ 'type' => 'textarea',
+ },
+
+ {
'key' => 'deletecustomers',
'section' => 'UI',
'description' => 'Enable customer deletions. Be very careful! Deleting a customer will remove all traces that this customer ever existed! It should probably only be used when auditing a legacy database. Normally, you cancel all of a customers\' packages if they cancel service.',
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index f3c2d76d3..65a58fc98 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -7,6 +7,7 @@ use vars qw( @ISA $nossh_hack $conf $dir_prefix @shells $usernamemin
$username_noperiod $username_uppercase
$shellmachine $useradd $usermod $userdel $mydomain
$cyrus_server $cyrus_admin_user $cyrus_admin_pass
+ $cp_server $cp_user $cp_pass $cp_workgroup
$dirhash
$icradius_dbh
@saltset @pw_set);
@@ -71,6 +72,16 @@ $FS::UID::callback{'FS::svc_acct'} = sub {
$cyrus_admin_user = '';
$cyrus_admin_pass = '';
}
+ if ( $conf->exists('cp_app') ) {
+ ($cp_server, $cp_user, $cp_pass, $cp_workgroup) =
+ $conf->config('cp_app');
+ eval "use Net::APP;"
+ } else {
+ $cp_server = '';
+ $cp_user = '';
+ $cp_pass = '';
+ $cp_workgroup = '';
+ }
if ( $conf->exists('icradiusmachines') ) {
if ( $conf->exists('icradius_secrets') ) {
#need some sort of late binding so it's only connected to when
@@ -286,6 +297,16 @@ sub insert {
return "queueing job (transaction rolled back): $error";
}
}
+
+ if ( $cp_server ) {
+ my $queue = new FS::queue { 'job' => 'FS::svc_acct::cp_insert' };
+ $error = $queue->insert($self->username, $self->_password);
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "queueing job (transaction rolled back): $error";
+ }
+ }
+
if ( $icradius_dbh ) {
my $radcheck_queue =
@@ -351,6 +372,27 @@ sub cyrus_insert {
1;
}
+sub cp_insert {
+ my( $username, $password ) = @_;
+
+ my $app = new Net::APP ( $cp_server,
+ User => $cp_user,
+ Password => $cp_pass,
+ Domain => $mydomain,
+ Timeout => 60,
+ #Debug => 1,
+ ) or die $@;
+
+ $app->create_mailbox(
+ Mailbox => $username,
+ Password => $password,
+ Workgroup => $cp_workgroup,
+ Domain => $mydomain,
+ );
+
+ die $app->message unless $app->ok;
+}
+
sub icradius_rc_insert {
my( $username, $password, %radcheck ) = @_;
@@ -517,6 +559,16 @@ sub delete {
return "queueing job (transaction rolled back): $error";
}
}
+
+ if ( $cp_server ) {
+ my $queue = new FS::queue { 'job' => 'FS::svc_acct::cp_delete' };
+ $error = $queue->insert($self->username);
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "queueing job (transaction rolled back): $error";
+ }
+ }
+
if ( $icradius_dbh ) {
my $radcheck_queue =
@@ -562,6 +614,24 @@ sub cyrus_delete {
1;
}
+sub cp_delete {
+ my( $username ) = @_;
+ my $app = new Net::APP ( $cp_server,
+ User => $cp_user,
+ Password => $cp_pass,
+ Domain => $mydomain,
+ Timeout => 60,
+ #Debug => 1,
+ ) or die $@;
+
+ $app->delete_mailbox(
+ Mailbox => $username,
+ Domain => $mydomain,
+ );
+
+ die $app->message unless $app->ok;
+}
+
sub icradius_rc_delete {
my $username = shift;
@@ -666,6 +736,24 @@ sub replace {
}
}
+ if ( $cp_server && $old->username ne $new->username ) {
+ my $queue = new FS::queue { 'job' => 'FS::svc_acct::cp_rename' };
+ $error = $queue->insert( $old->username, $new->username );
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "queueing job (transaction rolled back): $error";
+ }
+ }
+
+ if ( $cp_server && $old->_password ne $new->_password ) {
+ my $queue = new FS::queue { 'job' => 'FS::svc_acct::cp_change' };
+ $error = $queue->insert( $new->username, $new->_password );
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "queueing job (transaction rolled back): $error";
+ }
+ }
+
if ( $icradius_dbh ) {
my $queue = new FS::queue { 'job' => 'FS::svc_acct::icradius_rc_replace' };
$error = $queue->insert( $new->username,
@@ -693,6 +781,48 @@ sub icradius_rc_replace {
1;
}
+sub cp_rename {
+ my ( $old_username, $new_username );
+
+ my $app = new Net::APP ( $cp_server,
+ User => $cp_user,
+ Password => $cp_pass,
+ Domain => $mydomain,
+ Timeout => 60,
+ #Debug => 1,
+ ) or die $@;
+
+ $app->rename_mailbox(
+ Domain => $mydomain,
+ Old_Mailbox => $old_username,
+ New_Mailbox => $new_username,
+ );
+
+ die $app->message unless $app->ok;
+
+}
+
+sub cp_change {
+ my ( $username, $password );
+
+ my $app = new Net::APP ( $cp_server,
+ User => $cp_user,
+ Password => $cp_pass,
+ Domain => $mydomain,
+ Timeout => 60,
+ #Debug => 1,
+ ) or die $@;
+
+ $app->change_mailbox(
+ Domain => $mydomain,
+ Mailbox => $username,
+ Password => $password,
+ );
+
+ die $app->message unless $app->ok;
+
+}
+
=item suspend
Suspends this account by prefixing *SUSPENDED* to the password. If there is an
diff --git a/Makefile b/Makefile
index 283981a87..dd134ebfc 100644
--- a/Makefile
+++ b/Makefile
@@ -6,8 +6,8 @@ DATASOURCE = DBI:Pg:host=localhost;dbname=freeside
DB_USER = freeside
DB_PASSWORD=
-TEMPLATE = asp
-#TEMPLATE = mason
+#TEMPLATE = asp
+TEMPLATE = mason
ASP_GLOBAL = /usr/local/etc/freeside/asp-global