API Documentation

Zend/Ldap.php

Show: inherited
Table of Contents

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Ldap  
Version
$Id: Ldap.php 24594 2012-01-05 21:27:01Z matthew $  

\Zend_Ldap

Package: Zend\Ldap

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

Constant  SEARCH_SCOPE_SUB = 1
Constant  SEARCH_SCOPE_ONE = 2
Constant  SEARCH_SCOPE_BASE = 3
Constant  ACCTNAME_FORM_DN = 1
Constant  ACCTNAME_FORM_USERNAME = 2
Constant  ACCTNAME_FORM_BACKSLASH = 3
Constant  ACCTNAME_FORM_PRINCIPAL = 4

Properties

Propertyprotectedboolean|null|string  $_boundUser= 'false'

FALSE if no user is bound to the LDAP resource NULL if there has been an anonymous bind username of the currently bound user

Default valuefalseDetails
Type
booleannullstring
Propertyprivatestring  $_connectString= ''

String used with ldap_connect for error handling purposes.

Details
Type
string
Propertyprotectedarray  $_options= 'null'

The options used in connecting, binding, etc.

Default valuenullDetails
Type
array
Propertyprotectedresource  $_resource= 'null'

The raw LDAP extension resource.

Default valuenullDetails
Type
resource
Propertyprotected\Zend_Ldap_Node  $_rootDse= 'null'

Caches the RootDSE

Default valuenullDetails
Type
\Zend_Ldap_Node
Propertyprotected\Zend_Ldap_Node  $_schema= 'null'

Caches the schema

Default valuenullDetails
Type
\Zend_Ldap_Node

Methods

methodpublic__construct( array|\Zend_Config $options = array() ) : void

Constructor.

Parameters
Name Type Description
$options array|\Zend_Config

Options used in connecting, binding, etc.

Throws
Exception Description
\Zend_Ldap_Exception if ext/ldap is not installed
methodpublic__destruct( ) : void

Destructor.

methodprotected_createCollection( \Zend_Ldap_Collection_Iterator_Default $iterator, string|null $collectionClass ) : \Zend_Ldap_Collection

Extension point for collection creation

Parameters
Name Type Description
$iterator \Zend_Ldap_Collection_Iterator_Default
$collectionClass string|null
Returns
Type Description
\Zend_Ldap_Collection
Throws
Exception Description
\Zend_Ldap_Exception
methodprotected_getAccount(  $acctname, array $attrs = null ) : array

Parameters
Name Type Description
$acctname
$attrs array

An array of names of desired attributes

Returns
Type Description
array An array of the attributes representing the account
Throws
Exception Description
\Zend_Ldap_Exception
methodprotected_getAccountCanonicalForm( ) : integer

Returns
Type Description
integer Either ACCTNAME_FORM_BACKSLASH, ACCTNAME_FORM_PRINCIPAL or ACCTNAME_FORM_USERNAME indicating the form usernames should be canonicalized to.
methodprotected_getAccountDn( string $acctname ) : string

Parameters
Name Type Description
$acctname string

The name of the account

Returns
Type Description
string The DN of the specified account
Throws
Exception Description
\Zend_Ldap_Exception
methodprotected_getAccountDomainName( ) : string

Returns
Type Description
string The account domain name
methodprotected_getAccountDomainNameShort( ) : string

Returns
Type Description
string The short account domain name
methodprotected_getAccountFilter(  $acctname ) : string

Parameters
Name Type Description
$acctname
Returns
Type Description
string The LDAP search filter for matching directory accounts
methodprotected_getAccountFilterFormat( ) : string

Returns
Type Description
string A format string for building an LDAP search filter to match an account
methodprotected_getAllowEmptyPassword( ) : boolean

Returns
Type Description
boolean Allow empty passwords
methodprotected_getBindRequiresDn( ) : boolean

Returns
Type Description
boolean Bind requires DN
methodprotected_getChildrenDns( string|\Zend_Ldap_Dn $parentDn ) : array

Retrieve the immediate children DNs of the given $parentDn

This method is used in recursive methods like {@see delete()} or {@see copy()}

Parameters
Name Type Description
$parentDn string|\Zend_Ldap_Dn
Returns
Type Description
array of DNs
methodprotected_getHost( ) : string

