Fix LDAP search
This commit is contained in:
parent
984cb050fa
commit
2f6b3a9812
@ -189,6 +189,9 @@ sub get_dn($$@)
|
|||||||
my $ldap = shift // ldap_connect();
|
my $ldap = shift // ldap_connect();
|
||||||
my $dn = shift;
|
my $dn = shift;
|
||||||
|
|
||||||
|
my $base = BASE_DN;
|
||||||
|
$dn = "$dn," . BASE_DN if ($dn !~ /$base$/);
|
||||||
|
|
||||||
my $mesg = $ldap->search( # search
|
my $mesg = $ldap->search( # search
|
||||||
base => "$dn",
|
base => "$dn",
|
||||||
filter => Net::LDAP::Filter->new("(objectClass=*)"),
|
filter => Net::LDAP::Filter->new("(objectClass=*)"),
|
||||||
|
10
utils/lpt
10
utils/lpt
@ -266,7 +266,7 @@ sub cmd_account_create($@)
|
|||||||
my $ldap = LDAP::ldap_connect();
|
my $ldap = LDAP::ldap_connect();
|
||||||
|
|
||||||
# Check if the OU exists
|
# 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);
|
my $ou = LDAP::get_dn($ldap, $oudn);
|
||||||
|
|
||||||
if (! $ou)
|
if (! $ou)
|
||||||
@ -841,7 +841,7 @@ sub cmd_groups($@)
|
|||||||
|
|
||||||
if ($gname && $gname =~ /^(2[0-9]{3})$/)
|
if ($gname && $gname =~ /^(2[0-9]{3})$/)
|
||||||
{
|
{
|
||||||
$ou = "year=$1,$ou";
|
$ou = "ou=$1,$ou";
|
||||||
$gname = shift;
|
$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 ...");
|
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;
|
my $class;
|
||||||
$class = "intraGroup" if ($ou ne $group_types{system});
|
$class = "intraGroup" if ($ou ne $group_types{system});
|
||||||
@ -1060,7 +1060,7 @@ sub cmd_group_create
|
|||||||
};
|
};
|
||||||
log(ERROR, $@) if ($@);
|
log(ERROR, $@) if ($@);
|
||||||
|
|
||||||
my $mesg = $ldap->add( $dn,
|
my $mesg = $ldap->add( $dn . ",dc=acu,dc=epita,dc=fr",
|
||||||
attrs => [
|
attrs => [
|
||||||
objectclass => [ "top", $class ],
|
objectclass => [ "top", $class ],
|
||||||
cn => $gname,
|
cn => $gname,
|
||||||
@ -1084,7 +1084,7 @@ sub cmd_group_delete(@)
|
|||||||
my $ou = shift;
|
my $ou = shift;
|
||||||
my $gname = 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 ...");
|
log(DEBUG, "Deleting dn: $dn ...");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user