API Documentation

Ldap.php

Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Ldap
version
$Id: Ldap.php 22997 2010-09-22 17:04:28Z sgehrig $
Classes
Zend_Ldap

Description

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.

Zend_Ldap

category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Ldap
Constants
SEARCH_SCOPE_SUB
SEARCH_SCOPE_ONE
SEARCH_SCOPE_BASE
ACCTNAME_FORM_DN
ACCTNAME_FORM_USERNAME
ACCTNAME_FORM_BACKSLASH
ACCTNAME_FORM_PRINCIPAL
Properties
$_connectString
$_options
$_resource
$_boundUser
$_rootDse
$_schema
Methods
filterEscape
explodeDn
__construct
__destruct
getResource
getLastErrorCode
getLastError
getBoundUser
setOptions
getOptions
_getHost
_getPort
_getUseSsl
_getUsername
_getPassword
_getBindRequiresDn
getBaseDn
_getAccountCanonicalForm
_getAccountDomainName
_getAccountDomainNameShort
_getAccountFilterFormat
_getAllowEmptyPassword
_getUseStartTls
_getOptReferrals
_getTryUsernameSplit
_getAccountFilter
_splitName
_getAccountDn
_isPossibleAuthority
getCanonicalAccountName
_getAccount
disconnect
connect
bind
search
_createCollection
count
countChildren
exists
searchEntries
getEntry
prepareLdapEntryArray
add
update
save
delete
_getChildrenDns
moveToSubtree
move
rename
copyToSubtree
copy
getNode
getBaseNode
getRootDse
getSchema

Description

Constants

SEARCH_SCOPE_SUB

 SEARCH_SCOPE_SUB = '1'

Details

value
1

SEARCH_SCOPE_ONE

 SEARCH_SCOPE_ONE = '2'

Details

value
2

SEARCH_SCOPE_BASE

 SEARCH_SCOPE_BASE = '3'

Details

value
3

ACCTNAME_FORM_DN

 ACCTNAME_FORM_DN = '1'

Details

value
1

ACCTNAME_FORM_USERNAME

 ACCTNAME_FORM_USERNAME = '2'

Details

value
2

ACCTNAME_FORM_BACKSLASH

 ACCTNAME_FORM_BACKSLASH = '3'

Details

value
3

ACCTNAME_FORM_PRINCIPAL

 ACCTNAME_FORM_PRINCIPAL = '4'

Details

value
4

Properties

$_boundUser

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

Details

$_boundUser
boolean|null|string
visibility
protected
default
false
final
false
static
false

$_connectString

string $_connectString = ''

String used with ldap_connect for error handling purposes.

Details

$_connectString
string
visibility
private
default
final
false
static
false

$_options

array $_options = 'null'

The options used in connecting, binding, etc.

Details

$_options
array
visibility
protected
default
null
final
false
static
false

$_resource

resource $_resource = 'null'

The raw LDAP extension resource.

Details

$_resource
resource
visibility
protected
default
null
final
false
static
false

$_rootDse

Zend_Ldap_Node $_rootDse = 'null'

Caches the RootDSE

Details

$_rootDse
Zend_Ldap_Node
visibility
protected
default
null
final
false
static
false

$_schema

Zend_Ldap_Node $_schema = 'null'

Caches the schema

Details

$_schema
Zend_Ldap_Node
visibility
protected
default
null
final
false
static
false

Methods

__construct

__construct( array|Zend_Config $options = array ) : void

Constructor.

Arguments
$options
arrayZend_Config
Options used in connecting, binding, etc.
Details
visibility
public
final
false
static
false
throws
if ext/ldap is not installed

__destruct

__destruct( ) : void

Destructor.

Details
visibility
public
final
false
static
false

_createCollection

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

Extension point for collection creation

Arguments
$iterator
Zend_Ldap_Collection_Iterator_Default
$collectionClass
stringnull
Details
visibility
protected
final
false
static
false
throws

_getAccount

_getAccount(  $acctname, array $attrs = null ) : array

Arguments
$acctname
$attrs
array
An array of names of desired attributes
Output
array
An array of the attributes representing the account
Details
visibility
protected
final
false
static
false
throws

_getAccountCanonicalForm

_getAccountCanonicalForm( ) : integer

Output
integer
Either ACCTNAME_FORM_BACKSLASH, ACCTNAME_FORM_PRINCIPAL or ACCTNAME_FORM_USERNAME indicating the form usernames should be canonicalized to.
Details
visibility
protected
final
false
static
false

_getAccountDn

_getAccountDn( string $acctname ) : string

Arguments
$acctname
string
The name of the account
Output
string
The DN of the specified account
Details
visibility
protected
final
false
static
false
throws

_getAccountDomainName

_getAccountDomainName( ) : string

Output
string
The account domain name
Details
visibility
protected
final
false
static
false

_getAccountDomainNameShort

_getAccountDomainNameShort( ) : string

Output
string
The short account domain name
Details
visibility
protected
final
false
static
false

_getAccountFilter

_getAccountFilter(  $acctname ) : string

Arguments
$acctname
Output
string
The LDAP search filter for matching directory accounts
Details
visibility
protected
final
false
static
false

