1 package FS::part_export::cp;
3 use vars qw(@ISA %info);
7 @ISA = qw(FS::part_export);
9 tie my %options, 'Tie::IxHash',
10 'port' => { label=>'Port number' },
11 'username' => { label=>'Username' },
12 'password' => { label=>'Password' },
13 'domain' => { label=>'Domain' },
14 'workgroup' => { label=>'Default Workgroup' },
19 'desc' => 'Real-time export to Critical Path Account Provisioning Protocol',
20 'options'=> \%options,
23 <a href="http://www.cp.net/">Critial Path Account Provisioning Protocol</a>.
24 Requires installation of
25 <a href="http://search.cpan.org/dist/Net-APP">Net::APP</a>
30 sub rebless { shift; }
33 my( $self, $svc_acct ) = (shift, shift);
34 $self->cp_queue( $svc_acct->svcnum, 'create_mailbox',
35 'Mailbox' => $svc_acct->username,
36 'Password' => $svc_acct->_password,
37 'Workgroup' => $self->option('workgroup'),
38 'Domain' => $svc_acct->domain,
43 my( $self, $new, $old ) = (shift, shift, shift);
44 return "can't change domain with Critical Path"
45 if $old->domain ne $new->domain;
46 return "can't change username with Critical Path" #CP no longer supports this
47 if $old->username ne $new->username;
48 return '' unless $old->_password ne $new->_password;
49 $self->cp_queue( $new->svcnum, 'replace', $new->domain,
50 $old->username, $new->username, $old->_password, $new->_password );
54 my( $self, $svc_acct ) = (shift, shift);
55 $self->cp_queue( $svc_acct->svcnum, 'delete_mailbox',
56 'Mailbox' => $svc_acct->username,
57 'Domain' => $svc_acct->domain,
62 my( $self, $svc_acct ) = (shift, shift);
63 $self->cp_queue( $svc_acct->svcnum, 'set_mailbox_status',
64 'Mailbox' => $svc_acct->username,
65 'Domain' => $svc_acct->domain,
67 'OTHER_SUSPEND' => 'T',
71 sub _export_unsuspend {
72 my( $self, $svc_acct ) = (shift, shift);
73 $self->cp_queue( $svc_acct->svcnum, 'set_mailbox_status',
74 'Mailbox' => $svc_acct->username,
75 'Domain' => $svc_acct->domain,
78 'OTHER_SUSPEND' => 'F',
79 'OTHER_BOUNCE' => 'F',
84 my( $self, $svcnum, $method ) = (shift, shift, shift);
85 my $queue = new FS::queue {
87 'job' => 'FS::part_export::cp::cp_command',
91 $self->option('port'),
92 $self->option('username'),
93 $self->option('password'),
94 $self->option('domain'),
100 sub cp_command { #subroutine, not method
101 my($host, $port, $username, $password, $login_domain, $method, @args) = @_;
104 if ( $method eq 'replace' ) {
106 my( $domain, $old_username, $new_username, $old_password, $new_password)
109 if ( $old_username ne $new_username ) {
110 cp_command($host, $port, $username, $password, 'rename_mailbox',
112 Old_Mailbox => $old_username,
113 New_Mailbox => $new_username,
118 if ( $new_password =~ /^\*SUSPENDED\* (.*)$/ ) {
122 #cp_command($host, $port, $username, $password, $login_domain,
123 # 'set_mailbox_status',
125 # Mailbox => $new_username,
127 # Other_Bounce => $other,
130 if ( $old_password ne $new_password ) {
131 cp_command($host, $port, $username, $password, $login_domain,
134 Mailbox => $new_username,
135 Password => $new_password,
143 eval "use Net::APP;";
145 my $app = new Net::APP (
148 Password => $password,
149 Domain => $login_domain,
154 $app->$method( @args );
156 die $app->message."\n" unless $app->ok;