Returns
Type Description
string The hostname of the LDAP server being used to authenticate accounts
methodprotected_getOptReferrals( ) : boolean

Returns
Type Description
boolean Opt. Referrals
methodprotected_getPassword( ) : string

Returns
Type Description
string The default password for binding
methodprotected_getPort( ) : int

Returns
Type Description
int The port of the LDAP server or 0 to indicate that no port value is set
methodprotected_getTryUsernameSplit( ) : boolean

Returns
Type Description
boolean Try splitting the username into username and domain
methodprotected_getUseSsl( ) : boolean

Returns
Type Description
boolean The default SSL / TLS encrypted transport control
methodprotected_getUseStartTls( ) : boolean

Returns
Type Description
boolean The default SSL / TLS encrypted transport control
methodprotected_getUsername( ) : string

Returns
Type Description
string The default acctname for binding
methodprotected_isPossibleAuthority( string $dname ) : boolean

Parameters
Name Type Description
$dname string

The domain name to check

Returns
Type Description
boolean
methodprotected_splitName( string $name, string $dname, string $aname ) : void

Parameters
Name Type Description
$name string

The name to split

$dname string

The resulting domain name (this is an out parameter)

$aname string

The resulting account name (this is an out parameter)

methodpublicadd( string|\Zend_Ldap_Dn $dn, array $entry ) : \Zend_Ldap

Add new information to the LDAP repository

Parameters
Name Type Description
$dn string|\Zend_Ldap_Dn
$entry array
Returns
Type Description
\Zend_Ldap Provides a fluid interface
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicbind( string $username = null, string $password = null ) : \Zend_Ldap

Parameters
Name Type Description
$username string

The username for authenticating the bind

$password string

The password for authenticating the bind

Returns
Type Description
\Zend_Ldap Provides a fluent interface
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicconnect( string $host = null, int $port = null, boolean $useSsl = null, boolean $useStartTls = null ) : \Zend_Ldap

To connect using SSL it seems the client tries to verify the server certificate by default. One way to disable this behavior is to set 'TLS_REQCERT never' in OpenLDAP's ldap.conf and restarting Apache. Or, if you really care about the server's cert you can put a cert on the web server.

Parameters
Name Type Description
$host string

The hostname of the LDAP server to connect to

$port int

The port number of the LDAP server to connect to

$useSsl boolean

Use SSL

$useStartTls boolean

Use STARTTLS

Returns
Type Description
\Zend_Ldap Provides a fluent interface
Throws
Exception Description
\Zend_Ldap_Exception
methodpubliccopy( string|\Zend_Ldap_Dn $from, string|\Zend_Ldap_Dn $to, boolean $recursively = false ) : \Zend_Ldap

Copies a LDAP entry from one DN to another DN.

Parameters
Name Type Description
$from string|\Zend_Ldap_Dn
$to string|\Zend_Ldap_Dn
$recursively boolean
Returns
Type Description
\Zend_Ldap Provides a fluid interface
Throws
Exception Description
\Zend_Ldap_Exception
methodpubliccopyToSubtree( string|\Zend_Ldap_Dn $from, string|\Zend_Ldap_Dn $to, boolean $recursively = false ) : \Zend_Ldap

Copies a LDAP entry from one DN to another subtree.

Parameters
Name Type Description
$from string|\Zend_Ldap_Dn
$to string|\Zend_Ldap_Dn
$recursively boolean
Returns
Type Description
\Zend_Ldap Provides a fluid interface
Throws
Exception Description
\Zend_Ldap_Exception
methodpubliccount( string|\Zend_Ldap_Filter_Abstract $filter, string|\Zend_Ldap_Dn|null $basedn = null, integer $scope = self::SEARCH_SCOPE_SUB ) : integer

Count items found by given filter.

Parameters
Name Type Description
$filter string|\Zend_Ldap_Filter_Abstract
$basedn string|\Zend_Ldap_Dn|null
$scope integer
Returns
Type Description
integer
Throws
Exception Description
\Zend_Ldap_Exception
methodpubliccountChildren( string|\Zend_Ldap_Dn $dn ) : integer

Count children for a given DN.

Parameters
Name Type Description
$dn string|\Zend_Ldap_Dn
Returns
Type Description
integer
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicdelete( string|\Zend_Ldap_Dn $dn, boolean $recursively = false ) : \Zend_Ldap

