6 use FS::UID qw(adminsuidsetup);
7 use FS::Record qw(qsearchs);
11 my $user = shift or die;
12 adminsuidsetup($user);
14 $FS::svc_Common::noexport_hack = 1;
15 $FS::svc_domain::whois_hack = 1;
17 my $domain_svcpart = 1;
18 my $account_svcpart = 2;
19 my $mailbox_svcpart = 3;
20 my $fedweeknet_svcpart = 4;
23 # Net::LDAP::LDIF->new( "ispman-06-23-04.ldif", "r", onerror => 'undef' );
25 Net::LDAP::LDIF->new( "ispman-06-23-04.ldif", "r", onerror => 'warn' );
33 while ( $entry = $ldif->read_entry ) {
35 my %attributes = map { $_ => [ $entry->get_value( $_ ) ] } $entry->attributes;
37 my $objectclass = join('/', @{$attributes{'objectclass'}} );
39 next unless $objectclass eq 'posixAccount/ispmanDomainUser/radiusprofile';
41 foreach my $attr ( keys %attributes ) {
42 print join( " => ", substr($attr.' 'x30,0,30), @{$attributes{ $attr }} ), "\n";
43 #if ( $attr eq 'objectclass' ) {
44 # $objectclass{ join('/', @{$attributes{$attr}} ) }++;
51 my $email = $attributes{'maillocaladdress'}->[0];
52 $email =~ /^(\w+)\@([\w\.\-]+)$/ or die $email;
53 die "$1 ne ". $attributes{'ispmanuserid'}->[0]. "\n"
54 unless lc($1) eq $attributes{'ispmanuserid'}->[0];
55 my $username = lc($1);
58 my $svc_domain = qsearchs('svc_domain', { 'domain' => $domain } )
59 || new FS::svc_domain { 'svcpart' => $domain_svcpart,
64 unless ( $svc_domain->svcnum ) {
65 my $error = $svc_domain->insert;
67 die "inserting domain: $error\n";
71 ( my $password = $attributes{'userpassword'}->[0] ) =~ s/^\{crypt\}//;
74 my $svcpart = $account_svcpart;
75 if ( $domain eq 'fedweeknet.com' ) {
76 $svcpart = $fedweeknet_svcpart;
77 } elsif ( $attributes{'dialupaccess'}->[0] =~ /(false|no)/i ) {
78 $svcpart = $mailbox_svcpart;
81 my $dir = $attributes{'homedirectory'}->[0];
85 my $svc_acct = new FS::svc_acct {
86 'svcpart' => $svcpart,
87 'username' => $username,
88 '_password' => $password,
89 'finger' => $attributes{'cn'}->[0],
90 'domsvc' => $svc_domain->svcnum,
91 'shell' => $attributes{'loginshell'}->[0],
92 'uid' => $attributes{'uidnumber'}->[0],
93 'gid' => $attributes{'gidnumber'}->[0],
95 'quota' => $attributes{'mailquota'}->[0],
97 my $error = $svc_acct->insert;
98 #my $error = $svc_acct->check;
108 print "$imported of $acct imported\n";
112 #foreach ( sort { $objectclass{$b} <=> $objectclass{$a} } keys %objectclass ) {
113 # print "$objectclass{$_}: $_\n";