36 lines
791 B
PHP
36 lines
791 B
PHP
<?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();
|
|
}
|
|
}
|
|
}
|