PHP 클래스 Horde_Ldap, horde

Copyright 2003-2007 Tarjej Huse, Jan Wagner, Del Elson, Benedikt Hallinger Copyright 2009-2016 Horde LLC (http://www.horde.org/)
저자: Tarjej Huse ([email protected])
저자: Jan Wagner ([email protected])
저자: Del ([email protected])
저자: Benedikt Hallinger ([email protected])
저자: Ben Klang ([email protected])
저자: Chuck Hagenbuch ([email protected])
저자: Jan Schneider ([email protected])
파일 보기 프로젝트 열기: horde/horde 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_config array - hostspec: the LDAP host to connect to (may be an array of several hosts to try). - port: the server port. - version: LDAP version (defaults to 3). - tls: when set, ldap_start_tls() is run after connecting. - binddn: the DN to bind as when searching. - bindpw: password to use when searching LDAP. - basedn: LDAP base. - options: hash of LDAP options to set. - filter: default search filter. - scope: default search scope. - user: configuration parameters for {@link findUserDN()}, must contain 'uid', and may contain 'basedn' entries. - timeout: Connection timeout in seconds (defaults to 5). - auto_reconnect: if true, the class will automatically attempt to reconnect to the LDAP server in certain failure conditions when attempting a search, or other LDAP operations. Defaults to false. Note that if you set this to true, calls to search() may block indefinitely if there is a catastrophic server failure. - min_backoff: minimum reconnection delay period (in seconds). - current_backof: initial reconnection delay period (in seconds). - max_backoff: maximum reconnection delay period (in seconds). - cache a Horde_Cache instance for caching schema requests.
$_downHostList array List of hosts that are known to be down.
$_hostList array List of hosts we try to establish a connection to.
$_link resource LDAP resource link.
$_rootDSECache array Hash with requested rootDSE attr names as key and rootDSE object as value. Since the RootDSE object itself may request a rootDSE object, {@link rootDSE()} caches successful requests. Internally, Horde_Ldap needs several lookups to this object, so caching increases performance significally.
$_schema Horde_Ldap_Schema Schema object.
$_schemaAttrs Cache for attribute encoding checks.
$_schemaCache string Schema cache function callback.

공개 메소드들

메소드 설명
__construct ( array $config = [] ) Constructor.
__destruct ( ) Destructor.
add ( Horde_Ldap_Entry $entry ) Adds a new entry to the directory.
bind ( string $dn = null, string $password = null ) Bind or rebind to the LDAP server.
buildClause ( string $lhs, string $op, string $rhs, array $params = [] ) : string Builds an LDAP search filter fragment.
checkLDAPExtension ( ) Checks if PHP's LDAP extension is loaded.
copy ( Horde_Ldap_Entry $entry, string $newdn ) : Horde_Ldap_Entry Copies an entry to a new location.
delete ( string | Horde_Ldap_Entry $dn, boolean $recursive = false ) Deletes an entry from the directory.
disconnect ( ) Closes the LDAP connection.
errorName ( integer $errorcode ) : string Returns the string for an LDAP errorcode.
exists ( string | Horde_Ldap_Entry $dn ) : boolean Returns whether a DN exists in the directory.
findUserDN ( string $user ) : string Returns the DN of a user.
getEntry ( string $dn, array $attributes = [] ) : Horde_Ldap_Entry Returns a specific entry based on the DN.
getLink ( ) : resource Returns the LDAP link resource.
getOption ( string $option ) : Horde_Ldap_Error | string Returns an LDAP option value.
getVersion ( ) : integer Returns the LDAP protocol version that is used on the connection.
modify ( string | Horde_Ldap_Entry $entry, array $parms = [] ) Modifies an LDAP entry on the server.
move ( string | Horde_Ldap_Entry $entry, string $newdn, Horde_Ldap $target_ldap = null ) Renames or moves an entry.
quote ( string $clause ) : string Escapes characters with special meaning in LDAP searches.
quoteDN ( array $parts ) : string Takes an array of DN elements and properly quotes it according to RFC 1485.
rootDSE ( array $attrs = [] ) : Horde_Ldap_RootDse Returns a rootDSE object
schema ( string $dn = null ) : Horde_Ldap_Schema Returns a schema object
search ( string | Horde_Ldap_Entry $base = null, string | Horde_Ldap_Filter $filter = null, array $params = [] ) : Horde_Ldap_Search Runs an LDAP search query.
setOption ( string $option, mixed $value ) Sets an LDAP option.
setVersion ( integer $version, boolean $force = false ) Sets the LDAP protocol version that is used on the connection.
startTLS ( ) Starts an encrypted session.
utf8Decode ( array $attributes ) : array | Horde_Ldap_Error
utf8Encode ( array $attributes ) : array | Horde_Ldap_Error

보호된 메소드들

메소드 설명
_connect ( ) Connects to the LDAP server.
_quoteRDN ( array $attribute ) : string Takes an RDN array with an attribute name and value and properly quotes it according to RFC 1485.
_quoteRDNs ( array $attribute ) : string Takes a single or a list of RDN arrays with an attribute name and value and properly quotes it according to RFC 1485.
_reconnect ( ) Reconnects to the LDAP server.
setConfig ( array $config ) Sets the internal configuration array.
utf8 ( array $attributes, array $function ) : array

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( array $config = [] )
$config array Configuration array.

__destruct() 공개 메소드

Destructor.
public __destruct ( )

_connect() 보호된 메소드

This function connects to the LDAP server specified in the configuration, binds and set up the LDAP protocol as needed.
protected _connect ( )

_quoteRDN() 보호된 정적인 메소드

Takes an RDN array with an attribute name and value and properly quotes it according to RFC 1485.
protected static _quoteRDN ( array $attribute ) : string
$attribute array A tuple containing the attribute name and that attribute's value which make up the RDN.
리턴 string The properly quoted string RDN.

_quoteRDNs() 보호된 정적인 메소드

Takes a single or a list of RDN arrays with an attribute name and value and properly quotes it according to RFC 1485.
protected static _quoteRDNs ( array $attribute ) : string
$attribute array A tuple or array of tuples containing the attribute name and that attribute's value which make up the RDN.
리턴 string The properly quoted string RDN.

_reconnect() 보호된 메소드

In case the connection to the LDAP service has dropped out for some reason, this function will reconnect, and re-bind if a bind has been attempted in the past. It is probably most useful when the server list provided to the new() or _connect() function is an array rather than a single host name, because in that case it will be able to connect to a failover or secondary server in case the primary server goes down. This method just tries to re-establish the current connection. It will sleep for the current backoff period (seconds) before attempting the connect, and if the connection fails it will double the backoff period, but not try again. If you want to ensure a reconnection during a transient period of server downtime then you need to call this function in a loop.
protected _reconnect ( )

add() 공개 메소드

This also links the entry to the connection used for the add, if it was a fresh entry.
또한 보기: HordeLdap_Entry::createFresh()
public add ( Horde_Ldap_Entry $entry )
$entry Horde_Ldap_Entry An LDAP entry.

bind() 공개 메소드

This function binds with the given DN and password to the server. In case no connection has been made yet, it will be started and STARTTLS issued if appropiate. The internal bind configuration is not being updated, so if you call bind() without parameters, you can rebind with the credentials provided at first connecting to the server.
public bind ( string $dn = null, string $password = null )
$dn string DN for binding.
$password string Password for binding.

buildClause() 공개 정적인 메소드

Builds an LDAP search filter fragment.
public static buildClause ( string $lhs, string $op, string $rhs, array $params = [] ) : string
$lhs string The attribute to test.
$op string The operator.
$rhs string The comparison value.
$params array Any additional parameters for the operator.
리턴 string The LDAP search fragment.

checkLDAPExtension() 공개 정적인 메소드

If it is not loaded, it tries to load it manually using PHP's dl(). It knows both windows-dll and *nix-so.
public static checkLDAPExtension ( )

copy() 공개 메소드

The entry will be immediately copied. Only attributes you have selected will be copied.
public copy ( Horde_Ldap_Entry $entry, string $newdn ) : Horde_Ldap_Entry
$entry Horde_Ldap_Entry An LDAP entry.
$newdn string New FQF-DN of the entry.
리턴 Horde_Ldap_Entry The copied entry.

delete() 공개 메소드

Deletes an entry from the directory.
public delete ( string | Horde_Ldap_Entry $dn, boolean $recursive = false )
$dn string | Horde_Ldap_Entry DN string or Horde_Ldap_Entry.
$recursive boolean Should we delete all children recursivelx as well?

disconnect() 공개 메소드

Closes the LDAP connection.
public disconnect ( )

errorName() 공개 정적인 메소드

Made to be able to make better errorhandling. Function based on DB::errorMessage(). Hint: The best description of the errorcodes is found here: http://www.directory-info.com/Ldap/LDAPErrorCodes.html
public static errorName ( integer $errorcode ) : string
$errorcode integer An error code.
리턴 string The description for the error.

exists() 공개 메소드

Returns whether a DN exists in the directory.
public exists ( string | Horde_Ldap_Entry $dn ) : boolean
$dn string | Horde_Ldap_Entry The DN of the object to test.
리턴 boolean True if the DN exists.

findUserDN() 공개 메소드

The purpose is to quickly find the full DN of a user so it can be used to re-bind as this user. This method requires the 'user' configuration parameter to be set.
public findUserDN ( string $user ) : string
$user string The user to find.
리턴 string The user's full DN.

getEntry() 공개 메소드

Returns a specific entry based on the DN.
public getEntry ( string $dn, array $attributes = [] ) : Horde_Ldap_Entry
$dn string DN of the entry that should be fetched.
$attributes array Array of Attributes to select. If ommitted, all attributes are fetched.
리턴 Horde_Ldap_Entry A Horde_Ldap_Entry object.

getOption() 공개 메소드

Returns an LDAP option value.
public getOption ( string $option ) : Horde_Ldap_Error | string
$option string Option to get.
리턴 Horde_Ldap_Error | string Horde_Ldap_Error or option value

getVersion() 공개 메소드

A lot of LDAP functionality is defined by what protocol version the LDAP server speaks. This might be 2 or 3.
public getVersion ( ) : integer
리턴 integer The protocol version.

modify() 공개 메소드

The $params argument is an array of actions and should be something like this: array('add' => array('attribute1' => array('val1', 'val2'), 'attribute2' => array('val1')), 'delete' => array('attribute1'), 'replace' => array('attribute1' => array('val1')), 'changes' => array('add' => ..., 'replace' => ..., 'delete' => array('attribute1', 'attribute2' => array('val1'))) The order of execution is as following: 1. adds from 'add' array 2. deletes from 'delete' array 3. replaces from 'replace' array 4. changes (add, replace, delete) in order of appearance The function calls the corresponding functions of an Horde_Ldap_Entry object. A detailed description of array structures can be found there. Unlike the modification methods provided by the Horde_Ldap_Entry object, this method will instantly carry out an update() after each operation, thus modifying "directly" on the server.
또한 보기: Horde_Ldap_Entry::add()
또한 보기: Horde_Ldap_Entry::delete()
또한 보기: Horde_Ldap_Entry::replace()
public modify ( string | Horde_Ldap_Entry $entry, array $parms = [] )
$entry string | Horde_Ldap_Entry DN string or Horde_Ldap_Entry.
$parms array Array of changes

move() 공개 메소드

This method will instantly carry out an update() after the move, so the entry is moved instantly. You can pass an optional Horde_Ldap object. In this case, a cross directory move will be performed which deletes the entry in the source (THIS) directory and adds it in the directory $target_ldap. A cross directory move will switch the entry's internal LDAP reference so updates to the entry will go to the new directory. If you want to do a cross directory move, you need to pass an Horde_Ldap_Entry object, otherwise the attributes will be empty.
public move ( string | Horde_Ldap_Entry $entry, string $newdn, Horde_Ldap $target_ldap = null )
$entry string | Horde_Ldap_Entry An LDAP entry.
$newdn string The new location.
$target_ldap Horde_Ldap Target directory for cross server move.

quote() 공개 정적인 메소드

Escapes characters with special meaning in LDAP searches.
public static quote ( string $clause ) : string
$clause string The string to escape.
리턴 string The escaped string.

quoteDN() 공개 정적인 메소드

Takes an array of DN elements and properly quotes it according to RFC 1485.
public static quoteDN ( array $parts ) : string
$parts array An array of tuples containing the attribute name and that attribute's value which make up the DN. Example: $parts = array( array('cn', 'John Smith'), array('dc', 'example'), array('dc', 'com') ); Nested arrays are supported since 2.1.0, to form multi-valued RDNs. Example: $parts = array( array( array('cn', 'John'), array('sn', 'Smith'), array('o', 'Acme Inc.'), ), array('dc', 'example'), array('dc', 'com') ); which will result in cn=John+sn=Smith+o=Acme Inc.,dc=example,dc=com
리턴 string The properly quoted string DN.

rootDSE() 공개 메소드

This either fetches a fresh rootDSE object or returns it from the internal cache for performance reasons, if possible.
public rootDSE ( array $attrs = [] ) : Horde_Ldap_RootDse
$attrs array Array of attributes to search for.
리턴 Horde_Ldap_RootDse Horde_Ldap_RootDse object

schema() 공개 메소드

Returns a schema object
public schema ( string $dn = null ) : Horde_Ldap_Schema
$dn string Subschema entry dn.
리턴 Horde_Ldap_Schema Horde_Ldap_Schema object

setConfig() 보호된 메소드

Sets the internal configuration array.
protected setConfig ( array $config )
$config array Configuration hash.

setOption() 공개 메소드

Sets an LDAP option.
public setOption ( string $option, mixed $value )
$option string Option to set.
$value mixed Value to set option to.

setVersion() 공개 메소드

Sets the LDAP protocol version that is used on the connection.
public setVersion ( integer $version, boolean $force = false )
$version integer LDAP version that should be used.
$force boolean If set to true, the check against the rootDSE will be skipped.

startTLS() 공개 메소드

Starts an encrypted session.
public startTLS ( )

utf8() 보호된 메소드

protected utf8 ( array $attributes, array $function ) : array
$attributes array Array of attributes
$function array Function to apply to attribute values
리턴 array Array of attributes with function applied to values.

utf8Decode() 공개 메소드

또한 보기: utf8Encode()
public utf8Decode ( array $attributes ) : array | Horde_Ldap_Error
$attributes array Array of attributes
리턴 array | Horde_Ldap_Error Array with decoded attribute values or Error

utf8Encode() 공개 메소드

public utf8Encode ( array $attributes ) : array | Horde_Ldap_Error
$attributes array An array of attributes.
리턴 array | Horde_Ldap_Error An array of UTF8 encoded attributes or an error.

프로퍼티 상세

$_config 보호되어 있는 프로퍼티

- hostspec: the LDAP host to connect to (may be an array of several hosts to try). - port: the server port. - version: LDAP version (defaults to 3). - tls: when set, ldap_start_tls() is run after connecting. - binddn: the DN to bind as when searching. - bindpw: password to use when searching LDAP. - basedn: LDAP base. - options: hash of LDAP options to set. - filter: default search filter. - scope: default search scope. - user: configuration parameters for {@link findUserDN()}, must contain 'uid', and may contain 'basedn' entries. - timeout: Connection timeout in seconds (defaults to 5). - auto_reconnect: if true, the class will automatically attempt to reconnect to the LDAP server in certain failure conditions when attempting a search, or other LDAP operations. Defaults to false. Note that if you set this to true, calls to search() may block indefinitely if there is a catastrophic server failure. - min_backoff: minimum reconnection delay period (in seconds). - current_backof: initial reconnection delay period (in seconds). - max_backoff: maximum reconnection delay period (in seconds). - cache a Horde_Cache instance for caching schema requests.
protected array $_config
리턴 array

$_downHostList 보호되어 있는 프로퍼티

List of hosts that are known to be down.
protected array $_downHostList
리턴 array

$_hostList 보호되어 있는 프로퍼티

List of hosts we try to establish a connection to.
protected array $_hostList
리턴 array

$_rootDSECache 보호되어 있는 프로퍼티

Hash with requested rootDSE attr names as key and rootDSE object as value. Since the RootDSE object itself may request a rootDSE object, {@link rootDSE()} caches successful requests. Internally, Horde_Ldap needs several lookups to this object, so caching increases performance significally.
protected array $_rootDSECache
리턴 array

$_schema 보호되어 있는 프로퍼티

Schema object.
또한 보기: schema()
protected Horde_Ldap_Schema $_schema
리턴 Horde_Ldap_Schema

$_schemaAttrs 보호되어 있는 프로퍼티

Cache for attribute encoding checks.
protected $_schemaAttrs

$_schemaCache 보호되어 있는 프로퍼티

Schema cache function callback.
또한 보기: registerSchemaCache()
protected string $_schemaCache
리턴 string