summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ldap_wizard/Ldap.pm12
-rw-r--r--ldap_wizard/ldapdef.pm40
2 files changed, 25 insertions, 27 deletions
diff --git a/ldap_wizard/Ldap.pm b/ldap_wizard/Ldap.pm
index ccbe1b49..c43e2b46 100644
--- a/ldap_wizard/Ldap.pm
+++ b/ldap_wizard/Ldap.pm
@@ -55,7 +55,7 @@ my $ldap_suffix=join(',dc=', split(/\./, chomp_(`hostname -f`)));
$ldap_suffix =~ s/[^,]*,//;
my $conf_file = "/etc/sysconfig/ldapconf";
my $LDAPCONF = "/etc/openldap/slapd.conf";
-my $rootdn_cn = "Admin";
+#my $rootdn_cn = "Admin";
##### Read conf file is exist
my $hostname = `hostname`;
@@ -249,7 +249,7 @@ sub do_it_setldap {
}
# set rootpass
- my $cryptpass = crypt($o->{var}{rootpass}, "crypt");
+ my $_cryptpass = crypt($o->{var}{rootpass}, "crypt");
if (any { /^rootpw/ } cat_($LDAPCONF)) {
substInFile {
#s/rootpw.*/rootpw $cryptpass/;
@@ -279,7 +279,7 @@ EOF
sub init_ldap {
- my $root_cn = (split('=', (split(/,/, $o->{var}{rootdn}))[0]))[1];
+ my $_root_cn = (split('=', (split(/,/, $o->{var}{rootdn}))[0]))[1];
my $ldap_dc = (split('=', (split(/,/, $o->{var}{suffix}))[0]))[1];
$o->{var}{rootdn} =~ /cn=(\w+),/ and my $cnadmin = $1;
@@ -327,12 +327,12 @@ RootLdif
sub do_it_user_add {
return if $::testing;
- my $ldap = ldap_connect($o);
- my $mesg = add_user($o);
+ my $_ldap = ldap_connect($o);
+ my $_mesg = add_user($o);
}
sub do_it_modif {
- my $mesg = modif_krb5($o);
+ modif_krb5($o);
}
sub new {
diff --git a/ldap_wizard/ldapdef.pm b/ldap_wizard/ldapdef.pm
index 3d44005b..c68e2eb7 100644
--- a/ldap_wizard/ldapdef.pm
+++ b/ldap_wizard/ldapdef.pm
@@ -91,30 +91,29 @@ if (-f $conf_file) {
}
# Connect to Ldap server
-sub ldap_connect {
-
- my $cnx= Net::LDAP->new($o->{var}{srv}) or die "Impossible de se connecter au server";
+sub ldap_connect() {
+ Net::LDAP->new($o->{var}{srv}) or die "Impossible de se connecter au server";
}
# bind root
-sub root_bind{
+sub root_bind {
my ($ldap) = @_;
- #my $mesg=$ldap->bind(dn =>"cn=".$o->{var}{rootdn}.",".$o->{var}{suffix},password =>$o->{var}{rootpass});
- my $mesg=$ldap->bind(dn =>$o->{var}{rootdn},password =>$o->{var}{rootpass});
+ #my $mesg=$ldap->bind(dn => "cn=" . $o->{var}{rootdn} . "," . $o->{var}{suffix}, password => $o->{var}{rootpass});
+ my $mesg=$ldap->bind(dn => $o->{var}{rootdn},password => $o->{var}{rootpass});
print ldap_error_text($mesg->code);
return $mesg->code;
}
-sub anonymous_bind{
+sub anonymous_bind {
my ($ds) = @_;
my $mesg=$ds->bind;
return $mesg->code;
}
-sub ldap_search{
- my ($ds,$filter,$basedn) = @_;
- my $attrs =['objectClass'];
+sub ldap_search {
+ my ($ds, $filter, $basedn) = @_;
+ my $attrs = ['objectClass'];
my $mesg = $ds->search(
base => $basedn,
filter => $filter,
@@ -123,11 +122,11 @@ sub ldap_search{
);
my $href = $mesg->as_struct;
print("Results of the query\n");
- print "$href";
+ print $href;
}
-sub get_dn{
- my ($ds,$filter,$basedn,$attrs) = @_;
+sub get_dn {
+ my ($ds, $filter, $basedn, $_attrs) = @_;
my $mesg = $ds->search(
base => $basedn,
filter => $filter,
@@ -141,16 +140,15 @@ sub get_dn{
return $mesg
}
-sub get_dse {
-
+sub get_dse() {
my $ldap = ldap_connect();
- my $result = get_dn($ldap,"(objectclass=organization)","$cfg{'base'}");
+ my $result = get_dn($ldap, "(objectclass=organization)", $cfg{base});
my @arrayOfDNs = $result->entries;
#my %ldap = ();
foreach my $dn_value (@arrayOfDNs)
{
my $orga = $dn_value->dn;
- $ldap{'orga'} = $orga;
+ $ldap{orga} = $orga;
}
return %ldap;
}
@@ -162,7 +160,7 @@ sub add_user {
my $result = $ldap->add(
"uid=$u->{var}{uid},$u->{var}{defou},$u->{var}{suffix}",
attr => [
- objectclass => ["top","posixAccount","inetOrgPerson","shadowAccount"],
+ objectclass => ["top", "posixAccount", "inetOrgPerson", "shadowAccount"],
sn => $u->{var}{sn},
uid => $u->{var}{uid},
cn => $u->{var}{cn},
@@ -189,11 +187,11 @@ sub modif_krb5 {
my $result = $ldap->modify(
"uid=$u->{var}{uid},$u->{var}{defou},$u->{var}{suffix}",
changes => [
- replace => [objectClass => ['inetOrgPerson', 'posixAccount', 'shadowAccount','krb5Principal']],
- replace => [ userPassword => 'EROS '],
+ replace => [ objectClass => [ 'inetOrgPerson', 'posixAccount', 'shadowAccount', 'krb5Principal' ] ],
+ replace => [ userPassword => 'EROS ' ],
add => [krb5PrincipalName => $u->{var}{uid}],
]
);
- $result->code && die "failed to add entry: ", $result->error ;
+ $result->code and die "failed to add entry: ", $result->error;
return 1;
}