#!perl # # makeaddrbook for squirrelmail # # change the ldapsrv variable, pipe it to global.abook and # copy it to where your global.abook lives. And, change # the other occurance of yourdomain.com in the # (mail=*yourdomain.com) search string to match # your mocal mail domain. # use Net::LDAP; $ldapsrv = "exchange.yourdomain.com"; $ldap = Net::LDAP->new($ldapsrv) or die "$@"; $mesg = $ldap->bind; $mesg = $ldap->search( base => "c=US", filter => "(& (mail=*yourdomain.com)(objectclass=person))", attrs => ['cn', 'mail'] ); $mesg->code && die $mesg->error; foreach $entry ($mesg->entries) { #print "DN: ", $entry->dn, "\n"; #$entry->dump; my $attr; my $line; my @results; foreach $attr ( $entry->attributes ) { next if ( $attr =~ /;binary$/ ); $val = $entry->get_value ( $attr ); next if ( $val =~ /^SMEX/ ); push @results, $val; #print " $attr : ", $entry->get_value ( $attr ) ,"\n"; } my ($gn,$sn) = split(/\s/,$results[0],2); $line = join ("|", $results[0], $gn, $sn, $results[1]); unless ($line =~ /\|\|\|/) { push @addresses, $line; } } $mesg = $ldap->unbind; @addresses = sort @addresses; foreach $line (@addresses) { print "$line\n"; }

In reply to Exchange to Squirrelmail Global Address Book by BravoTwoZero

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.