ApTest Manager documentation: API: ApTest::LDAP

ApTest::LDAP

NAME

ApTest::LDAP - class for ATM LDAP support

AUTHOR

Shane P. McCarron <shane@aptest.com>

COPYRIGHT

Copyright 2001-2009 Applied Testing and Technology, Inc. All Rights Reserved.

SYNOPSIS

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.

METHODS

new - Create a new, unpopulated test session

$file = new ApTest::LDAP( [ cfg ] );

Creates a new LDAP connection object.

cfg is an optional reference to a configuration data structure.

Returns a reference to the LDAP connection object.

authenticate - authenticate a userid / password via bind

my $auth = ApTest::LDAP::authenticate( userid, passwd [, user] ) ;

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.

cfg is a reference to an LDAP connection configuration. If not defined, then one will be gathered via the config method in this class.

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.

bind - bind to the associated LDAP server

$conn = $ldap->bind( ) ;

Returns 1 on success, 0 on failure.

config - get/set configuration parameters for connection

$cfgHashRef = $ldap->config( [cfhHashRef ] ) ;

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:

active

Boolean indicating if the LDAP connection is active at all.

host

The host on which the LDAP server resides.

port

The port on which the LDAP server is listening.

protocol

The LDAP protocol to use when communicating with the server.

user

The username to use with the server, if any.

password

The password to use with the server, if any.

uidF

The name of the field in the database that provides user IDs. This is only used when data minig for accounts.

fnF

The name of the field that defines a fullname, if any.

phoneF

The name of the field that defines a phone number, if any.

emailF

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.

connect - connect to an LDAP server

my $conn = $ldap->connect ( ) ;

Returns a handle to a LDAP server connection. Returns undef if there was a problem initializing the connection.

getEntry - get the LDAP Entry associated with a uid

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

isActive - check whether LDAP is active or not

$state = $ldap->isActive() ;

$state = ApTest::LDAP::isActive() ;

Returns true of LDAP is configured and active.

release - release the object

$ref->release();

This method undefines the data structures associated with the session and releases the lock on the session.

Copyright © 2000-2010 Applied Testing and Technology, Inc. All rights reserved.