Delete an LDAP entry

Parameters
Name Type Description
$dn string|\Zend_Ldap_Dn
$recursively boolean
Returns
Type Description
\Zend_Ldap Provides a fluid interface
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicdisconnect( ) : \Zend_Ldap

Returns
Type Description
\Zend_Ldap Provides a fluent interface
methodpublicexists( string|\Zend_Ldap_Dn $dn ) : boolean

Check if a given DN exists.

Parameters
Name Type Description
$dn string|\Zend_Ldap_Dn
Returns
Type Description
boolean
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicexplodeDn( string $dn, array $keys = null, array $vals = null ) : boolean
static

Parameters
Name Type Description
$dn string

The DN to parse

$keys array

An optional array to receive DN keys (e.g. CN, OU, DC, ...)

$vals array

An optional array to receive DN values

Returns
Type Description
boolean True if the DN was successfully parsed or false if the string is not a valid DN.
Details
Deprecated
will be removed, use {@see Zend_Ldap_Dn::checkDn()}  
methodpublicfilterEscape( string $str ) : string
static

Parameters
Name Type Description
$str string

The string to escape.

Returns
Type Description
string The escaped string
Details
Deprecated
will be removed, use {@see Zend_Ldap_Filter_Abstract::escapeValue()}  
methodpublicgetBaseDn( ) : string

Gets the base DN under which objects of interest are located

Returns
Type Description
string
methodpublicgetBaseNode( ) : \Zend_Ldap_Node

Returns the base node as a Zend_Ldap_Node

Returns
Type Description
\Zend_Ldap_Node
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicgetBoundUser( ) : false|null|string

Get the currently bound user

FALSE if no user is bound to the LDAP resource NULL if there has been an anonymous bind username of the currently bound user

Returns
Type Description
false|null|string
methodpublicgetCanonicalAccountName( string $acctname,  $form = 0 ) : string

Parameters
Name Type Description
$acctname string

The name to canonicalize

$form
Returns
Type Description
string The canonicalized name in the desired form
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicgetEntry( string|\Zend_Ldap_Dn $dn, array $attributes = array(), boolean $throwOnNotFound = false ) : array

Get LDAP entry by DN

Parameters
Name Type Description
$dn string|\Zend_Ldap_Dn
$attributes array
$throwOnNotFound boolean
Returns
Type Description
array
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicgetLastError( int $errorCode = null, array $errorMessages = null ) : string

Return the LDAP error message of the last LDAP command

Parameters
Name Type Description
$errorCode int
$errorMessages array
Returns
Type Description
string
methodpublicgetLastErrorCode( ) : int

Return the LDAP error number of the last LDAP command

Returns
Type Description
int
methodpublicgetNode( string|\Zend_Ldap_Dn $dn ) : \Zend_Ldap_Node|null

Returns the specified DN as a Zend_Ldap_Node

Parameters
Name Type Description
$dn string|\Zend_Ldap_Dn
Returns
Type Description
\Zend_Ldap_Node|null
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicgetOptions( ) : array

Returns
Type Description
array The current options.
methodpublicgetResource( ) : resource

Returns
Type Description
resource The raw LDAP extension resource.
methodpublicgetRootDse( ) : \Zend_Ldap_Node_RootDse

Returns the RootDSE

Returns
Type Description
\Zend_Ldap_Node_RootDse
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicgetSchema( ) : \Zend_Ldap_Node_Schema

Returns the schema

Returns
Type Description
\Zend_Ldap_Node_Schema
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicmove( string|\Zend_Ldap_Dn $from, string|\Zend_Ldap_Dn $to, boolean $recursively = false, boolean $alwaysEmulate = false ) : \Zend_Ldap

Moves a LDAP entry from one DN to another DN.

This is an alias for {@link rename()}

Parameters
Name Type Description
$from string|\Zend_Ldap_Dn
$to string|\Zend_Ldap_Dn
$recursively boolean
$alwaysEmulate boolean
Returns
Type Description
\Zend_Ldap Provides a fluid interface
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicmoveToSubtree( string|\Zend_Ldap_Dn $from, string|\Zend_Ldap_Dn $to, boolean $recursively = false, boolean $alwaysEmulate = false ) : \Zend_Ldap

