|
|
Using Net:LDAP
We use OpenLDAP in a Linux environment, but I suspect that the Perl-LDAP modules will work just fine under Mac OS X. Using the modules makes manipulating LDAP data very easy. For example, here is a simple script I wrote to create a flat passwd file:
#!/usr/bin/perl
use Net::LDAP;
$ldap = Net::LDAP->new("localhost");
$ldap->bind("cn=admin,dc=domain,dc=com", password=>"secret");
$mesg = $ldap->search(filter=>"(objectclass=posixAccount)", base=>"ou=people,dc=domain,dc=com");
@entries = $mesg->entries;
foreach $entry (@entries) {
$username = $entry->get_value(uid);
$uidnumber = $entry->get_value(uidNumber);
$gidnumber = $entry->get_value(gidNumber);
$gecos = $entry->get_value(gecos);
$homedir = $entry->get_value(homeDirectory);
$shell = $entry->get_value(loginShell);
print "$username:x:$uidnumber:$gidnumber:$gecos:$homedir:$shell\n";
}
escape char got snarfed
an escape character got snarfed, the print statement at the end should have a backslash before the n. Hopefully it won't get stripped again: |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.08 seconds |
|