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



Annotate this POD

View/Report Bugs
Module Version: 1.0   Source  




Connector for LDAP directories.


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

   $ldap = Net::LDAP->new( '' ) 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 );



Constructor ^


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

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

Methods ^


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('') );

Returns the object that it is passed.


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:


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


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 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.


Supply or fetch search parameters

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


Supply or fetch filterspec

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


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.


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.


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 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 ^


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

syntax highlighting: