Class abook_ldap_server

Description

Address book backend for LDAP server

An array with the following elements must be passed to the class constructor (elements marked ? are optional)

Main settings:

    host      => LDAP server hostname, IP-address or any other URI compatible
                 with used LDAP library.
    base      => LDAP server root (base dn). Empty string allowed.
  ? port      => LDAP server TCP port number (default: 389)
  ? charset   => LDAP server charset (default: utf-8)
  ? name      => Name for LDAP server (default "LDAP: hostname")
                 Used to tag the result data
  ? maxrows   => Maximum number of rows in search result
  ? timeout   => Timeout for LDAP operations (in seconds, default - 30)
                 Might not work for all LDAP libraries or servers.
  ? binddn    => LDAP Bind DN.
  ? bindpw    => LDAP Bind Password.
  ? protocol  => LDAP Bind protocol.
Advanced settings:
  ? filter    => Filter expression to limit ldap searches
  ? limit_scope => Limits scope to base DN (Specific to Win2k3 ADS).
  ? listing   => Controls listing of LDAP directory.
  ? writeable => Controls write access to address book
  ? search_tree => Controls subtree or one level search.
  ? starttls  => Controls use of StartTLS on LDAP connections
  ? rebind    => Controls rebinding to LDAP server with userdn and password
  ? unique_id => Controls attribute used to store address book nicknames
NOTE. This class should not be used directly. Use addressbook_init() function instead.

Located in /nasmail/functions/abook_ldap_server.php (line 67)

addressbook_backend
   |
   --abook_ldap_server
Variable Summary
 string $basedn
 string $binddn
 string $bindpw
 string $bname
 string $btype
 string $charset
 string $filter
 boolean $limit_scope
 object PHP $linkid
 boolean $listing
 integer $maxrows
 integer $port
 integer $protocol
 boolean $rebind
 boolean $search_tree
 string $server
 string $sname
 boolean $starttls
 integer $timeout
 string $unique_dn
 string $unique_id
 boolean $writeable
Method Summary
 abook_ldap_server abook_ldap_server (array $param)
 boolean add (array $userdata)
 string charset_decode (string $str)
 string charset_encode (string $str)
 boolean find_unique_dn ()
 string ldapspecialchars (string $string)
 boolean ldap_add (string $dn, array $data)
 string ldap_error (string $sError)
 bool ldap_modify (string $dn, array $data, array $deleted_attribs)
 boolean ldap_remove (string $dn)
 boolean ldap_rename (string $sourcedn, string $targetdn, string $parent)
 array ldap_search (string $expression, [boolean $singleentry = false])
 array list_addr ()
 array lookup (string $alias)
 boolean modify (string $alias, array $userdata)
 bool open ([bool $new = false])
 string quotevalue (string $string)
 boolean remove (array $aliases)
 array search (string $expr)
Variables
string $basedn = '' (line 93)
  • var: LDAP base DN
string $binddn = '' (line 117)
  • var: DN to bind to (non-anonymous bind)
string $bindpw = '' (line 121)
  • var: password to bind with (non-anonymous bind)
string $bname = 'ldap_server' (line 75)
  • var: backend name

Redefinition of:
addressbook_backend::$bname
string $btype = 'remote' (line 71)
  • var: backend type

Redefinition of:
addressbook_backend::$btype
string $charset = 'utf-8' (line 97)
  • var: charset used for entries in LDAP server
string $filter = '' (line 109)
  • var: ldap filter
boolean $limit_scope = false (line 129)
  • var: limits scope to base dn
object PHP $linkid = false (line 101)
  • var: LDAP link ID
boolean $listing = false (line 133)
  • var: controls listing of directory
integer $maxrows = 250 (line 105)
  • var: max rows in result
integer $port = 389 (line 89)
  • var: LDAP server port
integer $protocol = '' (line 125)
  • var: protocol used to connect to ldap server
boolean $rebind = false (line 152)
  • var: rebind to ldap with user's dn and password
  • since: 1.3
boolean $search_tree = true (line 142)
  • var: controls ldap search type. only first level entries are displayed if set to false
string $server = '' (line 85)
  • var: LDAP server name or address or url
string $sname = 'LDAP' (line 81)
  • var: displayed name

Redefinition of:
addressbook_backend::$sname
boolean $starttls = false (line 147)
  • var: controls use of StartTLS on ldap connections. Requires php 4.2+ and protocol >= 3
integer $timeout = 30 (line 113)
  • var: timeout of LDAP operations (in seconds)
string $unique_dn = '' (line 162)
  • var: User's DN used for rebinding
  • since: 1.3
string $unique_id = '' (line 157)
  • var: unique ldap attribute
  • since: 1.3
boolean $writeable = false (line 137)
  • var: true if removing/adding/modifying entries is allowed

Redefinition of:
addressbook_backend::$writeable

Inherited Variables

Inherited from addressbook_backend

addressbook_backend::$bnum
addressbook_backend::$error
Methods
Constructor abook_ldap_server (line 168)

Constructor. Connects to database

abook_ldap_server abook_ldap_server (array $param)
  • array $param: connection options
