Server IP : 23.254.227.96 / Your IP : 216.73.216.7 Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64 User : viralblo ( 1001) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /proc/thread-self/root/usr/share/doc/perl-LDAP/contrib/ |
Upload File : |
#!/usr/bin/perl -w # # recursive-ldap-delete.pl # # originally by Mike Jackson <mj@sci.fi> # shortened by Peter Marschall <peter@adpm.de> # based on ideas by Norbert Kiesel <nkiesel@tbdetworks.com> # # ToDo: check errors, handle references, .... use strict; use Net::LDAP; my $server = "localhost"; my $binddn = "cn=directory manager"; my $bindpasswd = "foobar"; my $delbranch = "ou=users,dc=bigcorp,dc=com"; # branch to remove my $ldap = Net::LDAP->new( $server ) or die "$@"; $ldap->bind( $binddn, password => $bindpasswd, version => 3 ); my $search = $ldap->search( base => $delbranch, filter => "(objectclass=*)" ); # delete the entries found in a sorted way: # those with more "," (= more elements) in their DN, which are deeper in the DIT, first # trick for the sorting: tr/,// returns number of , (see perlfaq4 for details) foreach my $e (sort { $b->dn =~ tr/,// <=> $a->dn =~ tr/,// } $search->entries()) { $ldap->delete($e); } $ldap->unbind();