Skip to Content
Programming Jabber
book

Programming Jabber

by DJ Adams
January 2002
Beginner
480 pages
13h 15m
English
O'Reilly Media, Inc.
Content preview from Programming Jabber

Looking at ldapr Step by Step

Taking the script step by step, we start on familiar ground:

use strict;
use Jabber::Connection;
use Jabber::NodeFactory;
use Jabber::NS qw(:all);
use Net::LDAP;

my $ldapsrv = 'cicero';
my $basedn  = 'dc=demo,dc=org';

After declaring the modules we want to use (the only one we haven’t seen so far is the Net::LDAP module that we’ll need to connect to and query an LDAP server), we define a couple of variables. $ldapsrv is the name of the LDAP server that ldapr is going to be reflecting, and $basedn is the base distinguished name that will be used as the suffix in all of the LDAP queries.

If you don’t have an LDAP server of your own, a number of public ones are available that you could point this script at. The two variables $ldapsrv and $basedn go together—make sure you specify the correct base DN for the LDAP server you want to reflect.

Note

Depending on the configuration, some LDAP servers will require you to bind to them with a username and password before you can perform searches. To do this, you’ll need to include an extra step in this script, using the bind() method in Net::LDAP.

Having opened our connection to the LDAP server:

my $ldap = Net::LDAP->new($ldapsrv) or die $@;

we then proceed to connect to the Jabber server as a component. We’re connecting to localhost:9389, which means this component script is going to run on the same host as the Jabber server, and connect to it on port 9389:

debug("connecting to Jabber"); my $c = new Jabber::Connection( ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Professional XMPP Programming with JavaScript® and jQuery

Professional XMPP Programming with JavaScript® and jQuery

Jack Moffitt
Hacking Web Performance

Hacking Web Performance

Maximiliano Firtman

Publisher Resources

ISBN: 0596002025Errata Page