diff options
author | Guilhem Moulin <guilhem.moulin@fripost.org> | 2012-08-20 01:54:17 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem.moulin@fripost.org> | 2012-08-20 01:54:17 +0200 |
commit | b6762006da16052ed0b55e91b9416712efca01ca (patch) | |
tree | 3b3db4c8f749a2594eff88c3c23fd6a50623479f /addadmin.pl | |
parent | ded29bf9eb3fa40c56eb9ace365d13e6348e215c (diff) |
Archive the MySQL -> LDAP migration procedure.
Diffstat (limited to 'addadmin.pl')
-rwxr-xr-x | addadmin.pl | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/addadmin.pl b/addadmin.pl deleted file mode 100755 index 508d100..0000000 --- a/addadmin.pl +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/perl - -# Run `sudo ./addadmin.pl' to add yourself as an administrator for virtual -# mail hosting. -# (Use the optional argument if you're not happy with your login name.) -# -# To use the tools, you'll need to edit `~/.fripost.yml' and replace -# `bind_dn' and `bind_pw' by, respectively, the returned Distinguished Name -# and your password - -use 5.010_000; -use strict; -use warnings; -use utf8; - -use FindBin qw($Bin); -use lib "$Bin/lib"; - -use Fripost::Schema; -use Fripost::Password; -use Fripost::Prompt; -use YAML::Syck; - -my $user = $ARGV[0]; -$user //= $ENV{SUDO_USER}; -$user //= $ENV{USER}; - -die "Error: Cannot find user name.\n" - unless defined $user; - -# Connect to the LDAP server -my $ldapconf = LoadFile ( 'ldap.yml' ); -my $ldap = Fripost::Schema->new( $ldapconf ); -$ldap = $ldap->{_ldap}; - - -my $dn = join ',', ( 'cn='.$user - , 'ou=managers' - , (split ',', $ldapconf->{base_dn},2)[1] ); - -my $password = hash( undef, undef, prompt_password() ); -my $res = $ldap->add( $dn, - attrs => [ objectClass => [ 'simpleSecurityObject' - , 'organizationalRole' ] - , userPassword => $password - ] - ); - die "Error: " .$res->error. "\n" if $res->code; - -say $dn; -$ldap->unbind(); |