From: Graham B. <gb...@po...> - 2001-04-05 12:43:33
|
----- Forwarded message from Ian Taite <it...@na...> ----- Date: Thu, 5 Apr 2001 12:55:34 +0100 To: "'gb...@po...'" <gb...@po...> From: Ian Taite <it...@na...> Subject: Perl-LDAP on Win32 targetting Exchange 5.5 X-Mailer: Internet Mail Service (5.5.2653.19) Try as I might, I cannot get my script to work - I just cannot find enough good examples to get a grip of how to get this done. What I want to do is read the global address list to produce a phone directory comprising users first name, last name, title, email address, phone number and mobile number. My script is incomplete, but produces no errors and no results. Do you know where I can get an example of what I want to do? I can only find examples based on ADSI or that create mailboxes, and I dont seem to be able to grasp it from those examples. My feeble script is below. Many thanks, Ian. use Net::LDAP; use Net::LDAP::LDIF; $server="172.16.1.15"; # IP ADDRESS OF EXCHSH01 Exchange box $port=389; $c = Net::LDAP->new($server, port=>$port, diag=>1) or die "Unable to connect to server $server: $@\n"; # Anonymous bind $c->bind() or die "Unable to bind: $@\n"; $basedn="cn=Recipients,ou=Altrincham,o=NavTrak Limited,c=GB"; $scope="base"; $filter="(objectClass=organizationalPerson)"; $searchobj = $c->search(base=>$basedn,scope=>$scope,filter=>$filter,0,"mail"); die "Bad search, errorcode #".$searchobj->code() if $searchobj->code(); $ldif = new Net::LDAP::LDIF("-"); $ldif->write($searchobj->entries()); $ldif->done(); # Disconnect from the LDAP server $c->unbind(); **************************************************************************** Note **************************************************************************** The information in this Email message, and any files transmitted with it, are confidential and intended only for use of the individual or entity named as recipient. If the reader of this message is not the intended recipient you are hereby notified that any dissemination, processing, distribution or copy of this material is strictly prohibited. If you have received this Email in error, please immediately notify our network manager on the telephone number below and delete the message. Your co-operation is appreciated. Any personal opinions expressed in this message are those of the sender and should not be taken as representing the views of ITIS Holdings. **************************************************************************** Contact Details ITIS Holdings The Warrant House 1 The High Street Altrincham WA14 1PZ Telephone - (44) 161 929 5788 ----- End forwarded message ----- |
From: Gordon J. <gor...@cp...> - 2001-04-05 13:09:30
|
The scope in your search should be either 'one' or 'sub'; 'base' will only read read your searchbase entry. -- gj > -----Original Message----- > From: per...@li... > [mailto:per...@li...]On Behalf Of Graham > Barr > Sent: Thursday, April 05, 2001 8:43 am > To: LDAP Mailing List > Cc: Ian Taite > Subject: [Fwd] Perl-LDAP on Win32 targetting Exchange 5.5 > > > ----- Forwarded message from Ian Taite <it...@na...> ----- > > Date: Thu, 5 Apr 2001 12:55:34 +0100 > To: "'gb...@po...'" <gb...@po...> > From: Ian Taite <it...@na...> > Subject: Perl-LDAP on Win32 targetting Exchange 5.5 > X-Mailer: Internet Mail Service (5.5.2653.19) > > Try as I might, I cannot get my script to work - I just cannot find enough > good examples to get a grip of how to get this done. > > What I want to do is read the global address list to produce a phone > directory comprising users first name, last name, title, email address, > phone number and mobile number. > > My script is incomplete, but produces no errors and no results. > > Do you know where I can get an example of what I want to do? I > can only find > examples based on ADSI or that create mailboxes, and I dont seem > to be able > to grasp it from those examples. > > My feeble script is below. > Many thanks, > Ian. > > use Net::LDAP; > use Net::LDAP::LDIF; > > $server="172.16.1.15"; # IP ADDRESS OF EXCHSH01 Exchange box > $port=389; > > $c = Net::LDAP->new($server, port=>$port, diag=>1) or die "Unable > to connect > to server $server: $@\n"; > > # Anonymous bind > $c->bind() or die "Unable to bind: $@\n"; > > $basedn="cn=Recipients,ou=Altrincham,o=NavTrak Limited,c=GB"; > $scope="base"; > $filter="(objectClass=organizationalPerson)"; > > $searchobj = > $c->search(base=>$basedn,scope=>$scope,filter=>$filter,0,"mail"); > > die "Bad search, errorcode #".$searchobj->code() if $searchobj->code(); > > > $ldif = new Net::LDAP::LDIF("-"); > $ldif->write($searchobj->entries()); > $ldif->done(); > > # Disconnect from the LDAP server > $c->unbind(); > > > > > ****************************************************************** > ********** > Note > ****************************************************************** > ********** > > The information in this Email message, and any files transmitted with it, > are confidential and intended only for use of the individual or > entity named > as recipient. If the reader of this message is not the intended recipient > you are hereby notified that any dissemination, processing, > distribution or > copy of this material is strictly prohibited. If you have received this > Email in error, please immediately notify our network manager on the > telephone number below and delete the message. Your co-operation is > appreciated. > > Any personal opinions expressed in this message are those of the > sender and > should not be taken as representing the views of ITIS Holdings. > > ****************************************************************** > ********** > Contact Details > > ITIS Holdings > The Warrant House > 1 The High Street > Altrincham > WA14 1PZ > > Telephone - (44) 161 929 5788 > > > ----- End forwarded message ----- > |