Hi,

Well, a full-fledged LDAP client on the web is actually different, but I arranged a 
quick-and-dirty stuff to allow IMail web-users to have local addresses at hand.
Actually, using IMail's web access you have no info about users of local servers. This 
is not a problem for ISPs (privacy first), but for a regular Company it is a big one, 
since one has to correspond with hundreds (sometimes thousands) individuals.
Tha trick I arranged is quite simple. Just get local addresses out of somewhere and 
add them to relevant IMail web templates, along with personal address list, for 
selection in mail messages.
Where can we get information from? personal data (tipically name and email) are stored 
in LDAP tables, which are binary files. Since Uncle Bill didn't think about, we need 
something to get the data out of that tables, format them in HTML form and write them 
back to templates. Better using UNIX (Linux actually) for this...
OK. Relevant data are stored in file LDAP\PERSON.DTA under IMail root. We perform, 
with a .CMD script, the following actions:
1 - Copy this binary file to a UNIX host with an ftp script (or other command 
depending on servers capabilities. CAVEAT: check protections and rights to avoid 
troubles!);
2 - Get data in ASCII form with UNIX' string command;
3 - Parse above data rsh-ing a perl script to create an HTML  list, with line items 
readable such as "LOCAL: Gates, Bill ";
4 - Get back the list on STDIN;
5 - Include it in relevant templates (fwdmsg1.html, replymsg1.html, sendmail.html in 
Web directiory under IMail root).
Inclusion in html templates is done by splitting original templates in two parts, 
right at the point where Address Book is included, and typing them back along with 
runtime-generated list to final template.
Therefore, users see in their list all local accounts (identified by a label such as 
"LOCAL: " preceding name and email), may select as recipients but cannot cancel or 
modify them.
CMD file is to be included in AT scheduling on IMail NT server twice a day or more, 
depending on change rate in your users population, to keep the list up-to-date.
Absolutely brutal and stinking, but works. Waiting for a better, IPwitch-supplied 
solution.
Hope this helps. Relevant files included.

        Ciao
        Luca Salvadori
        Information Systems
        LABEN S.p.A.
        Milan - Italy

P.S. Just in case of doubt: Yes, I DO prefer Unix over NT...


+++++ LIST OF FILES +++++
LOCALIST.CMD - DOS batch triggering the whole stuff
TOHOST.FTP - ftp script to transfer LDAP file to UNIX host
localist.pl - Perl script performing the task
fwdmsg1_1of2.html - Part one of fwdmsg1.html template (attachment)
fwdmsg1_2of2.html - Part two of fwdmsg1.html template (attachment)
replymsg1_1of2.html - Part one of replymsg1.html template (attachment)
replymsg1_2of2.html - Part two of replymsg1.html template (attachment)
sendmail_1of2.html - Part one of sendmail.html template (attachment)
sendmail_2of2.html - Part two of sendmail.html template (attachment)
+++++ END OF LIST OF FILES +++++

+++++ LOCALIST.CMD +++++
@echo off
REM LOCALIST.CMD
REM This batch file sends an LDAP library containing local email addresses
REM to a UNIX server, which performs some parsing and sends back on stdout 
REM a list of email addresses and names to be used in IMail. Format is
REM compliant with regular IMail's aliases.txt file.
REM Finally, the received list is joined with IMail html templates
REM to add local addresses to personal address lists.
REM The stuff is a workaround to offer local addresses list to IMail's
REM WebAccess users, which are (so far) unable to use IMail's LDAP
REM features.
REM 
REM LABEN S.p.A. - Oct 1999
REM

REM Moving to the relevant directory of IMail
D:
cd \imail
REM Sending LDAP file to server through an ftp command file
ftp -vn < tohost.ftp
REM Moving to html templates directory
cd web
REM Invoking remote utility via rsh
rsh myunixhost -l myuser "/mypath/localist.pl /wherever/PERSON.DTA" > MYADDR.TXT
REM Now recreate relevant templates. Affected files are:
REM     fwdmsg1.html = fwdmsg1_1of2.html + MYADDR.TXT + fwdmsg1_2of2.html
REM     replymsg1.html = replymsg1_1of2.html + MYADDR.TXT + replymsg1_2of2.html
REM     sendmail.html = sendmail_1of2.html + MYADDR.TXT + sendmail_2of2.html
IF EXIST MYADDR.TXT type fwdmsg1_1of2.html MYADDR.TXT fwdmsg1_2of2.html > fwdmsg1.html
IF EXIST MYADDR.TXT type replymsg1_1of2.html MYADDR.TXT replymsg1_2of2.html > 
replymsg1.html
IF EXIST MYADDR.TXT type sendmail_1of2.html MYADDR.TXT sendmail_2of2.html > 
sendmail.html
REM Cleanup and exit
IF EXIST MYADDR.TXT del MYADDR.TXT
REM exit
+++++ END OF FILE - LOCALIST.CMD +++++

+++++ TOHOST.FTP +++++
open myunixhost.mysite.com
user myuser mypasswd
cd /wherever
binary
put ldap\PERSON.DTA PERSON.DTA
quit
+++++ END OF FILE - TOHOST.FTP +++++

+++++ localist.pl +++++
#!/usr/bin/perl
# FILENAME: localist.pl
# DESCRIPTION: 
# Gets LDAP-formatted data out of a binary LDAP files and turns
# them to HTML <OPTION> list for inclusion in a <SELECT> statement.
#
# USAGE: localist.pl file
#
# LABEN S.p.A. - October, 1999
#
# HISTORY:
# 0.0 Luca Salvadori <[EMAIL PROTECTED]> 03-oct-1999
#       - Functions and behaviour
#
########### S U B R O U T I N E S ###########

# Defining record-separator and catched strings
$PREFIX="LOCAL";
$firstline="^\\[([0-9AF]*)\\]";
$mailstring="^mail=";
$gnstring="^gn=";
$snstring="^sn=";
#
# No user-serviceable parts below. DO NOT EDIT!
#

####### E N D  O F  S U B R O U T I N E S ######

########### M A I N  P R O G R A M ###########

# Here begins the real stuff
#
# Get input file from command line
$infile=$ARGV[0];
# Begin looping over input file. Any line preceding firstline pattern is discard
open (INFILE,"strings $infile | egrep '$firstline|$snstring|$gnstring|$mailstrin
line: while(<INFILE>)
{
        # Striff off EOL character
        chomp;
        # Get relevant variables
        # If first line of block is read, cleanup variables and skip to next one
        if ( $_ =~ "$firstline" )
        {
                # Reset variables
                $mail=$cn=$gn=$sn="";
                next line;
        }
        # Catch relevant strings
        if ( $_ =~ "^mail=" ) { ($dummy,$mail)=split(/=/,$_) }
        if ( $_ =~ "^sn=" ) { ($dummy,$sn)=split(/=/,$_) }
        if ( $_ =~ "^gn=" ) { ($dummy,$gn)=split(/=/,$_) }
        # As soon as we got $mail and $cn=$gn+$sn we may skip to next record
        if ( $mail and $gn and $sn )
        {
                # Print formatted line
                $cn=$gn." ".$sn;
                print "<OPTION Value=\"1\" >\&quot;$PREFIX: $cn\&quot;\&#32;\&lt;$
                # Reset variables
                $ma
Please visit http://www.ipswitch.com/support/mailing-lists.html 
to be removed from this list.

Reply via email to