3 # This is very simple method to get data from LDAP and
4 # converts it to abook readable format.
5 # Script get only first email of any person. This is, probably,
7 # If you have better/simpler method - send me, please.
9 # You MUST have ldap-utils installed on your system to
10 # use this script. Without ldapsearch script does not work!
12 # Author: Mariusz Balewski <M.Balewski@wp.pl>
16 # Feel free to send me your comments
18 # I'm not programmer, so REMEMBER:
19 # YOU USE THIS SCRIPT ON YOUR OWN RISK!!!
22 # Change this section to your local settings
27 $BASEDN="\"-b ou=example,dc=com\"";
29 # dn which contains email addresses
32 # for example "-D \"cn=admin,dc=com\"" (if needed)
35 # ldap password (if needed), or -w to force script
36 # to password prompting
39 # use -x if your ldaphost accept simple authentication
43 # Where you want to put results?
44 # In this example results will be putted to
45 # your home directory, to abookFromLDAP file.
46 # If you wish to use abook with this file, simply run:
47 # abook --datafile $HOME/abookFromLDAP
48 $DESTFILE="$ENV{'HOME'}/abookFromLDAP";
50 # If you wish to see communiats in english or polish
51 # link comms.pl-en to comms.pl to english or
52 # comms.pl-pl to polish
54 # End of configuration
55 ###############################
56 ###############################
60 system("ldapsearch -h $HOST $SIMPLEAUTH $AUTHDN $PASS \"$FINDDN=*\" $BASEDN -LLL > /tmp/ldap2abook.tmp");
63 open(F1,"</tmp/ldap2abook.tmp") || die "$TMPERR";
64 open(F2,">$DESTFILE") || die "$DESTFILEERR";
68 if ($_ =~ m/^gecos/g){
75 elsif ($_ =~ m/^mail/g){
85 system("rm /tmp/ldap2abook.tmp");