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

36 lines
803 B
PHP

<?php
namespace nur\ldap\app;
use nur\ldap\LdapSearch;
use nur\ldap\LdapWalker;
use nur\sery\output\msg;
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)) {
msg::action("Suppression $lo[dn]");
$lo->delete();
msg::asuccess();
}
}
}