add (line 801)

Add address

boolean add (array $userdata)
  • array $userdata: new data

Redefinition of:
addressbook_backend::add()
Adds address book entry Dummy function. Always returns false. Real backends should replace it.
charset_decode (line 370)

Decode from charset used by this LDAP server to charset used by translation

Uses SquirrelMail charset_decode functions

  • return: decoded string
string charset_decode (string $str)
  • string $str: string that has to be decoded
charset_encode (line 355)

Encode string to the charset used by this LDAP server

  • return: encoded string
string charset_encode (string $str)
  • string $str: string that has to be encoded
find_unique_dn (line 675)

Locates user's dn for rebinding

DN is saved in unique_dn property.

boolean find_unique_dn ()
ldapspecialchars (line 385)

Sanitizes ldap search strings.

See rfc2254

string ldapspecialchars (string $string)
  • string $string
ldap_add (line 544)

Add an entry to LDAP server.

Warning: You must make sure that the arguments are correctly formated and sanitize use of special ldap keywords.

  • return: result (false on error)
boolean ldap_add (string $dn, array $data)
  • string $dn: the dn of the entry to be added
  • array $data: the values of the entry to be added
ldap_error (line 657)

Get error from LDAP resource if possible

Should get error from server using the ldap_errno() and ldap_err2str() functions

  • return: error message
string ldap_error (string $sError)
  • string $sError: error message used when ldap error functions and connection resource are unavailable
ldap_modify (line 630)

Modify the values of an entry on LDAP server.

Warning: You must make sure that the arguments are correctly formated and sanitize use of special ldap keywords.

  • return: result (false on error)
bool ldap_modify (string $dn, array $data, array $deleted_attribs)
  • string $dn: the dn of the entry to be modified
  • array $data: the new values of the entry
  • array $deleted_attribs: attributes that should be deleted.
ldap_remove (line 566)

Remove an entry from LDAP server.

Warning: You must make sure that the argument is correctly formated and sanitize use of special ldap keywords.

  • return: result (false on error)
boolean ldap_remove (string $dn)
  • string $dn: the dn of the entry to remove
ldap_rename (line 590)

Rename an entry on LDAP server.

Warning: You must make sure that the arguments are correctly formated and sanitize use of special ldap keywords.

  • return: result (false on error)
boolean ldap_rename (string $sourcedn, string $targetdn, string $parent)
  • string $sourcedn: the dn of the entry to be renamed
  • string $targetdn: the dn which $sourcedn should be renamed to
  • string $parent: the dn of the parent entry
ldap_search (line 419)

Search LDAP server.

Warning: You must make sure that ldap query is correctly formated and sanitize use of special ldap keywords.

  • return: search results (false on error)
array ldap_search (string $expression, [boolean $singleentry = false])
  • string $expression: ldap query
  • boolean $singleentry: whether we are looking for a single entry. Boolean true forces LDAP_SCOPE_BASE search.
list_addr (line 780)

List all entries present in LDAP server

maxrows setting might limit list of returned entries. Careful with this -- it could get quite large for big sites.

  • return: all entries in ldap server
array list_addr ()

Redefinition of:
addressbook_backend::list_addr()
Lists all address book entries stored in backend Dummy function. Always returns false. Real backends should replace it.
lookup (line 751)

Lookup an alias

  • return: search results
array lookup (string $alias)
  • string $alias: alias

Redefinition of:
addressbook_backend::lookup()
Look for exact address book entry match Dummy function. Always returns false. Real backends should replace it.
modify (line 891)

Modify address

boolean modify (string $alias, array $userdata)
  • string $alias: modified alias
  • array $userdata: new data

Redefinition of:
addressbook_backend::modify()
Modifies address book entry Dummy function. Always returns false. Real backends should replace it.
open (line 257)

Open the LDAP server.

bool open ([bool $new = false])
  • bool $new: is it a new connection
quotevalue (line 404)

Prepares user input for use in a ldap query.

Function converts input string to character set used in LDAP server (charset_encode() method) and sanitizes it (ldapspecialchars()).

  • return: ldap encoded string
string quotevalue (string $string)
  • string $string: string to encode
remove (line 864)

Delete address

boolean remove (array $aliases)
  • array $aliases: array of entries that have to be removed.

Redefinition of:
addressbook_backend::remove()
Deletes address book entries Dummy function. Always returns false. Real backends should replace it.
search (line 717)

Search the LDAP server

  • return: search results
array search (string $expr)
  • string $expr: search expression

Redefinition of:
addressbook_backend::search()
Search address book backend for expression Dummy function. Always returns false. Real backends should replace it.

Inherited Methods

Inherited From addressbook_backend

 addressbook_backend::add()
 addressbook_backend::fullname()
 addressbook_backend::list_addr()
 addressbook_backend::lookup()
 addressbook_backend::modify()
 addressbook_backend::remove()
 addressbook_backend::search()
 addressbook_backend::set_error()

Documentation generated on Sun, 22 Nov 2009 17:36:13 +0200 by phpDocumentor 1.4.3