Skip to content

Instantly share code, notes, and snippets.

@sarguru
Created April 12, 2012 10:53
Show Gist options
  • Save sarguru/2366487 to your computer and use it in GitHub Desktop.
Save sarguru/2366487 to your computer and use it in GitHub Desktop.
Modify deepofix users from old schema to new schema
#!/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
]
);
@sarguru
Copy link
Author

sarguru commented Apr 12, 2012

usage:
./filename [username] [easypush-password]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment