Skip to content

Instantly share code, notes, and snippets.

@m4ldonado
Created March 4, 2018 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m4ldonado/a8016c7a17dff00f13e440e90b1526f4 to your computer and use it in GitHub Desktop.
Save m4ldonado/a8016c7a17dff00f13e440e90b1526f4 to your computer and use it in GitHub Desktop.
search ldap with perl
#!/usr/bin/perl
use Net::LDAP;
$ldap_url = '';
$ldap_base_dn = '';
$ldap = Net::LDAP->new($ldap_url);
$mesg = $ldap->bind;
$mesg = $ldap->search(
base => $ldap_base_dn,
filter => "cn=*"
);
$mesg->code && die $mesg->error;
foreach $entry($mesg->entries){
foreach my $attr ( $entry->attributes ) {
print join( "\n ", $attr, $entry->get_value( $attr ) ), "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment