summaryrefslogtreecommitdiffstats
path: root/ldap_wizard
diff options
context:
space:
mode:
Diffstat (limited to 'ldap_wizard')
-rw-r--r--ldap_wizard/ldapdef.pm113
1 files changed, 27 insertions, 86 deletions
diff --git a/ldap_wizard/ldapdef.pm b/ldap_wizard/ldapdef.pm
index c68e2eb7..7a1a6e9e 100644
--- a/ldap_wizard/ldapdef.pm
+++ b/ldap_wizard/ldapdef.pm
@@ -1,77 +1,29 @@
package ldapdef;
use strict;
+use MDK::Wizard::Ldap;
use Net::LDAP;
use Net::LDAP::Util qw(ldap_error_text);
-
-use lib qw(/usr/lib/libDrakX);
-use ugtk2;
-use common;
-use standalone;
-use MDK::Wizard::Varspaceval;
-use MDK::Wizard::Wizcommon;
-use Expect;
+use MDK::Common;
require Exporter;
use vars qw(@ISA @EXPORT %cfg %cfgfile $congfile $msg $attrs %ldap $ldap);
@ISA=qw(Exporter);
-@EXPORT=qw( %cfg %cfgfile $congfile load_config ldap_connect root_bind $msg anonymous_bind ldap_search get_dn $attrs get_dse %ldap add_user modif_krb5);
-
-require Exporter;
-
-
-my $o = {
- name => N("Add POSIX account"),
- var => {
- defou => 'ou=Users',
- srv => '',
- dom => 'mandrakesoft.com',
- suffix => '',
- rootdn => '',
- rootpass => '',
- rootpass2 => '',
- cn => '',
- sn => '',
- uid => '',
- uidpass => '',
- lshell => '/bin/bash',
- home => '/home/',
- uidnb => '1004',
- gidnb => '1004',
- container => 'container',
- objectclass => 'top,account,posixaccount',
- shadowmax => '99999',
- shadowmin => '-1',
- plop => '',
- tmp => '',
- nom => '',
- prenom => '',
- },
- needed_rpm => [ 'squid' ],
- defaultimage => "/usr/share/wizards/proxy_wizard/images/proxy.png"
- };
-
-
-
-
-
-
-
-
+@EXPORT=qw( %cfg %cfgfile $congfile ldap_connect root_bind $msg anonymous_bind ldap_search get_dn $attrs get_dse %ldap add_user);
-
-
-
-my $ldap_suffix=join(',dc=', split(/\./, `hostname -f`));
+my $ldap_suffix=join(',dc=', split(/\./, chomp_(`hostname -f`)));
$ldap_suffix =~ s/[^,]*,//;
my $conf_file = "/etc/sysconfig/ldapconf";
##### Read conf file is exist
my $hostname = `hostname`;
+#my $o = MDK::Wizard::Ldap->new();
+my $o = { var => undef };
$o->{var}{srv} = $hostname;
+print "tot";
if (-f $conf_file) {
@@ -83,25 +35,26 @@ if (-f $conf_file) {
$o->{var}{defou} = $conf{users};
} else {
+ my $hostname = chomp_(`hostname`);
+ $o->{var}{srv} = $hostname;
+ $o->{var}{suffix} = $ldap_suffix;
+}
- my $hostname = `hostname`;
- $o->{var}{srv} = $hostname;
- $o->{var}{suffix} = $ldap_suffix;
-}
# Connect to Ldap server
-sub ldap_connect() {
+sub ldap_connect {
+ my ($u) = @_;
+ print $u;
+ print " $u->{var}{srv}\n";
Net::LDAP->new($o->{var}{srv}) or die "Impossible de se connecter au server";
+
}
# bind root
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});
- print ldap_error_text($mesg->code);
- return $mesg->code;
+ $ldap->bind(dn => $o->{var}{rootdn},password => $o->{var}{rootpass});
}
@@ -121,12 +74,12 @@ sub ldap_search {
attrs => $attrs
);
my $href = $mesg->as_struct;
- print("Results of the query\n");
+ print("Résultats de la recherchei\n");
print $href;
}
sub get_dn {
- my ($ds, $filter, $basedn, $_attrs) = @_;
+ my ($ds, $filter, $basedn, $attrs) = @_;
my $mesg = $ds->search(
base => $basedn,
filter => $filter,
@@ -141,6 +94,7 @@ sub get_dn {
}
sub get_dse() {
+
my $ldap = ldap_connect();
my $result = get_dn($ldap, "(objectclass=organization)", $cfg{base});
my @arrayOfDNs = $result->entries;
@@ -168,7 +122,7 @@ sub add_user {
loginShell => $u->{var}{lshell},
uidNumber => $u->{var}{uidnb},
gidNumber => $u->{var}{gidnb},
- homeDirectory => $u->{var}{home}.$u->{var}{uid},
+ homeDirectory => $u->{var}{home} . $u->{var}{uid},
shadowMin => '-1',
shadowMax => '999999',
shadowWarning => '7',
@@ -176,22 +130,9 @@ sub add_user {
shadowExpire => '-1',
]
);
- #print ldap_error_text($result->code);
- return $result->code;
-}
-
-sub modif_krb5 {
- my ($u) = @_;
- my $ldap = ldap_connect();
- root_bind($ldap);
- my $result = $ldap->modify(
- "uid=$u->{var}{uid},$u->{var}{defou},$u->{var}{suffix}",
- changes => [
- replace => [ objectClass => [ 'inetOrgPerson', 'posixAccount', 'shadowAccount', 'krb5Principal' ] ],
- replace => [ userPassword => 'EROS ' ],
- add => [krb5PrincipalName => $u->{var}{uid}],
- ]
- );
- $result->code and die "failed to add entry: ", $result->error;
- return 1;
-}
+ print ldap_error_text($result->code);
+# return $result->code;
+ use lib qw(/usr/lib/libDrakX);
+ use standalone;
+ use ugtk2 qw(:ask :helpers :wrappers :create :dialogs);
+ create_dialog("Add user in OpenLDAP server", ldap_error_text($result->code)) }