Created
April 12, 2012 10:53
-
-
Save sarguru/2366487 to your computer and use it in GitHub Desktop.
Modify deepofix users from old schema to new schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Net::LDAP; | |
open (BASEDN,"/var/qmail/control/ldapbasedn") || die "couldn't open | |
file \n"; | |
$basedn = <BASEDN>; | |
chomp($basedn); | |
$ldap = Net::LDAP->new("localhost", timeout=>30) or die "failed"; | |
$msg = | |
$ldap->bind("uid=easypush,ou=People,$basedn", password=>$ARGV[1]); | |
print $msg->code; | |
$user=$ARGV[0]; | |
$search = $ldap->search( filter=>"(uid=$user)", base=>"ou=People,$basedn"); | |
@entries = $search->entries; | |
my $dn = @entries[0]->dn; # yes.. get the DN | |
print($dn); | |
print "\n"; | |
my @AddArray; | |
push @AddArray, 'objectClass', 'CourierMailAccount'; | |
push @AddArray, 'disableimap', '0'; | |
push @AddArray, 'disablepop3', '0'; | |
push @AddArray, 'disablewebmail', '0'; | |
push @AddArray, 'localonly', '0'; | |
push @AddArray, 'qmailDotMode', 'ldaponly'; | |
if ( $#AddArray > 0 ) | |
{ | |
push @whatToChange, 'add'; | |
push @whatToChange, \@AddArray; | |
} | |
else | |
{ | |
print "null" | |
} | |
my $result = $ldap->modify ( $dn, | |
changes => [ | |
@whatToChange | |
] | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage:
./filename [username] [easypush-password]