* Tue Aug 13 2024 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-9.sme

-  use esmith::util:ldap to manipulate ldap entries [SME: 12687]
This commit is contained in:
2024-08-13 17:42:52 -04:00
parent e61e1a8096
commit f99cce8bae
3 changed files with 29 additions and 84 deletions

View File

@@ -28,8 +28,9 @@ use strict;
use Errno;
use esmith::ConfigDB;
use esmith::util;
use Net::LDAP;
use esmith::AccountsDB;
use utf8;
use esmith::util::ldap;
my $adb = esmith::AccountsDB->open_ro();
@@ -41,22 +42,8 @@ unless ($conf->get('ldap')->prop('status') eq "enabled" )
exit(0);
}
my $domain = $conf->get('DomainName')
|| die("Couldn't determine domain name");
$domain = $domain->value;
# prepare LDAP bind
my $pw = esmith::util::LdapPassword();
my $base = esmith::util::ldapBase ($domain);
my $ldap = Net::LDAP->new('localhost')
or die "$@";
$ldap->bind(
dn => "cn=root,$base",
password => $pw
);
my $ldap=esmith::util::ldap->new();
my $event = $ARGV [0];
my $ibay = $ARGV [1];
@@ -88,10 +75,10 @@ if ( "$ldapauth" ne "enabled" )
}
}
my $result = $ldap->delete("uid=$ibay,ou=Users,$base");
$result->code && ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to delete (ldap) ibay account $ibay.\n" );
my $result = $ldap->ldapdeluser($ibay);
$result && ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to delete (ldap) ibay account $ibay.\n" );
$result = $ldap->delete("cn=$ibay,ou=Groups,$base");
$result->code && ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to delete (ldap) group account $ibay.\n" );
$result = $ldap->ldapdelgroup($ibay);
$result && ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to delete (ldap) group account $ibay.\n" );
exit $x