ApTest::LDAP - class for ATM LDAP support
Shane P. McCarron <firstname.lastname@example.org>
Copyright 2001-2009 Applied Testing and Technology, Inc. All Rights Reserved.
The methods in this class manipulate the LDAP server configuration and provide an abstraction layer for connecting to the LDAP server. Once connected, the returned handler is to a Net::LDAP object, and all operations on the LDAP store should be conducted through that object, including closing the connection when done with it.
$file = new ApTest::LDAP( [ cfg ,] serverID );
Creates a new LDAP connection object.
cfg is an optional reference to a configuration data structure.
serverID is an integer which uniquely identify a previously configured LDAP server. If the cfg reference is specified, the server number is taken from this configuration.
Returns a reference to the LDAP connection object.
my $auth = ApTest::LDAP::authenticate( userid, passwd [, user] ) ; my $auth = ApTest::LDAP::authenticate( userid, passwd [, LDAP server number] ) ; my $auth = $ldap->authenticate( userid, passwd ) ;
userid is a userid to check.
passwd is the passwd to use.
user is an optional reference to a UserInfo object. If provided, then if authentication succeeds the LDAP-bound fields will be updated to match their entries in the LDAP repository.
If the user reference is not specified, the (optional) LDAP server number must be, otherwise it becomes impossible to find the one associated with this user.
Uses the userid and other information associated with the connection to search the connected repository for a matching DN. If there is one, then binds using that DN and the passwd parameter. If the bind succeeds, then returns true. Otherwise returns false.
$conn = $ldap->bind( ) ;
Returns 1 on success, 0 on failure.
$cfgHashRef = ApTest::LDAP::config( serverNum [, cfgHashRef] ) ; $cfgHashRef = $ldap->config( [cfgHashRef ] ) ;
If called as an object method, the object is already bound to a specific LDAP server. If called as a class method, then the first parameter MUST be the server number to operate upon.
cfgHashRef is an optional reference to a populated set of connection configuration information. If provided, this data is updated into the persistent store. The contains the following data items:
Boolean indicating if the LDAP connection is active at all.
The host on which the LDAP server resides.
The port on which the LDAP server is listening.
The LDAP protocol to use when communicating with the server.
The username to use with the server, if any.
The password to use with the server, if any.
The name of the field in the database that provides user IDs. This is only used when data minig for accounts.
The name of the field that defines a fullname, if any.
The name of the field that defines a phone number, if any.
The name of the field that defines an email address, if any.
Returns a reference to a hash containing the connection configuration information. If there is no definition, then returns an unpopulated structure.
my $conn = $ldap->connect ( ) ;
Returns a handle to a LDAP server connection. Returns undef if there was a problem initializing the connection.
$result = ApTest::LDAP::delete(serverNum)
Deletes the configuration for server serverNum.
Returns 1 on success, 0 on failure.
This method will return a reference to a hash, keyed on LDAP server number, of those servers actually active. The value of the hash entry is the hostname of the server.
$entry = $ldap->getEntry ( uid [, limit ] ) ;
uid is the user id to match.
limit is the maximum number of entries to match - this defaults to 2.
Returns an LDAP::Entry object or undef if the UID is not matched.
In an array context, returns up to limit entries that matched the uid pattern.
$state = $ldap->isActive() ; $state = ApTest::LDAP::isActive(serverNum) ;
Returns true of LDAP is configured and active.
serverNum is the ID of the LDAP server to use. This is normally set when the LDAP object is created. If LDAP::isActive is called as a class method, and not an object method, it must be specified to learn if a specific LDAP server is active. If it is not specified, this function will look at all LDAP servers and return true if ANY are active.
This method will return an integer corresponding to the number of the highest numbered LDAP server. If the datadir can't be opened, 0 is returned. If the number of servers is 0, but a single LDAPCONFIG file exist, -1 is returned to signal the config() method to use legacy code.
This method undefines the data structures associated with the session and releases the lock on the session.
Copyright © 2000-2013 Applied Testing and Technology, Inc. All rights reserved.