Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

output formatting
Hi all,=20

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:uid@homeMachine=20
uid2:uid2@homeMachine=20
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.

Cheers,

Matthew

Report this thread to moderator Post Follow-up to this message
Old Post
Matthew Woolnough
05-20-05 09:06 AM


Re: output formatting
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:uid@homeMachine
> uid2:uid2@homeMachine
> 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 li
ke:

#!/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";
}
}

Report this thread to moderator Post Follow-up to this message
Old Post
Elliot Foster
05-24-05 01:59 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

LDAP archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 09:56 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.