From b6762006da16052ed0b55e91b9416712efca01ca Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Mon, 20 Aug 2012 01:54:17 +0200 Subject: Archive the MySQL -> LDAP migration procedure. --- addadmin.pl | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100755 addadmin.pl (limited to 'addadmin.pl') 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(); -- cgit v1.2.3