/usr/bin/ldap2netgroup is in debian-edu-config 1.818+deb8u2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #!/usr/bin/perl
#
# Tool to export netgroups from LDAP to /etc/netgroup format.
use strict;
use warnings;
use Net::LDAP;
use Debian::Edu;
use vars qw($ldaphost $base $debug);
$debug = 0;
$ldaphost = $ARGV[0] || find_ldap_server() || 'ldap';
$base = $ARGV[1] || find_ldap_base($ldaphost)
|| 'dc=skole,dc=skolelinux,dc=no';
my $ldap = new Net::LDAP($ldaphost)
|| die "Unable to connect to LDAP host '$ldaphost'";
my $mesg = $ldap->bind ; # as anonymous
die("Unable to bind anonymously: $mesg->error") unless ( 0 == $mesg->code );
$mesg = $ldap->search( base => $base,
filter => '(objectClass=nisNetgroup)' );
$mesg->code && die $mesg->error;
foreach my $entry ($mesg->all_entries) {
my $name = $entry->get_value("cn");
print "$name";
map { print " $_" } $entry->get_attribute("memberNisNetgroup");
map { print " $_" } $entry->get_attribute("nisNetgroupTriple");
print "\n";
$entry->dump if $debug;
}
$ldap->unbind; # take down session
|