summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ldap_wizard/ldap.pm172
1 files changed, 78 insertions, 94 deletions
diff --git a/ldap_wizard/ldap.pm b/ldap_wizard/ldap.pm
index 3cc1c31f..6b40d689 100644
--- a/ldap_wizard/ldap.pm
+++ b/ldap_wizard/ldap.pm
@@ -13,7 +13,7 @@ use standalone;
use MDK::Wizard::Varspaceval;
use MDK::Wizard::Wizcommon;
use Expect;
-use Net::LDAP;
+require Net::LDAP;
#unless ($> == 0) {
# die "You are not root Exiting\n";
@@ -36,7 +36,7 @@ my $o = {
rootpass => 'secret',
cn => '',
sn => '',
- uid => '',
+ uid => 'vincent',
uidpass => '',
lshell => '/bin/bash',
uidnb => '',
@@ -51,60 +51,60 @@ my $o = {
needed_rpm => [ 'openldap-servers', 'openldap-clients' ],
defaultimage => "/usr/share/wizards/dns_wizard/images/DNS.png"
};
+use Data::Dumper; print Dumper($o->{var});
+
my %level = (
- 1 => N("Server - Set configuration of LDAP server"),
- 2 => N("Add - add entry in LDAP server"),
+ 1 => N("Server - Set configuration of Ldap server"),
+ 2 => N("Add - add entry in Ldap server"),
);
+my $cn;
+
$o->{pages} = {
welcome => {
- name => N("LDAP configuration wizard") . "\n\n" . N("Setup a LDAP server."),
+ name => N("LDAP configuration wizard") . "\n\n" . N("Setup a ldap server."),
no_back => 1,
- pre => sub { $o->{var}{wiz_level} ||= 1 },
- post => sub { if ($o->{var}{wiz_level} == 2) {
- return 'add_user_posix';
- }
- },
+ pre => sub {
+ $o->{var}{wiz_level} ||= 1;
+ },
+ post => sub {
+ if ($o->{var}{wiz_level} == 2) {
+ return 'add_userposix';
+ }
+ },
data => [
{
- label => N("which operation on LDAP:"), val => \$o->{var}{wiz_level}, list => [ keys %level ], format => sub { $level{$_[0]} } },
+ label => N("wich operation on LDAP:"), val => \$o->{var}{wiz_level}, list => [ keys %level ], format => sub { $level{$_[0]} } },
],
next => 'setldap',
},
- add_user_posix => {
- name => N("Add data in LDAP") . "\n\n" . N("UID, GUID, home directory, "),
- data => [
- {
- label => N("First Name:"), val => \$o->{var}{cn} },
- {
- label => N("Last Name:"), val => \$o->{var}{sn} },
- {
- label => N("User Name:"), val => \$o->{var}{uid} },
- {
- label => N("Password:"), val => \$o->{var}{uidpass} },
- {
- label => N("Login shell:"), val => \$o->{var}{lshell} },
- {
- label => N("UID number:"), val => \$o->{var}{uidnb} },
- {
- label => N("Group ID:"), val => \$o->{var}{Guidnb} },
- {
- label => N("Container:"), val => $o->{var}{container} . $DC },
- ],
- post => \&test_add,
- next => 'summaryadd',
- },
+ add_userposix => {
+ name => N("Add data in LDAP") . "\n\n" . N("uid, guid, home directory, "),
+ data => [
+ { label => N("First Name:"), val => \$o->{var}{cn} },
+ { label => N("Last Name:"), val => \$o->{var}{sn} },
+ { label => N("User Name:"), val => \$o->{var}{uid} },
+ { label => N("Password:"), val => \$o->{var}{uidpass} },
+ { label => N("Login shell:"), val => \$o->{var}{lshell} },
+ { label => N("uid number:"), val => \$o->{var}{uidnb} },
+ { label => N("Group ID:"), val => \$o->{var}{guidnb} },
+ { label => N("Container:"), val => $o->{var}{container} . $DC },
+ ],
+ post => \&test_add,
+ next => 'summaryadd',
+ },
setldap => {
- name => N("LDAP RootDSE
-Example: \"obelx.nux.com\" will be \"dc=obelx,dc=nux,dc=com\" in LDAP config.
-
-RootDN is the manager of your LDAP server."),
+ name => N("Ldap RootDSE") . "\n\n" . N("example:") . "\n" . N("obelx.nux.com") . "\n\n" . N("will be in ldap config:") . "\n" . N("dc=obelx,dc=nux,dc=com") . "\n\n" . N("RootDN is the manager of your ldap server."),
data => [
- { label => N("RootDSE"), val => \$o->{var}{rootdse} },
- { label => N("RootDN"), val => \$o->{var}{rootdn} },
- { label => N("Password"), val => \$o->{var}{rootpass} },
- { label => N("Default OU"), val => \$o->{var}{defou} },
+ {
+ label => N("RootDSE"), val => \$o->{var}{rootdse} },
+ {
+ label => N("RootDN"), val => \$o->{var}{rootdn} },
+ {
+ label => N("Password"), val => \$o->{var}{rootpass} },
+ {
+ label => N("Default OU"), val => \$o->{var}{defou} },
],
post => \&test_set,
next => 'summaryset',
@@ -112,36 +112,21 @@ RootDN is the manager of your LDAP server."),
summaryadd => {
name => N("Ok Now add entry in LDAP"),
data => [
- {
- label => N("First Name:"), fixed_val => \$o->{var}{cn} },
- {
- label => N("Last Name:"), fixed_val => \$o->{var}{sn} },
- {
- label => N("User Name:"), fixed_val => \$o->{var}{uid} },
- {
- label => N("Password:"), fixed_val => \$o->{var}{uidpass} },
- {
- label => N("Home directory:"), fixed_val => \$o->{var}{uid} },
- {
- label => N("Login shell:"), val => \$o->{var}{lshell} },
- {
- label => N("uid number:"), fixed_val => \$o->{var}{uidnb} },
- {
- label => N("Group ID:"), fixed_val => \$o->{var}{Guidnb} },
- {
- label => N("Container:"), fixed_val => \$o->{var}{container} },
- {
- label => N("shadowMax:"), fixed_val => \$o->{var}{shadowmax} },
- {
- label => N("shadowMin:"), fixed_val => \$o->{var}{shadowmin} },
- {
- label => N("shadowWarning:"), fixed_val => \$o->{var}{shadowina} },
- {
- label => N("shadowInactive:"), fixed_val => \$o->{var}{shadowina} },
- {
- label => N("shadowExpire:"), fixed_val => \$o->{var}{shadowexpire} },
- {
- label => N("objectClass:"), fixed_val => \$o->{var}{objectclass} },
+ { label => N("First Name:"), fixed_val => \$o->{var}{cn2} },
+ { label => N("Last Name:"), fixed_val => \$o->{var}{sn2} },
+ { label => N("User Name:"), fixed_val => \$o->{var}{uid2} },
+ { label => N("Password:"), fixed_val => \$o->{var}{uidpass} },
+ { label => N("Home directory:"), fixed_val => \$o->{var}{uid} },
+ { label => N("Login shell:"), fixed_val => \$o->{var}{lshell} },
+ { label => N("uid number:"), fixed_val => \$o->{var}{uidnb} },
+ { label => N("Group ID:"), fixed_val => \$o->{var}{guidnb} },
+ { label => N("Container:"), fixed_val => \$o->{var}{container} },
+ { label => N("shadowMax:"), fixed_val => \$o->{var}{shadowmax} },
+ { label => N("shadowMin:"), fixed_val => \$o->{var}{shadowmin} },
+ { label => N("shadowWarning:"), fixed_val => \$o->{var}{shadowina} },
+ { label => N("shadowInactive:"), fixed_val => \$o->{var}{shadowina} },
+ { label => N("shadowExpire:"), fixed_val => \$o->{var}{shadowexpire} },
+ { label => N("objectClass:"), fixed_val => \$o->{var}{objectclass} },
],
post => \&do_it_add,
next => 'endadd',
@@ -149,15 +134,17 @@ RootDN is the manager of your LDAP server."),
summaryset => {
name => N("Ok Now building your LDAP configuration") . "\n\n" . N("with this configuration:"),
data => [
- { label => N("RootDSE"), fixed_val => \$o->{var}{rootdse} },
- { label => N("RootDN"), fixed_val => \$o->{var}{rootdn} },
+ {
+ label => N("RootDSE"), fixed_val => \$o->{var}{rootdse} },
+ {
+ label => N("RootDN"), fixed_val => \$o->{var}{rootdn} },
],
post => \&do_it_setldap,
next => 'end'
},
error_homedir => {
name => N("Error in Home directory"),
- next => 'add_user_posix',
+ next => 'add_userposix',
},
error_pass => {
name => N("Error, pass could not be empty"),
@@ -165,11 +152,11 @@ RootDN is the manager of your LDAP server."),
},
error_shell => {
name => N("Error in Login shell") . "\n\n" . N("Please choose a correct one"),
- next => 'add_user_posix',
+ next => 'add_userposix',
},
error_nb => {
name => N("Error") . "\n\n" . N("Please Should be a number"),
- next => 'add_user_posix',
+ next => 'add_userposix',
},
end => {
name => N("Congratulations"),
@@ -179,11 +166,11 @@ RootDN is the manager of your LDAP server."),
next => 0
},
endadd => {
- name => N("Data Successfully added"),
- data => [ { label => N("The wizard successfully add entry in LDAP") } ],
+ name => N("Successfully add data"),
+ data => [ { label => N("The wizard successfully add entry in ldap") } ],
no_back => 1,
end => 1,
- next => 0
+ next => 0,
},
};
@@ -218,7 +205,7 @@ sub do_it_setldap {
s/suffix.*/suffix\t"dc=$dcall"/;
} $LDAPCONF;
} else {
- append_to_file($LDAPCONF, qq(suffix\t"dc=$dcall"));
+ append_to_file($LDAPCONF, "suffix\t\"dc=$dcall\"");
}
# s/example/$dcall
@@ -232,27 +219,24 @@ sub do_it_setldap {
s/rootdn.*/rootdn\t"cn=$o->{var}{rootdn},dc=$dcall"/;
} $LDAPCONF;
} else {
- append_to_file($LDAPCONF, qq(rootdn\t"$o->{var}{rootdn},dc=$dcall"));
+ append_to_file($LDAPCONF, "rootdn\t\"$o->{var}{rootdn},dc=$dcall\"");
}
# set rootpass
my $cryptpass = crypt($o->{var}{rootpass}, "crypt");
if (any { /^rootpw/ } cat_($LDAPCONF)) {
- substInFile {
- s/rootpw.*/rootpw $cryptpass/;
- } $LDAPCONF;
+ substInFile {
+ s/rootpw.*/rootpw $cryptpass/;
+ } $LDAPCONF;
} else {
- append_to_file($LDAPCONF, "rootpw {CRYPT}$cryptpass");
+ append_to_file($LDAPCONF, "rootpw {CRYPT}$cryptpass");
}
# reset premisions
system("chown -R root.ldap /etc/openldap");
system("service ldap restart");
-
$o->{var}{rootdse} = "dc=$dcall";
-
create_rootdse($o);
-
}
sub test_add {
@@ -263,13 +247,13 @@ sub test_add {
}
sub do_it_add {
- my $dcall = rootdse_to_dc($o->{var}{rootdse});
- $o->{var}{rootdse} = "dc=$dcall";
- $o->{var}{rootpass} = "secret";
- add_user_posix($o);
+ return if $::testing;
+ my $dcall = rootdse_to_dc($o->{var}{rootdse});
+ $o->{var}{rootdse} = "dc=$dcall";
+ $o->{var}{rootpass} = "secret";
+ add_user_posix($o);
}
-
sub new {
my ($class, $conf) = @_;
bless {