_getAccountFilterFormat

_getAccountFilterFormat( ) : string

Output
string
A format string for building an LDAP search filter to match an account
Details
visibility
protected
final
false
static
false

_getAllowEmptyPassword

_getAllowEmptyPassword( ) : boolean

Output
boolean
Allow empty passwords
Details
visibility
protected
final
false
static
false

_getBindRequiresDn

_getBindRequiresDn( ) : boolean

Output
boolean
Bind requires DN
Details
visibility
protected
final
false
static
false

_getChildrenDns

_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()}

Arguments
$parentDn
stringZend_Ldap_Dn
Output
array
of DNs
Details
visibility
protected
final
false
static
false

_getHost

_getHost( ) : string

Output
string
The hostname of the LDAP server being used to authenticate accounts
Details
visibility
protected
final
false
static
false

_getOptReferrals

_getOptReferrals( ) : boolean

Output
boolean
Opt. Referrals
Details
visibility
protected
final
false
static
false

_getPassword

_getPassword( ) : string

Output
string
The default password for binding
Details
visibility
protected
final
false
static
false

_getPort

_getPort( ) : int

Output
int
The port of the LDAP server or 0 to indicate that no port value is set
Details
visibility
protected
final
false
static
false

_getTryUsernameSplit

_getTryUsernameSplit( ) : boolean

Output
boolean
Try splitting the username into username and domain
Details
visibility
protected
final
false
static
false

_getUseSsl

_getUseSsl( ) : boolean

Output
boolean
The default SSL / TLS encrypted transport control
Details
visibility
protected
final
false
static
false

_getUseStartTls

_getUseStartTls( ) : boolean

Output
boolean
The default SSL / TLS encrypted transport control
Details
visibility
protected
final
false
static
false

_getUsername

_getUsername( ) : string

Output
string
The default acctname for binding
Details
visibility
protected
final
false
static
false

_isPossibleAuthority

_isPossibleAuthority( string $dname ) : boolean

Arguments
$dname
string
The domain name to check
Output
boolean
Details
visibility
protected
final
false
static
false

_splitName

_splitName( string $name, string $dname, string $aname ) : void

Arguments
$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)
Details
visibility
protected
final
false
static
false

add

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

Add new information to the LDAP repository

Arguments
$dn
stringZend_Ldap_Dn
$entry
array
Output
Zend_Ldap
Provides a fluid interface
Details
visibility
public
final
false
static
false
throws

bind

bind( string $username = null, string $password = null ) : Zend_Ldap

Arguments
$username
string
The username for authenticating the bind
$password
string
The password for authenticating the bind
Output
Zend_Ldap
Provides a fluent interface
Details
visibility
public
final
false
static
false
throws

connect

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

Arguments
$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
Output
Zend_Ldap
Provides a fluent interface
Details
visibility
public
final
false
static
false
throws

copy

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

Arguments
$from
stringZend_Ldap_Dn
$to
stringZend_Ldap_Dn
$recursively
boolean
Output
Zend_Ldap
Provides a fluid interface
Details
visibility
public
final
false
static
false
throws

copyToSubtree

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

Arguments
$from
stringZend_Ldap_Dn
$to
stringZend_Ldap_Dn
$recursively
boolean
Output
Zend_Ldap
Provides a fluid interface
Details
visibility
public
final
false
static
false
throws

count

count( string|Zend_Ldap_Filter_Abstract $filter, string|Zend_Ldap_Dn|null $basedn = null, integer $scope = self ) : integer

Count items found by given filter.

Arguments
$filter
stringZend_Ldap_Filter_Abstract
$basedn
stringZend_Ldap_Dnnull
$scope
integer
Output
integer
Details
visibility
public
final
false
static
false
throws

countChildren

countChildren( string|Zend_Ldap_Dn $dn ) : integer

Count children for a given DN.

Arguments
$dn
stringZend_Ldap_Dn
Output
integer
Details
visibility
public
final
false
static
false
throws

delete

delete( string|Zend_Ldap_Dn $dn, boolean $recursively = false ) : Zend_Ldap

Delete an LDAP entry

Arguments
$dn
stringZend_Ldap_Dn
$recursively
boolean
Output
Zend_Ldap
Provides a fluid interface
Details
visibility
public
final
false
static
false
throws

disconnect

disconnect( ) : Zend_Ldap

Output
Zend_Ldap
Provides a fluent interface
Details
visibility
public
final
false
static
false

exists

exists( string|Zend_Ldap_Dn $dn ) : boolean

Check if a given DN exists.

Arguments
$dn
stringZend_Ldap_Dn
Output
boolean
Details
visibility
public
final
false
static
false
throws

explodeDn

explodeDn( string $dn, array $keys = null, array $vals = null ) : boolean

Arguments
$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
Output
boolean
True if the DN was successfully parsed or false if the string is not a valid DN.
Details
visibility
public
final
false
static
true
deprecated
will be removed, use {@see Zend_Ldap_Dn::checkDn()}

filterEscape

filterEscape( string $str ) : string