Moves a LDAP entry from one DN to another subtree.

Parameters
Name Type Description
$from string|\Zend_Ldap_Dn
$to string|\Zend_Ldap_Dn
$recursively boolean
$alwaysEmulate boolean
Returns
Type Description
\Zend_Ldap Provides a fluid interface
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicprepareLdapEntryArray( array $entry ) : void
static

Prepares an ldap data entry array for insert/update operation

Parameters
Name Type Description
$entry array
Throws
Exception Description
\InvalidArgumentException
methodpublicrename( string|\Zend_Ldap_Dn $from, string|\Zend_Ldap_Dn $to, boolean $recursively = false, boolean $alwaysEmulate = false ) : \Zend_Ldap

Renames a LDAP entry from one DN to another DN.

This method implicitely moves the entry to another location within the tree.

Parameters
Name Type Description
$from string|\Zend_Ldap_Dn
$to string|\Zend_Ldap_Dn
$recursively boolean
$alwaysEmulate boolean
Returns
Type Description
\Zend_Ldap Provides a fluid interface
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicsave( string|\Zend_Ldap_Dn $dn, array $entry ) : \Zend_Ldap

Save entry to LDAP registry.

Internally decides if entry will be updated to added by calling {@link exists()}.

Parameters
Name Type Description
$dn string|\Zend_Ldap_Dn
$entry array
Returns
Type Description
\Zend_Ldap Provides a fluid interface
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicsearch( string|\Zend_Ldap_Filter_Abstract|array $filter, string|\Zend_Ldap_Dn|null $basedn = null, integer $scope = self::SEARCH_SCOPE_SUB, array $attributes = array(), string|null $sort = null, string|null $collectionClass = null, integer $sizelimit = 0, integer $timelimit = 0 ) : \Zend_Ldap_Collection

A global LDAP search routine for finding information.

Options can be either passed as single parameters according to the method signature or as an array with one or more of the following keys - filter - baseDn - scope - attributes - sort - collectionClass - sizelimit - timelimit

Parameters
Name Type Description
$filter string|\Zend_Ldap_Filter_Abstract|array
$basedn string|\Zend_Ldap_Dn|null
$scope integer
$attributes array
$sort string|null
$collectionClass string|null
$sizelimit integer
$timelimit integer
Returns
Type Description
\Zend_Ldap_Collection
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicsearchEntries( string|\Zend_Ldap_Filter_Abstract|array $filter, string|\Zend_Ldap_Dn|null $basedn = null, integer $scope = self::SEARCH_SCOPE_SUB, array $attributes = array(), string|null $sort = null, boolean $reverseSort = false, integer $sizelimit = 0, integer $timelimit = 0 ) : array

Search LDAP registry for entries matching filter and optional attributes

Options can be either passed as single parameters according to the method signature or as an array with one or more of the following keys - filter - baseDn - scope - attributes - sort - reverseSort - sizelimit - timelimit

Parameters
Name Type Description
$filter string|\Zend_Ldap_Filter_Abstract|array
$basedn string|\Zend_Ldap_Dn|null
$scope integer
$attributes array
$sort string|null
$reverseSort boolean
$sizelimit integer
$timelimit integer
Returns
Type Description
array
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicsetOptions( array|\Zend_Config $options ) : \Zend_Ldap

Sets the options used in connecting, binding, etc.

Valid option keys: host port useSsl username password bindRequiresDn baseDn accountCanonicalForm accountDomainName accountDomainNameShort accountFilterFormat allowEmptyPassword useStartTls optRefferals tryUsernameSplit

Parameters
Name Type Description
$options array|\Zend_Config

Options used in connecting, binding, etc.

Returns
Type Description
\Zend_Ldap Provides a fluent interface
Throws
Exception Description
\Zend_Ldap_Exception
methodpublicupdate( string|\Zend_Ldap_Dn $dn, array $entry ) : \Zend_Ldap

Update LDAP registry

Parameters
Name Type Description
$dn string|\Zend_Ldap_Dn
$entry array
Returns
Type Description
\Zend_Ldap Provides a fluid interface
Throws
Exception Description
\Zend_Ldap_Exception
Documentation was generated by DocBlox 0.15.1.