Archived
1
0

Fix LDAP search

This commit is contained in:
Mercier Pierre-Olivier 2013-11-15 12:40:29 +01:00
parent 984cb050fa
commit 2f6b3a9812
2 changed files with 8 additions and 5 deletions

View File

@ -189,6 +189,9 @@ sub get_dn($$@)
my $ldap = shift // ldap_connect();
my $dn = shift;
my $base = BASE_DN;
$dn = "$dn," . BASE_DN if ($dn !~ /$base$/);
my $mesg = $ldap->search( # search
base => "$dn",
filter => Net::LDAP::Filter->new("(objectClass=*)"),

View File

@ -266,7 +266,7 @@ sub cmd_account_create($@)
my $ldap = LDAP::ldap_connect();
# Check if the OU exists
my $oudn = "ou=$group,ou=users,dc=acu,dc=epita,dc=fr";
my $oudn = "ou=$group,ou=users";
my $ou = LDAP::get_dn($ldap, $oudn);
if (! $ou)
@ -841,7 +841,7 @@ sub cmd_groups($@)
if ($gname && $gname =~ /^(2[0-9]{3})$/)
{
$ou = "year=$1,$ou";
$ou = "ou=$1,$ou";
$gname = shift;
}
@ -1048,7 +1048,7 @@ sub cmd_group_create
log(DEBUG, "Adding dn: cn=$gname,ou=intra,ou=groups,dc=acu,dc=epita,dc=fr ...");
my $dn = "cn=$gname,$ou,dc=acu,dc=epita,dc=fr";
my $dn = "cn=$gname,$ou";
my $class;
$class = "intraGroup" if ($ou ne $group_types{system});
@ -1060,7 +1060,7 @@ sub cmd_group_create
};
log(ERROR, $@) if ($@);
my $mesg = $ldap->add( $dn,
my $mesg = $ldap->add( $dn . ",dc=acu,dc=epita,dc=fr",
attrs => [
objectclass => [ "top", $class ],
cn => $gname,
@ -1084,7 +1084,7 @@ sub cmd_group_delete(@)
my $ou = shift;
my $gname = shift;
my $dn = "cn=$gname,$ou,dc=acu,dc=epita,dc=fr";
my $dn = "cn=$gname,$ou";
log(DEBUG, "Deleting dn: $dn ...");