open P, "/mnt/p/etc/passwd"; while (
) { chop; my ($username,$x,$uid,$gid,$name,$home,$shell) = split ":"; next if exists ($admaccounts{$username}); $petra{$username} = [ userPassword => undef, uidNumber => $uidcounter++, gidNumber => "501", cn => $name eq "" ? "Osprey User" : $name, homeDirectory => "/ispman/domains/osprey.net/users/${username}_osprey_net/", loginShell => "/bin/bash", objectClass => [qw(top inetOrgPerson person posixAccount ispmanDomainUser PureFTPdUser)], ispmanStatus => "active", ispmanCreateTimestamp => "1", #fixme uid => "${username}_osprey_net", ispmanUserId => $username, givenName => $name eq "" ? "Osprey User" : $name, sn => $name eq "" ? "Osprey User" : $name, mailHost => "freedom", FTPStatus => "enabled", FTPQuotaMBytes => "10", mailLocalAddress => "${username}\@osprey.net", mailQuota => "10000", mailRoutingAddress => "${username}_osprey_net\@osprey.net", ]; } close P; open P, "/mnt/p/etc/shadow"; while (
) { chop; my ($username, $pass, @rest) = split ':'; next if exists ($admaccounts{$username}); $petra{$username}[1] = "{crypt}$pass"; if ($pass eq "*") { $petra{$username}[15] = "inactive"; } } close P; use Net::LDAP; use Net::LDAP::Entry; my $ldap = Net::LDAP->new('localhost'); $ldap->bind ( # bind to a directory with dn and password dn => 'cn=Manager, dc=domain,dc=com', password => 'secret' ); my $entry=Net::LDAP::Entry->new(); $entry->changetype("add"); my $dn = "uid=user_domain_com, ou=users, ispmanDomain=domain.com, dc=domain,dc=com"; $entry->dn($dn); $entry->add( @{$petra{user}} ); my $result = $entry->update($ldap); $result->code && warn "$dn" ."failed to add entry: ", $result->error ;