nur-sery/nur_src/ldap/app/LdapDeleteApp.php

36 lines
791 B
PHP
Raw Normal View History

2024-04-04 22:21:20 +04:00
<?php
namespace nur\ldap\app;
use nur\ldap\LdapSearch;
use nur\ldap\LdapWalker;
use nur\log;
class LdapDeleteApp extends LdapApplication {
const ARGS = [
"merge" => parent::ARGS,
["-s", "--scope", "args" => 1],
["-b", "--searchbase", "args" => 1],
["-B", "--searchbase-exact", "args" => 1],
];
protected $scope;
protected $searchbase, $searchbaseExact;
protected $args;
function main() {
$conn = $this->getConn();
$params = [];
LdapSearch::parse_args($params, $this->args
, $this->searchbase, $this->searchbaseExact
, $this->scope);
/** @var LdapWalker $lo */
$lo = $conn->search(null, $params);
while ($lo->next($first)) {
log::action("Suppression $lo[dn]");
$lo->delete();
log::asuccess();
}
}
}