Arguments
$str
string
The string to escape.
Output
string
The escaped string
Details
visibility
public
final
false
static
true
deprecated
will be removed, use {@see Zend_Ldap_Filter_Abstract::escapeValue()}

getBaseDn

getBaseDn( ) : string

Gets the base DN under which objects of interest are located

Output
string
Details
visibility
public
final
false
static
false

getBaseNode

getBaseNode( ) : Zend_Ldap_Node

Returns the base node as a Zend_Ldap_Node

Details
visibility
public
final
false
static
false
throws

getBoundUser

getBoundUser( ) : 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

Output
false|null|string
Details
visibility
public
final
false
static
false

getCanonicalAccountName

getCanonicalAccountName( string $acctname,  $form = 0 ) : string

Arguments
$acctname
string
The name to canonicalize
$form
Output
string
The canonicalized name in the desired form
Details
visibility
public
final
false
static
false
throws

getEntry

getEntry( string|Zend_Ldap_Dn $dn, array $attributes = array, boolean $throwOnNotFound = false ) : array

Get LDAP entry by DN

Arguments
$dn
stringZend_Ldap_Dn
$attributes
array
$throwOnNotFound
boolean
Output
array
Details
visibility
public
final
false
static
false
throws

getLastError

getLastError( int $errorCode = null, array $errorMessages = null ) : string

Return the LDAP error message of the last LDAP command

Arguments
$errorCode
int
$errorMessages
array
Output
string
Details
visibility
public
final
false
static
false

getLastErrorCode

getLastErrorCode( ) : int

Return the LDAP error number of the last LDAP command

Output
int
Details
visibility
public
final
false
static
false

getNode

getNode( string|Zend_Ldap_Dn $dn ) : Zend_Ldap_Node|null

Returns the specified DN as a Zend_Ldap_Node

Arguments
$dn
stringZend_Ldap_Dn
Output
Zend_Ldap_Node|null
Details
visibility
public
final
false
static
false
throws

getOptions

getOptions( ) : array

Output
array
The current options.
Details
visibility
public
final
false
static
false

getResource

getResource( ) : resource

Output
resource
The raw LDAP extension resource.
Details
visibility
public
final
false
static
false

getRootDse

getRootDse( ) : Zend_Ldap_Node_RootDse

Returns the RootDSE

Details
visibility
public
final
false
static
false
throws

getSchema

getSchema( ) : Zend_Ldap_Node_Schema

Returns the schema

Details
visibility
public
final
false
static
false
throws

move

move( 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()}

Arguments
$from
stringZend_Ldap_Dn
$to
stringZend_Ldap_Dn
$recursively
boolean
$alwaysEmulate
boolean
Output
Zend_Ldap
Provides a fluid interface
Details
visibility
public
final
false
static
false
throws

moveToSubtree

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

Arguments
$from
stringZend_Ldap_Dn
$to
stringZend_Ldap_Dn
$recursively
boolean
$alwaysEmulate
boolean
Output
Zend_Ldap
Provides a fluid interface
Details
visibility
public
final
false
static
false
throws

prepareLdapEntryArray

prepareLdapEntryArray( array $entry ) : void

Prepares an ldap data entry array for insert/update operation

Arguments
$entry
array
Details
visibility
public
final
false
static
true
throws

rename

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

Arguments
$from
stringZend_Ldap_Dn
$to
stringZend_Ldap_Dn
$recursively
boolean
$alwaysEmulate
boolean
Output
Zend_Ldap
Provides a fluid interface
Details
visibility
public
final
false
static
false
throws

save

save( 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()}.

Arguments
$dn
stringZend_Ldap_Dn
$entry
array
Output
Zend_Ldap
Provides a fluid interface
Details
visibility
public
final
false
static
false
throws

search

search( string|Zend_Ldap_Filter_Abstract|array $filter, string|Zend_Ldap_Dn|null $basedn = null, integer $scope = self, 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

Arguments
$filter
stringZend_Ldap_Filter_Abstractarray
$basedn
stringZend_Ldap_Dnnull
$scope
integer
$attributes
array
$sort
stringnull
$collectionClass
stringnull
$sizelimit
integer
$timelimit
integer
Details
visibility
public
final
false
static
false
throws

searchEntries

searchEntries( string|Zend_Ldap_Filter_Abstract|array $filter, string|Zend_Ldap_Dn|null $basedn = null, integer $scope = self, 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

Arguments
$filter
stringZend_Ldap_Filter_Abstractarray
$basedn
stringZend_Ldap_Dnnull
$scope
integer
$attributes
array
$sort
stringnull
$reverseSort
boolean
$sizelimit
integer
$timelimit
integer
Output
array
Details
visibility
public
final
false
static
false
throws

setOptions

setOptions( 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

Arguments
$options
arrayZend_Config
Options used in connecting, binding, etc.
Output
Zend_Ldap
Provides a fluent interface
Details
visibility
public
final
false
static
false
throws

update

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

Update LDAP registry

Arguments
$dn
stringZend_Ldap_Dn
$entry
array
Output
Zend_Ldap
Provides a fluid interface
Details
visibility
public
final
false
static
false
throws
Documentation was generated by DocBlox.