Matthew Woolnough wrote:
Hi all,
Im trying to get a dump of all users uids and homeMachine in our
people OU in a flat file for a legacy app in the format of:
uid:[EMAIL PROTECTED]
uid2:[EMAIL PROTECTED]
and so on.....
Ive stumbled across this module, and I'm guessing it might help me in
my quest. Im not well versed in Perl.
Any ideas would be greatly appreciated.
It'd be a pretty standard script, but if you say you are not well versed in
perl, you may want to look elsewhere. Here's something of what it'd look like:
#!/usr/bin/perl -Tw
use strict;
use Net::LDAP qw(:all);
my $ldhost = 'ldap.some.org'; # your ldap host here
my $ldh = Net::LDAP->new($ldhost) or die "Error in connection!\n";
my $bind = $ldh->bind() or die "Error in bind!\n";
die "Error ", $bind->code, ": ", $bind->error, "\n" if $bind->code;
my $search = $ldh->search(
base=>"ou=people,dc=some,dc=org", # path to your ou=people here
scope=>'sub',
filter=>'(uid=*)', # or some other filter like '(homeMachine=*)'
attrs=>['dn', 'uid', 'homeMachine']
) or die "Error in search!\n";
if ($search->code) {
die "Err ", $search->code, " in search: ", $search->error, "\n";
}
# this assumes uid and homeMachine are single-valued attributes
for my $entry ($search->entries) {
my $uid = $entry->get_value('uid') || '';
my $machine = $entry->get_value('homeMachine') || '';
if ($uid && $machine) {
print $uid, ":", $uid, "@", $machine, "\n";
} else {
print STDERR "problem with DN: ", $entry->dn, "\n";
}
}