Andrew Findlay > Data-Toolkit-1 > Data::Toolkit::Connector::LDAP

Download:
Data-Toolkit-1.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.0   Source   Latest Release: Data-Toolkit-1.1

NAME ^

Data::Toolkit::Connector::LDAP

DESCRIPTION ^

Connector for LDAP directories.

SYNOPSIS ^

   $ldapConn = Data::Toolkit::Connector::LDAP->new();

   $ldap = Net::LDAP->new( 'ldap.example.org' ) or die "$@";
   $mesg = $ldap->bind;

   $ldapConn->server( $ldap );

   $ldapConn->add( $entry );

   $hashref = $ldapConn->searchparams( { base => "dc=example,dc=org", scope => "sub" } );
   $hashref = $ldapConn->filterspec( '(sn=Beeblebrox)' );

   $msg = $ldapConn->search();
   $msg = $ldapConn->search( $entry );

   $msg = $ldapConn->delete( $entry );

DEPENDENCIES ^

   Carp
   Clone
   Net::LDAP

Constructor ^

new

   my $ldapConn = Data::Toolkit::Connector::LDAP->new();

Creates an object of type Data::Toolkit::Connector::LDAP

Methods ^

server

Define the LDAP server for the connector to use. This should be an object of type Net::LDAP

   my $res = $csvConn->server( Net::LDAP->new('ldap.example.org') );

Returns the object that it is passed.

add

Add an entry to the LDAP directory

   $msg = $ldapConn->add( $entry );

Retruns the Net::LDAP::Message object from the add operation.

The entry must contain attributes as follows:

_dn

The DN of the entry to be created (single value)

objectClass

A list of objectClasses describing the entry

In addition, the entry must contain all the mandatory attributes for the selected objectClasses. The attribute-value pair used as the RDN must be included.

All attributes in the entry whose names do not start with an underscore will be placed in the LDAP entry.

delete

Delete an entry from the LDAP directory

   $msg = $ldapConn->delete( $entry );

Retruns the Net::LDAP::Message object from the add operation.

The entry must contain an attribute called _dn containing a single value: the DN of the LDAP entry that you want to delete.

searchparams

Supply or fetch search parameters

   $hashref = $ldapConn->searchparams();
   $hashref = $ldapConn->searchparams( { base => "dc=example,dc=org", scope => "sub" } );

filterspec

Supply or fetch filterspec

   $hashref = $ldapConn->filterspec();
   $hashref = $ldapConn->filterspec( '(sn=Beeblebrox)' );

search

Search the LDAP directory. If an entry is supplied, attributes from it may be used in the search.

   $msg = $ldapConn->search();
   $msg = $ldapConn->search( $entry );

Returns the Net::LDAP::Message object from the search operation.

next

Return the next entry from the LDAP search as a Data::Toolkit::Entry object. Optionally apply a map to the LDAP data.

Updates the "current" entry (see "current" method description below).

   my $entry = $ldapConn->next();
   my $entry = $ldapConn->next( $map );

The result is a Data::Toolkit::Entry object if there is data left to be read, otherwise it is undef.

current

Return the current entry in the list of search results as a Data::Toolkit::Entry. The current entry is not defined until the "next" method has been called after a search. Alternatively the current entry can be set by passing a Net::LDAP::Entry object to this method.

   $entry = $ldapConn->current();
   $entry = $ldapConn->current( $newEntry );

NOTE: if you intend to modify the returned entry you should clone it first, as it is a reference to the connector's copy.

update

Update the current LDAP entry using data from a source entry and an optional map. If no map is supplied, all attributes in the source entry are updated in the LDAP entry.

If a map is supplied then any attribute listed in the map but not in the source entry will be deleted from the current entry in LDAP.

Returns the Net::LDAP::Message result of the LDAP update operation.

   $msg = $ldapConn->update($sourceEntry);
   $msg = $ldapConn->update($sourceEntry, $updateMap);

Debugging methods ^

debug

Set and/or get the debug level for Data::Toolkit::Connector

   my $currentDebugLevel = Data::Toolkit::Connector::LDAP->debug();
   my $newDebugLevel = Data::Toolkit::Connector::LDAP->debug(1);

Any non-zero debug level causes the module to print copious debugging information.

Note that this is a package method, not an object method. It should always be called exactly as shown above.

All debug information is reported using "carp" from the Carp module, so if you want a full stack backtrace included you can run your program like this:

   perl -MCarp=verbose myProg

Author ^

Andrew Findlay

Skills 1st Ltd

andrew.findlay@skills-1st.co.uk

http://www.skills-1st.co.uk/

syntax highlighting: