in reply to Re: Encrypt File while sending
in thread Encrypt File while sending
I run the command like this : perl report.pl > report.csv Thanks, Pamela#!/usr/bin/perl use Net::LDAP; @fields = # fields to expo +rt ( # Label Field Name Index ['UID','uid',0], ['mail','mail',0], ['OtherPhone','OtherPhone',0], ['mobile','mobile',0], ['givenName','givenName',0], ['Initials','initials',0], ['sn','sn',0], ['c','c',0], ); $ldap = Net::LDAP->new('hostname:port') or die "$@"; # open conne +ction $mesg = $ldap->bind( # login "cn=Directory Manager", password => "$$$$$$$$$$$"); $mesg = $ldap->search( # search base => "dc=xyz,dc=com", filter => "(&(objectClass=*)(!(c=US))(uid=*))" ); $DATETIME=`date`; sub get # get field valu +e { return $_[0]->exists($_[1]) ? $_[0]->get($_[1])->[$_[2] ? $_[2] : 0] : ''; } print "$DATETIME"; # first line with file created date/ +time print '"'.(join '","', "Report", # header map {$_->[0]} @fields)."\"\n"; foreach $entry ($mesg->all_entries) # for each entry { @dn = map {s/[a-z]+=//gi; $_ = ucfirst} # organization reverse split /,/, $entry->dn; shift @dn; shift @dn; shift @dn; pop @dn; print '"'.(join '","', "@dn", # row map {get $entry, $_->[1], $_->[2]} @fields)."\"\n"; } $mesg = $ldap->unbind; # close connecti +on
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Encrypt File while sending
by Utilitarian (Vicar) on Aug 20, 2009 at 22:31 UTC |