Projects
Kolab:3.4
php-pear-Net-LDAP2
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 10
View file
php5-pear-Net_LDAP2.changes
Added
@@ -0,0 +1,33 @@ +------------------------------------------------------------------- +Fri Feb 1 11:11:32 UTC 2013 - aj@ajaissle.de + +- New upstream release 2.0.12 + * inmproved performance with large search results + * Fixed some minor issues with Net_LDAP2_Filter and Net_LDAP2->dnExists() + * Added NOT filter to Net_LDAP2_Filter::create() so negating is more easily now + +------------------------------------------------------------------- +Mon Feb 13 10:53:31 UTC 2012 - coolo@suse.com + +- patch license to follow spdx.org standard + +------------------------------------------------------------------- +Mon Feb 7 15:38:50 UTC 2011 - lang@b1-systems.de + +- Added license file + +------------------------------------------------------------------- +Mon Jan 31 09:08:32 UTC 2011 - lang@b1-systems.de + +- LGPLv3 license + +------------------------------------------------------------------- +Wed Jan 26 13:32:09 UTC 2011 - lang@b1-systems.de + +- add dependency on php pecl module ldap as stated in pear + +------------------------------------------------------------------- +Wed Jan 26 12:42:44 UTC 2011 - lang@b1-systems.de + +- packaged with php-macros and a template spec +
View file
php-pear-Net-LDAP2.spec
Deleted
@@ -1,121 +0,0 @@ -%{!?__pear: %{expand: %%global __pear %{_bindir}/pear}} - -# Needed for openSUSE -%if 0%{?suse_version} -%{!?pear_cfgdir: %global pear_cfgdir %(%{__pear} config-get cfg_dir 2> /dev/null || echo undefined)} -%{!?pear_datadir: %global pear_datadir %(%{__pear} config-get data_dir 2> /dev/null || echo undefined)} -%{!?pear_docdir: %global pear_docdir %(%{__pear} config-get doc_dir 2> /dev/null || echo undefined)} -%{!?pear_metadir: %global pear_metadir %(%{__pear} config-get metadata_dir 2> /dev/null || echo undefined)} -%{!?pear_phpdir: %global pear_phpdir %(%{__pear} config-get php_dir 2> /dev/null || echo undefined)} -%{!?pear_testdir: %global pear_testdir %(%{__pear} config-get test_dir 2> /dev/null || echo undefined)} -%{!?pear_wwwdir: %global pear_wwwdir %(%{__pear} config-get www_dir 2> /dev/null || echo undefined)} -%{!?pear_xmldir: %global pear_xmldir %{_localstatedir}/lib/pear/pkgxml} -%endif - -%global pear_name Net_LDAP2 - -%if 0%{?suse_version} -Name: php5-pear-Net_LDAP2 -%else -Name: php-pear-Net-LDAP2 -%endif -Version: 2.0.9 -Release: 3%{?dist} -Summary: Object oriented interface for searching and manipulating LDAP-entries -Group: Development/Libraries -License: LGPLv3 -URL: http://pear.php.net/package/Net_LDAP2 -Source0: http://pear.php.net/get/%{pear_name}-%{version}.tgz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildArch: noarch - -BuildRequires: php-pear - -Requires(post): %{__pear} -Requires(postun): %{__pear} -Requires: php-pear - -Provides: php-pear(%{pear_name}) = %{version}-%{release} - -%description -Net_LDAP2 is the successor of Net_LDAP which is a clone of Perls Net::LDAP -object interface to directory servers. It does contain most of Net::LDAPs -features but has some own too. -With Net_LDAP2 you have: -* A simple object-oriented interface to connections, searches entries and filters. -* Support for tls and ldap v3. -* Simple modification, deletion and creation of ldap entries. -* Support for schema handling. - -Net_LDAP2 layers itself on top of PHP's existing ldap extensions. - -%prep -%setup -q -c - -mv package.xml %{pear_name}-%{version}/%{pear_name}.xml - - -%build -cd %{pear_name}-%{version} -# Empty build section, most likely nothing required. - - -%install -rm -rf %{buildroot} docdir - -pushd %{pear_name}-%{version} -%{__pear} install --nodeps --packagingroot %{buildroot} %{pear_name}.xml - -# Clean up unnecessary files -rm -rf %{buildroot}%{pear_phpdir}/.??* - -# Install XML package description -%{__mkdir_p} %{buildroot}%{pear_xmldir} -%{__install} -pm 644 %{pear_name}.xml %{buildroot}%{pear_xmldir} - -popd - -# For troubleshooting macros: - -echo "pear_metadir: '%{pear_metadir}'" - -%check -# Sanity check -lst=$(find %{buildroot}%{pear_phpdir} -exec grep -q %{buildroot} {} \; -print) -[ ! -z "$lst" ] && echo "Reference to BUILDROOT in $lst" && exit 1; - -%clean -rm -rf %{buildroot} - -%post -%{__pear} install --nodeps --soft --force --register-only \ - %{pear_xmldir}/%{pear_name}.xml >/dev/null || : - -%postun -if [ $1 -eq 0 ] ; then - %{__pear} uninstall --nodeps --ignore-errors --register-only \ - %{pear_name} >/dev/null || : -fi - -%files -%defattr(-,root,root,-) -%doc %{pear_docdir}/%{pear_name} -%dir %{pear_phpdir}/Net -%{pear_phpdir}/Net/LDAP2 -%{pear_phpdir}/Net/LDAP2.php -%{pear_testdir}/%{pear_name} -%if 0%{?suse_version} -%dir %{pear_xmldir} -%endif -%{pear_xmldir}/%{pear_name}.xml -%if 0%{?rhel} < 1 -%{pear_metadir}/.registry/net_ldap2.reg -%exclude %{pear_metadir} -%endif - -%changelog -* Sat Jun 05 2010 Christoph Wickert <wickert@kolabsys.com> - 2.0.9-3 -- Adjust requirements for php-channel(pear.horde.org) - -* Sun May 9 2010 Jeroen van Meeuwen <vanmeeuwen@kolabsys.com> - 2.0.9-2 -- Package for Fedora/EPEL
View file
php5-pear-Net_LDAP2.spec
Added
@@ -0,0 +1,114 @@ +# +# spec file for package php5-pear-Net_LDAP2 +# +# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + + +Name: php5-pear-Net_LDAP2 +%define pear_name Net_LDAP2 +%define pear_sname net_ldap2 +Summary: Object oriented interface for searching and manipulating LDAP-entries +License: LGPL-3.0 +Group: Productivity/Networking/Web/Servers +Version: 2.0.12 +Release: 0 +BuildArch: noarch +Url: http://pear.php.net/package/%{pear_name} +Source0: %{pear_name}-%{version}.tgz +Source1: LICENSE + +BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: php >= 5.0 +%if 0%{?sles_version} == 10 +BuildRequires: php-macros +%else +BuildRequires: php-devel >= 5.0 +%endif +BuildRequires: php-pear >= 1.5.0 +Requires: php >= 5.0 +Requires: php-pear >= 1.5.0 +Requires: php-ldap +#pecl extension. No separate project, comes with php5 project + +Provides: php-pear-%{pear_name} pear-%{pear_name} +# Fix for renaming (package convention) +Provides: php5-pear-%{pear_sname} = %{version} +Provides: php-pear-%{pear_sname} = %{version} +Provides: pear-%{pear_sname} = %{version} +Obsoletes: php5-pear-%{pear_sname} < %{version} +Obsoletes: php-pear-%{pear_sname} < %{version} +Obsoletes: pear-%{pear_sname} < %{version} + +%description +Net_LDAP2 is the successor of Net_LDAP which is a clone of Perls Net::LDAPobject interface to directory servers. +It does contain most of Net::LDAP's features but has some own too. +With Net_LDAP2 you have: + * A simple object-oriented interface to connections, searches entries and filters. + * Support for tls and ldap v3. + * Simple modification, deletion and creation of ldap entries. + * Support for schema handling. + +Net_LDAP2 layers itself on top of PHP's existing ldap extensions. + +%prep + +%setup -c +%{__cp} %{SOURCE1} . + +%build + +%install +%{__mv} package*.xml %{pear_name}-%{version} +cd %{pear_name}-%{version} +PHP_PEAR_PHP_BIN="$(which php) -d memory_limit=50m" +%{__pear} -v \ + -d doc_dir=/doc \ + -d bin_dir=%{_bindir} \ + -d data_dir=%{php_peardir}/data \ + install --force --offline --nodeps -R "%{buildroot}" package.xml + +%{__install} -D -m 0644 package.xml %{buildroot}%{php_pearxmldir}/%{pear_name}.xml + +%{__rm} -rf %{buildroot}/{doc,tmp} +%{__rm} -rf %{buildroot}%{php_peardir}/.{filemap,lock,registry,channels,depdb,depdblock} + +cd .. + +%php_pear_gen_filelist + +%post +# on `rpm -ivh` PARAM is 1 +# on `rpm -Uvh` PARAM is 2 +if [ "$1" = "1" ]; then + %{__pear} install --nodeps --soft --force --register-only %{php_pearxmldir}/%{pear_name}.xml +fi +if [ "$1" = "2" ]; then + %{__pear} upgrade --offline --register-only %{php_pearxmldir}/%{pear_name}.xml +fi + +%postun +# on `rpm -e` PARAM is 0 +if [ "$1" = "0" ]; then + %{__pear} uninstall --nodeps --ignore-errors --register-only pear.php.net/%{pear_name} +fi + +%clean +%{__rm} -rf %{buildroot} + +%files -f %{name}.files +%defattr(-, root, root) +%doc LICENSE + +%changelog
View file
LICENSE
Added
@@ -0,0 +1,166 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. +
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/Net/LDAP2.php
Added
@@ -0,0 +1,1799 @@ +<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +/** +* File containing the Net_LDAP2 interface class. +* +* PHP version 5 +* +* @category Net +* @package Net_LDAP2 +* @author Tarjej Huse <tarjei@bergfald.no> +* @author Jan Wagner <wagner@netsols.de> +* @author Del <del@babel.com.au> +* @author Benedikt Hallinger <beni@php.net> +* @copyright 2003-2007 Tarjej Huse, Jan Wagner, Del Elson, Benedikt Hallinger +* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3 +* @version SVN: $Id: LDAP2.php 318473 2011-10-27 13:39:13Z beni $ +* @link http://pear.php.net/package/Net_LDAP2/ +*/ + +/** +* Package includes. +*/ +require_once 'PEAR.php'; +require_once 'Net/LDAP2/RootDSE.php'; +require_once 'Net/LDAP2/Schema.php'; +require_once 'Net/LDAP2/Entry.php'; +require_once 'Net/LDAP2/Search.php'; +require_once 'Net/LDAP2/Util.php'; +require_once 'Net/LDAP2/Filter.php'; +require_once 'Net/LDAP2/LDIF.php'; +require_once 'Net/LDAP2/SchemaCache.interface.php'; +require_once 'Net/LDAP2/SimpleFileSchemaCache.php'; + +/** +* Error constants for errors that are not LDAP errors. +*/ +define('NET_LDAP2_ERROR', 1000); + +/** +* Net_LDAP2 Version +*/ +define('NET_LDAP2_VERSION', '2.0.10'); + +/** +* Net_LDAP2 - manipulate LDAP servers the right way! +* +* @category Net +* @package Net_LDAP2 +* @author Tarjej Huse <tarjei@bergfald.no> +* @author Jan Wagner <wagner@netsols.de> +* @author Del <del@babel.com.au> +* @author Benedikt Hallinger <beni@php.net> +* @copyright 2003-2007 Tarjej Huse, Jan Wagner, Del Elson, Benedikt Hallinger +* @license http://www.gnu.org/copyleft/lesser.html LGPL +* @link http://pear.php.net/package/Net_LDAP2/ +*/ +class Net_LDAP2 extends PEAR +{ + /** + * Class configuration array + * + * host = the ldap host to connect to + * (may be an array of several hosts to try) + * port = the server port + * version = ldap version (defaults to v 3) + * starttls = when set, ldap_start_tls() is run after connecting. + * bindpw = no explanation needed + * binddn = the DN to bind as. + * basedn = ldap base + * options = hash of ldap options to set (opt => val) + * filter = default search filter + * scope = default search scope + * + * Newly added in 2.0.0RC4, for auto-reconnect: + * auto_reconnect = if set to true then the class will automatically + * attempt to reconnect to the LDAP server in certain + * failure conditionswhen attempting a search, or other + * LDAP operation. 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_backoff = initial reconnection delay period (in seconds). + * max_backoff = maximum reconnection delay period (in seconds). + * + * @access protected + * @var array + */ + protected $_config = array('host' => 'localhost', + 'port' => 389, + 'version' => 3, + 'starttls' => false, + 'binddn' => '', + 'bindpw' => '', + 'basedn' => '', + 'options' => array(), + 'filter' => '(objectClass=*)', + 'scope' => 'sub', + 'auto_reconnect' => false, + 'min_backoff' => 1, + 'current_backoff' => 1, + 'max_backoff' => 32); + + /** + * List of hosts we try to establish a connection to + * + * @access protected + * @var array + */ + protected $_host_list = array(); + + /** + * List of hosts that are known to be down. + * + * @access protected + * @var array + */ + protected $_down_host_list = array(); + + /** + * LDAP resource link. + * + * @access protected + * @var resource + */ + protected $_link = false; + + /** + * Net_LDAP2_Schema object + * + * This gets set and returned by {@link schema()} + * + * @access protected + * @var object Net_LDAP2_Schema + */ + protected $_schema = null; + + /** + * Schema cacher function callback + * + * @see registerSchemaCache() + * @var string + */ + protected $_schema_cache = null; + + /** + * Cache for attribute encoding checks + * + * @access protected + * @var array Hash with attribute names as key and boolean value + * to determine whether they should be utf8 encoded or not. + */ + protected $_schemaAttrs = array(); + + /** + * Cache for rootDSE objects + * + * 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, Net_LDAP2 needs several lookups to this object, so + * caching increases performance significally. + * + * @access protected + * @var array + */ + protected $_rootDSE_cache = array(); + + /** + * Returns the Net_LDAP2 Release version, may be called statically + * + * @static + * @return string Net_LDAP2 version + */ + public static function getVersion() + { + return NET_LDAP2_VERSION; + } + + /** + * Configure Net_LDAP2, connect and bind + * + * Use this method as starting point of using Net_LDAP2 + * to establish a connection to your LDAP server. + * + * Static function that returns either an error object or the new Net_LDAP2 + * object. Something like a factory. Takes a config array with the needed + * parameters. + * + * @param array $config Configuration array + * + * @access public + * @return Net_LDAP2_Error|Net_LDAP2 Net_LDAP2_Error or Net_LDAP2 object + */ + public static function &connect($config = array()) + { + $ldap_check = self::checkLDAPExtension(); + if (self::iserror($ldap_check)) { + return $ldap_check;
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/Net/LDAP2/Entry.php
Added
@@ -0,0 +1,1069 @@ +<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +/** +* File containing the Net_LDAP2_Entry interface class. +* +* PHP version 5 +* +* @category Net +* @package Net_LDAP2 +* @author Jan Wagner <wagner@netsols.de> +* @author Tarjej Huse <tarjei@bergfald.no> +* @author Benedikt Hallinger <beni@php.net> +* @copyright 2009 Tarjej Huse, Jan Wagner, Benedikt Hallinger +* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3 +* @version SVN: $Id: Entry.php 307580 2011-01-19 12:32:05Z beni $ +* @link http://pear.php.net/package/Net_LDAP2/ +*/ + +/** +* Includes +*/ +require_once 'PEAR.php'; +require_once 'Net/LDAP2/Util.php'; + +/** +* Object representation of a directory entry +* +* This class represents a directory entry. You can add, delete, replace +* attributes and their values, rename the entry, delete the entry. +* +* @category Net +* @package Net_LDAP2 +* @author Jan Wagner <wagner@netsols.de> +* @author Tarjej Huse <tarjei@bergfald.no> +* @author Benedikt Hallinger <beni@php.net> +* @license http://www.gnu.org/copyleft/lesser.html LGPL +* @link http://pear.php.net/package/Net_LDAP2/ +*/ +class Net_LDAP2_Entry extends PEAR +{ + /** + * Entry ressource identifier + * + * @access protected + * @var ressource + */ + protected $_entry = null; + + /** + * LDAP ressource identifier + * + * @access protected + * @var ressource + */ + protected $_link = null; + + /** + * Net_LDAP2 object + * + * This object will be used for updating and schema checking + * + * @access protected + * @var object Net_LDAP2 + */ + protected $_ldap = null; + + /** + * Distinguished name of the entry + * + * @access protected + * @var string + */ + protected $_dn = null; + + /** + * Attributes + * + * @access protected + * @var array + */ + protected $_attributes = array(); + + /** + * Original attributes before any modification + * + * @access protected + * @var array + */ + protected $_original = array(); + + + /** + * Map of attribute names + * + * @access protected + * @var array + */ + protected $_map = array(); + + + /** + * Is this a new entry? + * + * @access protected + * @var boolean + */ + protected $_new = true; + + /** + * New distinguished name + * + * @access protected + * @var string + */ + protected $_newdn = null; + + /** + * Shall the entry be deleted? + * + * @access protected + * @var boolean + */ + protected $_delete = false; + + /** + * Map with changes to the entry + * + * @access protected + * @var array + */ + protected $_changes = array("add" => array(), + "delete" => array(), + "replace" => array() + ); + /** + * Internal Constructor + * + * Constructor of the entry. Sets up the distinguished name and the entries + * attributes. + * You should not call this method manually! Use {@link Net_LDAP2_Entry::createFresh()} + * or {@link Net_LDAP2_Entry::createConnected()} instead! + * + * @param Net_LDAP2|ressource|array &$ldap Net_LDAP2 object, ldap-link ressource or array of attributes + * @param string|ressource $entry Either a DN or a LDAP-Entry ressource + * + * @access protected + * @return none + */ + protected function __construct(&$ldap, $entry = null) + { + $this->PEAR('Net_LDAP2_Error'); + + // set up entry resource or DN + if (is_resource($entry)) { + $this->_entry = &$entry; + } else { + $this->_dn = $entry; + } + + // set up LDAP link + if ($ldap instanceof Net_LDAP2) { + $this->_ldap = &$ldap; + $this->_link = $ldap->getLink(); + } elseif (is_resource($ldap)) { + $this->_link = $ldap; + } elseif (is_array($ldap)) { + // Special case: here $ldap is an array of attributes, + // this means, we have no link. This is a "virtual" entry. + // We just set up the attributes so one can work with the object + // as expected, but an update() fails unless setLDAP() is called. + $this->setAttributes($ldap); + } + + // if this is an entry existing in the directory, + // then set up as old and fetch attrs + if (is_resource($this->_entry) && is_resource($this->_link)) { + $this->_new = false; + $this->_dn = @ldap_get_dn($this->_link, $this->_entry); + $this->setAttributes(); // fetch attributes from server + } + } + + /** + * Creates a fresh entry that may be added to the directory later on + * + * Use this method, if you want to initialize a fresh entry. + * + * The method should be called statically: $entry = Net_LDAP2_Entry::createFresh(); + * You should put a 'objectClass' attribute into the $attrs so the directory server + * knows which object you want to create. However, you may omit this in case you + * don't want to add this entry to a directory server. + * + * The attributes parameter is as following: + * <code> + * $attrs = array( 'attribute1' => array('value1', 'value2'), + * 'attribute2' => 'single value' + * ); + * </code> + *
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/Net/LDAP2/Filter.php
Added
@@ -0,0 +1,547 @@ +<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +/** +* File containing the Net_LDAP2_Filter interface class. +* +* PHP version 5 +* +* @category Net +* @package Net_LDAP2 +* @author Benedikt Hallinger <beni@php.net> +* @copyright 2009 Benedikt Hallinger +* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3 +* @version SVN: $Id: Filter.php 318470 2011-10-27 12:57:05Z beni $ +* @link http://pear.php.net/package/Net_LDAP2/ +*/ + +/** +* Includes +*/ +require_once 'PEAR.php'; +require_once 'Net/LDAP2/Util.php'; + +/** +* Object representation of a part of a LDAP filter. +* +* This Class is not completely compatible to the PERL interface! +* +* The purpose of this class is, that users can easily build LDAP filters +* without having to worry about right escaping etc. +* A Filter is built using several independent filter objects +* which are combined afterwards. This object works in two +* modes, depending how the object is created. +* If the object is created using the {@link create()} method, then this is a leaf-object. +* If the object is created using the {@link combine()} method, then this is a container object. +* +* LDAP filters are defined in RFC-2254 and can be found under +* {@link http://www.ietf.org/rfc/rfc2254.txt} +* +* Here a quick copy&paste example: +* <code> +* $filter0 = Net_LDAP2_Filter::create('stars', 'equals', '***'); +* $filter_not0 = Net_LDAP2_Filter::combine('not', $filter0); +* +* $filter1 = Net_LDAP2_Filter::create('gn', 'begins', 'bar'); +* $filter2 = Net_LDAP2_Filter::create('gn', 'ends', 'baz'); +* $filter_comp = Net_LDAP2_Filter::combine('or',array($filter_not0, $filter1, $filter2)); +* +* echo $filter_comp->asString(); +* // This will output: (|(!(stars=\0x5c0x2a\0x5c0x2a\0x5c0x2a))(gn=bar*)(gn=*baz)) +* // The stars in $filter0 are treaten as real stars unless you disable escaping. +* </code> +* +* @category Net +* @package Net_LDAP2 +* @author Benedikt Hallinger <beni@php.net> +* @license http://www.gnu.org/copyleft/lesser.html LGPL +* @link http://pear.php.net/package/Net_LDAP2/ +*/ +class Net_LDAP2_Filter extends PEAR +{ + /** + * Storage for combination of filters + * + * This variable holds a array of filter objects + * that should be combined by this filter object. + * + * @access protected + * @var array + */ + protected $_subfilters = array(); + + /** + * Match of this filter + * + * If this is a leaf filter, then a matching rule is stored, + * if it is a container, then it is a logical operator + * + * @access protected + * @var string + */ + protected $_match; + + /** + * Single filter + * + * If we operate in leaf filter mode, + * then the constructing method stores + * the filter representation here + * + * @acces private + * @var string + */ + protected $_filter; + + /** + * Create a new Net_LDAP2_Filter object and parse $filter. + * + * This is for PERL Net::LDAP interface. + * Construction of Net_LDAP2_Filter objects should happen through either + * {@link create()} or {@link combine()} which give you more control. + * However, you may use the perl iterface if you already have generated filters. + * + * @param string $filter LDAP filter string + * + * @see parse() + */ + public function __construct($filter = false) + { + // The optional parameter must remain here, because otherwise create() crashes + if (false !== $filter) { + $filter_o = self::parse($filter); + if (PEAR::isError($filter_o)) { + $this->_filter = $filter_o; // assign error, so asString() can report it + } else { + $this->_filter = $filter_o->asString(); + } + } + } + + /** + * Constructor of a new part of a LDAP filter. + * + * The following matching rules exists: + * - equals: One of the attributes values is exactly $value + * Please note that case sensitiviness is depends on the + * attributes syntax configured in the server. + * - begins: One of the attributes values must begin with $value + * - ends: One of the attributes values must end with $value + * - contains: One of the attributes values must contain $value + * - present | any: The attribute can contain any value but must be existent + * - greater: The attributes value is greater than $value + * - less: The attributes value is less than $value + * - greaterOrEqual: The attributes value is greater or equal than $value + * - lessOrEqual: The attributes value is less or equal than $value + * - approx: One of the attributes values is similar to $value + * + * Negation ("not") can be done by prepending the above operators with the + * "not" or "!" keyword, see example below. + * + * If $escape is set to true (default) then $value will be escaped + * properly. If it is set to false then $value will be treaten as raw filter value string. + * You should escape yourself using {@link Net_LDAP2_Util::escape_filter_value()}! + * + * Examples: + * <code> + * // This will find entries that contain an attribute "sn" that ends with "foobar": + * $filter = Net_LDAP2_Filter::create('sn', 'ends', 'foobar'); + * + * // This will find entries that contain an attribute "sn" that has any value set: + * $filter = Net_LDAP2_Filter::create('sn', 'any'); + * + * // This will build a negated equals filter: + * $filter = Net_LDAP2_Filter::create('sn', 'not equals', 'foobar'); + * </code> + * + * @param string $attr_name Name of the attribute the filter should apply to + * @param string $match Matching rule (equals, begins, ends, contains, greater, less, greaterOrEqual, lessOrEqual, approx, any) + * @param string $value (optional) if given, then this is used as a filter + * @param boolean $escape Should $value be escaped? (default: yes, see {@link Net_LDAP2_Util::escape_filter_value()} for detailed information) + * + * @return Net_LDAP2_Filter|Net_LDAP2_Error + */ + public static function &create($attr_name, $match, $value = '', $escape = true) + { + $leaf_filter = new Net_LDAP2_Filter(); + if ($escape) { + $array = Net_LDAP2_Util::escape_filter_value(array($value)); + $value = $array[0]; + } + + $match = strtolower($match); + + // detect negation + $neg_matches = array(); + $negate_filter = false; + if (preg_match('/^(?:not|!)[\s_-](.+)/', $match, $neg_matches)) { + $negate_filter = true; + $match = $neg_matches[1]; + } + + // build basic filter + switch ($match) { + case 'equals': + case '=': + case '==': + $leaf_filter->_filter = '(' . $attr_name . '=' . $value . ')'; + break; + case 'begins': + $leaf_filter->_filter = '(' . $attr_name . '=' . $value . '*)'; + break; + case 'ends': + $leaf_filter->_filter = '(' . $attr_name . '=*' . $value . ')'; + break; + case 'contains': + $leaf_filter->_filter = '(' . $attr_name . '=*' . $value . '*)'; + break; + case 'greater': + case '>': + $leaf_filter->_filter = '(' . $attr_name . '>' . $value . ')';
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/Net/LDAP2/LDIF.php
Added
@@ -0,0 +1,924 @@ +<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +/** +* File containing the Net_LDAP2_LDIF interface class. +* +* PHP version 5 +* +* @category Net +* @package Net_LDAP2 +* @author Benedikt Hallinger <beni@php.net> +* @copyright 2009 Benedikt Hallinger +* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3 +* @version SVN: $Id: LDIF.php 302696 2010-08-23 12:48:07Z beni $ +* @link http://pear.php.net/package/Net_LDAP2/ +*/ + +/** +* Includes +*/ +require_once 'PEAR.php'; +require_once 'Net/LDAP2.php'; +require_once 'Net/LDAP2/Entry.php'; +require_once 'Net/LDAP2/Util.php'; + +/** +* LDIF capabilitys for Net_LDAP2, closely taken from PERLs Net::LDAP +* +* It provides a means to convert between Net_LDAP2_Entry objects and LDAP entries +* represented in LDIF format files. Reading and writing are supported and may +* manipulate single entries or lists of entries. +* +* Usage example: +* <code> +* // Read and parse an ldif-file into Net_LDAP2_Entry objects +* // and print out the DNs. Store the entries for later use. +* require 'Net/LDAP2/LDIF.php'; +* $options = array( +* 'onerror' => 'die' +* ); +* $entries = array(); +* $ldif = new Net_LDAP2_LDIF('test.ldif', 'r', $options); +* do { +* $entry = $ldif->read_entry(); +* $dn = $entry->dn(); +* echo " done building entry: $dn\n"; +* array_push($entries, $entry); +* } while (!$ldif->eof()); +* $ldif->done(); +* +* +* // write those entries to another file +* $ldif = new Net_LDAP2_LDIF('test.out.ldif', 'w', $options); +* $ldif->write_entry($entries); +* $ldif->done(); +* </code> +* +* @category Net +* @package Net_LDAP2 +* @author Benedikt Hallinger <beni@php.net> +* @license http://www.gnu.org/copyleft/lesser.html LGPL +* @link http://pear.php.net/package/Net_LDAP22/ +* @see http://www.ietf.org/rfc/rfc2849.txt +* @todo Error handling should be PEARified +* @todo LDAPv3 controls are not implemented yet +*/ +class Net_LDAP2_LDIF extends PEAR +{ + /** + * Options + * + * @access protected + * @var array + */ + protected $_options = array('encode' => 'base64', + 'onerror' => null, + 'change' => 0, + 'lowercase' => 0, + 'sort' => 0, + 'version' => null, + 'wrap' => 78, + 'raw' => '' + ); + + /** + * Errorcache + * + * @access protected + * @var array + */ + protected $_error = array('error' => null, + 'line' => 0 + ); + + /** + * Filehandle for read/write + * + * @access protected + * @var array + */ + protected $_FH = null; + + /** + * Says, if we opened the filehandle ourselves + * + * @access protected + * @var array + */ + protected $_FH_opened = false; + + /** + * Linecounter for input file handle + * + * @access protected + * @var array + */ + protected $_input_line = 0; + + /** + * counter for processed entries + * + * @access protected + * @var int + */ + protected $_entrynum = 0; + + /** + * Mode we are working in + * + * Either 'r', 'a' or 'w' + * + * @access protected + * @var string + */ + protected $_mode = false; + + /** + * Tells, if the LDIF version string was already written + * + * @access protected + * @var boolean + */ + protected $_version_written = false; + + /** + * Cache for lines that have build the current entry + * + * @access protected + * @var boolean + */ + protected $_lines_cur = array(); + + /** + * Cache for lines that will build the next entry + * + * @access protected + * @var boolean + */ + protected $_lines_next = array(); + + /** + * Open LDIF file for reading or for writing + * + * new (FILE): + * Open the file read-only. FILE may be the name of a file + * or an already open filehandle. + * If the file doesn't exist, it will be created if in write mode. + * + * new (FILE, MODE, OPTIONS): + * Open the file with the given MODE (see PHPs fopen()), eg "w" or "a". + * FILE may be the name of a file or an already open filehandle. + * PERLs Net_LDAP2 "FILE|" mode does not work curently. + * + * OPTIONS is an associative array and may contain: + * encode => 'none' | 'canonical' | 'base64' + * Some DN values in LDIF cannot be written verbatim and have to be encoded in some way: + * 'none' No encoding. + * 'canonical' See "canonical_dn()" in Net::LDAP::Util. + * 'base64' Use base64. (default, this differs from the Perl interface. + * The perl default is "none"!) + * + * onerror => 'die' | 'warn' | NULL + * Specify what happens when an error is detected. + * 'die' Net_LDAP2_LDIF will croak with an appropriate message. + * 'warn' Net_LDAP2_LDIF will warn (echo) with an appropriate message. + * NULL Net_LDAP2_LDIF will not warn (default), use error(). + * + * change => 1 + * Write entry changes to the LDIF file instead of the entries itself. I.e. write LDAP + * operations acting on the entries to the file instead of the entries contents. + * This writes the changes usually carried out by an update() to the LDIF file. + * + * lowercase => 1 + * Convert attribute names to lowercase when writing. + * + * sort => 1 + * Sort attribute names when writing entries according to the rule: + * objectclass first then all other attributes alphabetically sorted by attribute name + * + * version => '1'
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/Net/LDAP2/RootDSE.php
Changed
(renamed from Net_LDAP2-2.0.9/Net/LDAP2/RootDSE.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/Net/LDAP2/Schema.php
Added
@@ -0,0 +1,622 @@ +<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +/** +* File containing the Net_LDAP2_Schema interface class. +* +* PHP version 5 +* +* @category Net +* @package Net_LDAP2 +* @author Jan Wagner <wagner@netsols.de> +* @author Benedikt Hallinger <beni@php.net> +* @copyright 2009 Jan Wagner, Benedikt Hallinger +* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3 +* @version SVN: $Id: Schema.php 296515 2010-03-22 14:46:41Z beni $ +* @link http://pear.php.net/package/Net_LDAP2/ +* @todo see the comment at the end of the file +*/ + +/** +* Includes +*/ +require_once 'PEAR.php'; + +/** +* Syntax definitions +* +* Please don't forget to add binary attributes to isBinary() below +* to support proper value fetching from Net_LDAP2_Entry +*/ +define('NET_LDAP2_SYNTAX_BOOLEAN', '1.3.6.1.4.1.1466.115.121.1.7'); +define('NET_LDAP2_SYNTAX_DIRECTORY_STRING', '1.3.6.1.4.1.1466.115.121.1.15'); +define('NET_LDAP2_SYNTAX_DISTINGUISHED_NAME', '1.3.6.1.4.1.1466.115.121.1.12'); +define('NET_LDAP2_SYNTAX_INTEGER', '1.3.6.1.4.1.1466.115.121.1.27'); +define('NET_LDAP2_SYNTAX_JPEG', '1.3.6.1.4.1.1466.115.121.1.28'); +define('NET_LDAP2_SYNTAX_NUMERIC_STRING', '1.3.6.1.4.1.1466.115.121.1.36'); +define('NET_LDAP2_SYNTAX_OID', '1.3.6.1.4.1.1466.115.121.1.38'); +define('NET_LDAP2_SYNTAX_OCTET_STRING', '1.3.6.1.4.1.1466.115.121.1.40'); + +/** +* Load an LDAP Schema and provide information +* +* This class takes a Subschema entry, parses this information +* and makes it available in an array. Most of the code has been +* inspired by perl-ldap( http://perl-ldap.sourceforge.net). +* You will find portions of their implementation in here. +* +* @category Net +* @package Net_LDAP2 +* @author Jan Wagner <wagner@netsols.de> +* @author Benedikt Hallinger <beni@php.net> +* @license http://www.gnu.org/copyleft/lesser.html LGPL +* @link http://pear.php.net/package/Net_LDAP22/ +*/ +class Net_LDAP2_Schema extends PEAR +{ + /** + * Map of entry types to ldap attributes of subschema entry + * + * @access public + * @var array + */ + public $types = array( + 'attribute' => 'attributeTypes', + 'ditcontentrule' => 'dITContentRules', + 'ditstructurerule' => 'dITStructureRules', + 'matchingrule' => 'matchingRules', + 'matchingruleuse' => 'matchingRuleUse', + 'nameform' => 'nameForms', + 'objectclass' => 'objectClasses', + 'syntax' => 'ldapSyntaxes' + ); + + /** + * Array of entries belonging to this type + * + * @access protected + * @var array + */ + protected $_attributeTypes = array(); + protected $_matchingRules = array(); + protected $_matchingRuleUse = array(); + protected $_ldapSyntaxes = array(); + protected $_objectClasses = array(); + protected $_dITContentRules = array(); + protected $_dITStructureRules = array(); + protected $_nameForms = array(); + + + /** + * hash of all fetched oids + * + * @access protected + * @var array + */ + protected $_oids = array(); + + /** + * Tells if the schema is initialized + * + * @access protected + * @var boolean + * @see parse(), get() + */ + protected $_initialized = false; + + + /** + * Constructor of the class + * + * @access protected + */ + protected function __construct() + { + $this->PEAR('Net_LDAP2_Error'); // default error class + } + + /** + * Fetch the Schema from an LDAP connection + * + * @param Net_LDAP2 $ldap LDAP connection + * @param string $dn (optional) Subschema entry dn + * + * @access public + * @return Net_LDAP2_Schema|NET_LDAP2_Error + */ + public function fetch($ldap, $dn = null) + { + if (!$ldap instanceof Net_LDAP2) { + return PEAR::raiseError("Unable to fetch Schema: Parameter \$ldap must be a Net_LDAP2 object!"); + } + + $schema_o = new Net_LDAP2_Schema(); + + if (is_null($dn)) { + // get the subschema entry via root dse + $dse = $ldap->rootDSE(array('subschemaSubentry')); + if (false == Net_LDAP2::isError($dse)) { + $base = $dse->getValue('subschemaSubentry', 'single'); + if (!Net_LDAP2::isError($base)) { + $dn = $base; + } + } + } + + // Support for buggy LDAP servers (e.g. Siemens DirX 6.x) that incorrectly + // call this entry subSchemaSubentry instead of subschemaSubentry. + // Note the correct case/spelling as per RFC 2251. + if (is_null($dn)) { + // get the subschema entry via root dse + $dse = $ldap->rootDSE(array('subSchemaSubentry')); + if (false == Net_LDAP2::isError($dse)) { + $base = $dse->getValue('subSchemaSubentry', 'single'); + if (!Net_LDAP2::isError($base)) { + $dn = $base; + } + } + } + + // Final fallback case where there is no subschemaSubentry attribute + // in the root DSE (this is a bug for an LDAP v3 server so report this + // to your LDAP vendor if you get this far). + if (is_null($dn)) { + $dn = 'cn=Subschema'; + } + + // fetch the subschema entry + $result = $ldap->search($dn, '(objectClass=*)', + array('attributes' => array_values($schema_o->types), + 'scope' => 'base')); + if (Net_LDAP2::isError($result)) { + return PEAR::raiseError('Could not fetch Subschema entry: '.$result->getMessage()); + } + + $entry = $result->shiftEntry(); + if (!$entry instanceof Net_LDAP2_Entry) { + if ($entry instanceof Net_LDAP2_Error) { + return PEAR::raiseError('Could not fetch Subschema entry: '.$entry->getMessage()); + } else { + return PEAR::raiseError('Could not fetch Subschema entry (search returned '.$result->count().' entries. Check parameter \'basedn\')'); + } + } + + $schema_o->parse($entry); + return $schema_o; + } + + /** + * Return a hash of entries for the given type + * + * Returns a hash of entry for the givene type. Types may be: + * objectclasses, attributes, ditcontentrules, ditstructurerules, matchingrules, + * matchingruleuses, nameforms, syntaxes + * + * @param string $type Type to fetch + * + * @access public + * @return array|Net_LDAP2_Error Array or Net_LDAP2_Error + */ + public function &getAll($type)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/Net/LDAP2/SchemaCache.interface.php
Changed
(renamed from Net_LDAP2-2.0.9/Net/LDAP2/SchemaCache.interface.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/Net/LDAP2/Search.php
Added
@@ -0,0 +1,624 @@ +<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +/** +* File containing the Net_LDAP2_Search interface class. +* +* PHP version 5 +* +* @category Net +* @package Net_LDAP2 +* @author Tarjej Huse <tarjei@bergfald.no> +* @author Benedikt Hallinger <beni@php.net> +* @copyright 2009 Tarjej Huse, Benedikt Hallinger +* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3 +* @version SVN: $Id: Search.php 315417 2011-08-24 12:11:39Z beni $ +* @link http://pear.php.net/package/Net_LDAP2/ +*/ + +/** +* Includes +*/ +require_once 'PEAR.php'; + +/** +* Result set of an LDAP search +* +* @category Net +* @package Net_LDAP2 +* @author Tarjej Huse <tarjei@bergfald.no> +* @author Benedikt Hallinger <beni@php.net> +* @license http://www.gnu.org/copyleft/lesser.html LGPL +* @link http://pear.php.net/package/Net_LDAP22/ +*/ +class Net_LDAP2_Search extends PEAR implements Iterator +{ + /** + * Search result identifier + * + * @access protected + * @var resource + */ + protected $_search; + + /** + * LDAP resource link + * + * @access protected + * @var resource + */ + protected $_link; + + /** + * Net_LDAP2 object + * + * A reference of the Net_LDAP2 object for passing to Net_LDAP2_Entry + * + * @access protected + * @var object Net_LDAP2 + */ + protected $_ldap; + + /** + * Result entry identifier + * + * @access protected + * @var resource + */ + protected $_entry = null; + + /** + * The errorcode the search got + * + * Some errorcodes might be of interest, but might not be best handled as errors. + * examples: 4 - LDAP_SIZELIMIT_EXCEEDED - indicates a huge search. + * Incomplete results are returned. If you just want to check if there's anything in the search. + * than this is a point to handle. + * 32 - no such object - search here returns a count of 0. + * + * @access protected + * @var int + */ + protected $_errorCode = 0; // if not set - sucess! + + /** + * Cache for all entries already fetched from iterator interface + * + * @access protected + * @var array + */ + protected $_iteratorCache = array(); + + /** + * What attributes we searched for + * + * The $attributes array contains the names of the searched attributes and gets + * passed from $Net_LDAP2->search() so the Net_LDAP2_Search object can tell + * what attributes was searched for ({@link searchedAttrs()) + * + * This variable gets set from the constructor and returned + * from {@link searchedAttrs()} + * + * @access protected + * @var array + */ + protected $_searchedAttrs = array(); + + /** + * Cache variable for storing entries fetched internally + * + * This currently is only used by {@link pop_entry()} + * + * @access protected + * @var array + */ + protected $_entry_cache = false; + + /** + * Cache variable for count() + * + * @see count() + * @access protected + * @var int + */ + protected $_count_cache = null; + + /** + * Constructor + * + * @param resource &$search Search result identifier + * @param Net_LDAP2|resource &$ldap Net_LDAP2 object or just a LDAP-Link resource + * @param array $attributes (optional) Array with searched attribute names. (see {@link $_searchedAttrs}) + * + * @access public + */ + public function __construct(&$search, &$ldap, $attributes = array()) + { + $this->PEAR('Net_LDAP2_Error'); + + $this->setSearch($search); + + if ($ldap instanceof Net_LDAP2) { + $this->_ldap =& $ldap; + $this->setLink($this->_ldap->getLink()); + } else { + $this->setLink($ldap); + } + + $this->_errorCode = @ldap_errno($this->_link); + + if (is_array($attributes) && !empty($attributes)) { + $this->_searchedAttrs = $attributes; + } + } + + /** + * Returns an array of entry objects + * + * @return array Array of entry objects. + */ + public function entries() + { + $entries = array(); + + while ($entry = $this->shiftEntry()) { + $entries[] = $entry; + } + + return $entries; + } + + /** + * Get the next entry in the searchresult. + * + * This will return a valid Net_LDAP2_Entry object or false, so + * you can use this method to easily iterate over the entries inside + * a while loop. + * + * @return Net_LDAP2_Entry|false Reference to Net_LDAP2_Entry object or false + */ + public function &shiftEntry() + { + if (is_null($this->_entry)) { + $this->_entry = @ldap_first_entry($this->_link, $this->_search); + $entry = Net_LDAP2_Entry::createConnected($this->_ldap, $this->_entry); + if ($entry instanceof Net_LDAP2_Error) $entry = false; + } else { + if (!$this->_entry = @ldap_next_entry($this->_link, $this->_entry)) { + $false = false; + return $false; + } + $entry = Net_LDAP2_Entry::createConnected($this->_ldap, $this->_entry); + if ($entry instanceof Net_LDAP2_Error) $entry = false; + } + return $entry; + } + + /** + * Alias function of shiftEntry() for perl-ldap interface + * + * @see shiftEntry()
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/Net/LDAP2/SimpleFileSchemaCache.php
Changed
(renamed from Net_LDAP2-2.0.9/Net/LDAP2/SimpleFileSchemaCache.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/Net/LDAP2/Util.php
Changed
(renamed from Net_LDAP2-2.0.9/Net/LDAP2/Util.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/doc/README.txt
Changed
(renamed from Net_LDAP2-2.0.9/doc/README.txt)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/doc/RootDSE.txt
Changed
(renamed from Net_LDAP2-2.0.9/doc/RootDSE.txt)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/doc/Schema.txt
Changed
(renamed from Net_LDAP2-2.0.9/doc/Schema.txt)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/doc/examples/add_entry.php
Changed
(renamed from Net_LDAP2-2.0.9/doc/examples/add_entry.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/doc/examples/connecting.php
Changed
(renamed from Net_LDAP2-2.0.9/doc/examples/connecting.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/doc/examples/fetch_entry.php
Changed
(renamed from Net_LDAP2-2.0.9/doc/examples/fetch_entry.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/doc/examples/modify_entry.php
Changed
(renamed from Net_LDAP2-2.0.9/doc/examples/modify_entry.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/doc/examples/modify_entry2.php
Added
@@ -0,0 +1,60 @@ +<?php +/** +* This is a short example on how to modify a specific entry in the +* directory using Net_LDAP2. +* The way described here is the more compact one but may be useful too. +* The diference is, that this way we use the $ldap object to modify +* the entry directly on the server. +*/ + +// We use the fetch_entry.php example to get the LDAP-Entry +// which we will modify now. +include_once 'fetch_entry.php'; + +// Okay, we should have a valid Net_LDAP2_Entry object that represents +// a real existing entry in our directory. + +// What we do now is to specify some actions that should be performed. +// Note, that the same rules as in the long version discussed in modify_entry.php +// aplly here too, so for replacing attributes, we must specify the absolute new state. +$changes = array( + 'add' => array( + 'mail' => array('foo@example.org', 'test2@example.org'), + 'telephoneNumber' => '1234567890' + ), + 'replace' => array( + 'mail' => array('test1@example.org', 'test2@example.org') + ), + + 'delete' => array( + 'mail' => 'test2@example.org', + 'telephoneNumber' => null // the null value is important here, since array + ) // mode (indexed, associative) is needed to be homogenous +); + +// Now it is time to transfer the changes to the ldap +// directory. However, for security reasons, these lines +// are commented out. +// You have two options to carry out the changes, with a small but often +// very important difference: +// The first call will carry out the actions in the order "add->delete->replace", +// while the latter will perform the changes in the order you define. +// (add->replace->delete, in our example) + + +/* +// METHOD 1: ORDER = add->delete->replace +$result = $ldap->modify($entry, $changes); +if (Net_LDAP2::isError($result)) { + die('Unable to update entry: '.$result->getMessage()); +} +*/ + +/* +// METHOD 2: ORDER = add->replace->delete +$result = $ldap->modify($entry, array('changes' => $changes)); +if (Net_LDAP2::isError($result)) { + die('Unable to update entry: '.$result->getMessage()); +} +*/ +?>
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/doc/examples/schema_cache.php
Changed
(renamed from Net_LDAP2-2.0.9/doc/examples/schema_cache.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/doc/examples/search_entries.php
Changed
(renamed from Net_LDAP2-2.0.9/doc/examples/search_entries.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/doc/manual.html
Changed
(renamed from Net_LDAP2-2.0.9/doc/manual.html)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/doc/utf8.txt
Changed
(renamed from Net_LDAP2-2.0.9/doc/utf8.txt)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/AllTests.php
Changed
(renamed from Net_LDAP2-2.0.9/tests/AllTests.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/Net_LDAP2Test.php
Added
@@ -0,0 +1,921 @@ +<?php +// Call Net_LDAP2Test::main() if this source file is executed directly. +if (!defined("PHPUnit_MAIN_METHOD")) { + define("PHPUnit_MAIN_METHOD", "Net_LDAP2Test::main"); +} + +require_once "PHPUnit/Framework/TestCase.php"; +require_once "PHPUnit/Framework/TestSuite.php"; + +require_once 'Net/LDAP2.php'; +require_once 'Net/LDAP2/Entry.php'; + +/** + * Test class for Net_LDAP2. + * Generated by PHPUnit_Util_Skeleton on 2007-10-09 at 10:32:36. + */ +class Net_LDAP2Test extends PHPUnit_Framework_TestCase { + /** + * Stores the LDAP configuration + */ + var $ldapcfg = false; + + /** + * Runs the test methods of this class. + * + * @access public + * @static + */ + public static function main() { + require_once "PHPUnit/TextUI/TestRunner.php"; + + $suite = new PHPUnit_Framework_TestSuite("Net_LDAP2Test"); + $result = PHPUnit_TextUI_TestRunner::run($suite); + } + + /** + * Load ldap config and adjust appropriately + * + * @access protected + */ + protected function setUp() { + $this->ldapcfg = $this->getTestConfig(); + } + + /** + * Tears down the fixture, for example, close a network connection. + * This method is called after a test is executed. + * + * @access protected + */ + protected function tearDown() { + } + + /** + * This checks if a valid LDAP testconfig is present and loads it. + * + * If so, it is loaded and returned as array. If not, false is returned. + * + * @return false|array + */ + public function getTestConfig() { + $config = false; + $file = dirname(__FILE__).'/ldapconfig.ini'; + if (file_exists($file) && is_readable($file)) { + $config = parse_ini_file($file, true); + } else { + return false; + } + // validate ini + $v_error = $file.' is probably invalid. Did you quoted values correctly?'; + $this->assertTrue(array_key_exists('global', $config), $v_error); + $this->assertTrue(array_key_exists('test', $config), $v_error); + $this->assertEquals(7, count($config['global']), $v_error); + $this->assertEquals(7, count($config['test']), $v_error); + + // reformat things a bit, for convinience + $config['global']['server_binddn'] = + $config['global']['server_binddn'].','.$config['global']['server_base_dn']; + $config['test']['existing_attrmv'] = explode('|', $config['test']['existing_attrmv']); + return $config; + } + + /** + * Establishes a working connection + * + * @return Net_LDAP2 + */ + public function &connect() { + // Check extension + if (true !== Net_LDAP2::checkLDAPExtension()) { + $this->markTestSkipped('PHP LDAP extension not found or not loadable. Skipped Test.'); + } + + // Simple working connect and privilegued bind + $lcfg = array( + 'host' => $this->ldapcfg['global']['server_address'], + 'port' => $this->ldapcfg['global']['server_port'], + 'basedn' => $this->ldapcfg['global']['server_base_dn'], + 'binddn' => $this->ldapcfg['global']['server_binddn'], + 'bindpw' => $this->ldapcfg['global']['server_bindpw'], + 'filter' => '(ou=*)', + ); + $ldap = Net_LDAP2::connect($lcfg); + $this->assertType('Net_LDAP2', $ldap, 'Connect failed but was supposed to work. Check credentials and host address. If those are correct, file a bug!'); + return $ldap; + } + +/* ---------- TESTS ---------- */ + + /** + * testCheckLDAPExtension(). + * + * @todo can we unload modules at runtime?? + */ + public function testCheckLDAPExtension() { + if (extension_loaded('ldap')) { + // If extension is already loaded, then we must get true. + $this->assertTrue(Net_LDAP2::checkLDAPExtension()); + } else { + // If not, we should be able to load it - but may fail + $this->assertThat(Net_LDAP2::checkLDAPExtension(), + $this->logicalOr($this->isInstanceOf('Net_LDAP2_Error'), $this->equalTo(true))); + } + } + + /** + * Tests if getVersion() works correctly + */ + public function testGetVersion() { + $this->assertTrue(defined('NET_LDAP2_VERSION')); + $this->assertEquals(NET_LDAP2_VERSION, Net_LDAP2::getVersion()); + } + + /** + * Tests if the server can connect and bind correctly + */ + public function testConnectAndPrivileguedBind() { + // Check extension + if (true !== Net_LDAP2::checkLDAPExtension()) { + $this->markTestSkipped('PHP LDAP extension not found or not loadable. Skipped Test.'); + } + + if (!$this->ldapcfg) { + $this->markTestSkipped('No ldapconfig.ini found. Skipping test!'); + } else { + // This connect is supposed to fail + $lcfg = array( + 'host' => 'pear.net-ldap.test.hostunknown.cno', + ); + $ldap = Net_LDAP2::connect($lcfg); + $this->assertType('Net_LDAP2_Error', $ldap, 'Connect succeeded but was supposed to fail!'); + + // Failing with multiple hosts + $lcfg = array( + 'host' => array('pear.net-ldap.test.hostunknown1.cno', 'pear.net-ldap.test.hostunknown2.cno'), + ); + $ldap = Net_LDAP2::connect($lcfg); + $this->assertType('Net_LDAP2_Error', $ldap, 'Connect succeeded but was supposed to fail!'); + + // Simple working connect and privilegued bind + $ldap =& $this->connect(); + + // Working connect and privilegued bind with first host down + $lcfg = array( + 'host' => array( + 'pear.net-ldap.test.hostunknown1.cno', + $this->ldapcfg['global']['server_address'] + ), + 'port' => $this->ldapcfg['global']['server_port'], + 'binddn' => $this->ldapcfg['global']['server_binddn'], + 'bindpw' => $this->ldapcfg['global']['server_bindpw'], + ); + $ldap = Net_LDAP2::connect($lcfg); + $this->assertType('Net_LDAP2', $ldap, 'Connect failed but was supposed to work. Check credentials and host address. If those are correct, file a bug!'); + } + } + + /** + * Tests if the server can connect and bind anonymously, if supported (->cfg and ldap mode) + */ + public function testConnectAndAnonymousBind() { + // Check extension + if (true !== Net_LDAP2::checkLDAPExtension()) { + $this->markTestSkipped('PHP LDAP extension not found or not loadable. Skipped Test.'); + } + + if (!$this->ldapcfg) { + $this->markTestSkipped('No ldapconfig.ini found. Skipping test!'); + } elseif ($this->ldapcfg['global']['server_cap_anonymous'] == true) { + // Simple working connect and anonymous bind + $lcfg = array( + 'host' => $this->ldapcfg['global']['server_address'], + 'port' => $this->ldapcfg['global']['server_port'], + ); + $ldap = Net_LDAP2::connect($lcfg); + $this->assertType('Net_LDAP2', $ldap, 'Connect failed but was supposed to work. Check address and if server supports anonymous bind. If those are correct, file a bug!'); + } else { + $this->markTestSkipped('Server does not support anonymous bind (see ldapconfig.ini). Skipping test.'); + }
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/Net_LDAP2_EntryTest.php
Changed
(renamed from Net_LDAP2-2.0.9/tests/Net_LDAP2_EntryTest.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/Net_LDAP2_FilterTest.php
Added
@@ -0,0 +1,331 @@ +<?php +// Call Net_LDAP2_FilterTest::main() if this source file is executed directly. +if (!defined("PHPUnit_MAIN_METHOD")) { + define("PHPUnit_MAIN_METHOD", "Net_LDAP2_FilterTest::main"); +} + +require_once "PHPUnit/Framework/TestCase.php"; +require_once "PHPUnit/Framework/TestSuite.php"; + +require_once 'Net/LDAP2/Filter.php'; + +/** + * Test class for Net_LDAP2_Filter. + * Generated by PHPUnit_Util_Skeleton on 2007-10-09 at 10:34:23. + */ +class Net_LDAP2_FilterTest extends PHPUnit_Framework_TestCase { + /** + * @var string default filter string to test with + */ + var $filter_str = '(&(cn=foo)(ou=bar))'; + + /** + * Runs the test methods of this class. + * + * @access public + * @static + */ + public static function main() { + require_once "PHPUnit/TextUI/TestRunner.php"; + + $suite = new PHPUnit_Framework_TestSuite("Net_LDAP2_FilterTest"); + $result = PHPUnit_TextUI_TestRunner::run($suite); + } + + /** + * Sets up the fixture, for example, open a network connection. + * This method is called before a test is executed. + * + * @access protected + */ + protected function setUp() { + } + + /** + * Tears down the fixture, for example, close a network connection. + * This method is called after a test is executed. + * + * @access protected + */ + protected function tearDown() { + } + + /** + * This tests the perl compatible creation of filters through parsing of an filter string + */ + public function testCreatePerlCompatible() { + $filter_o = new Net_LDAP2_Filter($this->filter_str); + $this->assertType('Net_LDAP2_Filter', $filter_o); + $this->assertEquals($this->filter_str, $filter_o->asString()); + + $filter_o_err = new Net_LDAP2_Filter('some bad filter'); + $this->assertType('PEAR_Error', $filter_o_err->asString()); + } + + /** + * Test correct parsing of filter strings through parse() + */ + public function testParse() { + $parsed_dmg = Net_LDAP2_Filter::parse('some_damaged_filter_str'); + $this->assertType('PEAR_Error', $parsed_dmg); + + $parsed_dmg2 = Net_LDAP2_Filter::parse('(invalid=filter)(because=~no-surrounding brackets)'); + $this->assertType('PEAR_Error', $parsed_dmg2); + + $parsed_dmg3 = Net_LDAP2_Filter::parse('((invalid=filter)(because=log_op is missing))'); + $this->assertType('PEAR_Error', $parsed_dmg3); + + $parsed_dmg4 = Net_LDAP2_Filter::parse('(invalid-because-becauseinvalidoperator)'); + $this->assertType('PEAR_Error', $parsed_dmg4); + + $parsed_dmg5 = Net_LDAP2_Filter::parse('(&(filterpart>=ok)(part2=~ok)(filterpart3_notok---becauseinvalidoperator))'); + $this->assertType('PEAR_Error', $parsed_dmg5); + + $parsed1 = Net_LDAP2_Filter::parse($this->filter_str); + $this->assertType('Net_LDAP2_Filter', $parsed1); + $this->assertEquals($this->filter_str, $parsed1->asString()); + + // To verify bug #16738 is fixed. + // In 2.0.6 there was a problem with the splitting of the filter parts if the next part was also an combined filter + $parsed2_str = "(&(&(objectClass=posixgroup)(objectClass=foogroup))(uniquemember=uid=eeggs,ou=people,o=foo))"; + $parsed2 = Net_LDAP2_Filter::parse($parsed2_str); + $this->assertType('Net_LDAP2_Filter', $parsed2); + $this->assertEquals($parsed2_str, $parsed2->asString()); + + // To verify bug #17057 is fixed + // In 2.0.7 there was a problem parsing certain not-combined filter strings. + $parsed3_str = "(!(jpegPhoto=*))"; + $parsed3 = Net_LDAP2_Filter::parse($parsed3_str); + $this->assertType('Net_LDAP2_Filter', $parsed3); + $this->assertEquals($parsed3_str, $parsed3->asString()); + + $parsed3_complex_str = "(&(someAttr=someValue)(!(jpegPhoto=*)))"; + $parsed3_complex = Net_LDAP2_Filter::parse($parsed3_complex_str); + $this->assertType('Net_LDAP2_Filter', $parsed3_complex); + $this->assertEquals($parsed3_complex_str, $parsed3_complex->asString()); + + } + + + /** + * This tests the basic create() method of creating filters + */ + public function testCreate() { + // Test values and an array containing the filter + // creating methods and an regex to test the resulting filter + $testattr = 'testattr'; + $testval = 'testval'; + $combinations = array( + 'equals' => "/\($testattr=$testval\)/", + 'equals' => "/\($testattr=$testval\)/", + 'begins' => "/\($testattr=$testval\*\)/", + 'ends' => "/\($testattr=\*$testval\)/", + 'contains' => "/\($testattr=\*$testval\*\)/", + 'greater' => "/\($testattr>$testval\)/", + 'less' => "/\($testattr<$testval\)/", + 'greaterorequal' => "/\($testattr>=$testval\)/", + 'lessorequal' => "/\($testattr<=$testval\)/", + 'approx' => "/\($testattr~=$testval\)/", + 'any' => "/\($testattr=\*\)/" + ); + // generate negating tests with supported operator combinations + foreach ($combinations as $match => $regex) { + $regex = preg_replace('#^/|/$#', '', $regex); // treat regex, so we can extend it easily + $combinations['not '.$match] = "/\(!$regex\)/"; + $combinations['not_'.$match] = "/\(!$regex\)/"; + $combinations['not-'.$match] = "/\(!$regex\)/"; + $combinations['! '.$match] = "/\(!$regex\)/"; + $combinations['!_'.$match] = "/\(!$regex\)/"; + $combinations['!-'.$match] = "/\(!$regex\)/"; + } + + // perform tests + foreach ($combinations as $match => $regex) { + // escaping is tested in util class + $filter = Net_LDAP2_Filter::create($testattr, $match, $testval, false); + + $this->assertType('Net_LDAP2_Filter', $filter); + $this->assertRegExp($regex, $filter->asString(), "Filter generation failed for MatchType: $match"); + } + + // test creating failure + $filter = Net_LDAP2_Filter::create($testattr, 'test_undefined_matchingrule', $testval); + $this->assertType('PEAR_Error', $filter); + } + + /** + * Tests, if asString() works + */ + public function testAsString() { + $filter = Net_LDAP2_Filter::create('foo', 'equals', 'bar'); + $this->assertType('Net_LDAP2_Filter', $filter); + $this->assertEquals('(foo=bar)', $filter->asString()); + $this->assertEquals('(foo=bar)', $filter->as_string()); + } + + /** + * Tests, if printMe() works + */ + public function testPrintMe() { + if (substr(strtolower(PHP_OS), 0,3) == 'win') { + $testfile = '/tmp/Net_LDAP2_Filter_printMe-Testfile'; + } else { + $testfile = 'c:\Net_LDAP2_Filter_printMe-Testfile'; + } + $filter = Net_LDAP2_Filter::create('testPrintMe', 'equals', 'ok'); + $this->assertType('Net_LDAP2_Filter', $filter); + + // print success: + ob_start(); + $printresult = $filter->printMe(); + ob_end_clean(); + $this->assertTrue($printresult); + + // PrintMe if Filehandle is an error (e.g. if some PEAR-File db is used): + $err = new PEAR_Error(); + $this->assertType('PEAR_Error', $filter->printMe($err)); + + // PrintMe if filter is damaged, + // $filter_dmg is used below too, to test printing to a file with + // damaged filter + $filter_dmg = new Net_LDAP2_Filter('damaged_filter_string'); + + // write success: + $file = @fopen($testfile, 'w'); + if (is_writable($testfile) && $file) { + $this->assertTrue($filter->printMe($file)); + $this->assertType('PEAR_Error', $filter_dmg->printMe($file)); // dmg. filter + @fclose($file); + } else {
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/Net_LDAP2_LDIFTest.php
Changed
(renamed from Net_LDAP2-2.0.9/tests/Net_LDAP2_LDIFTest.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/Net_LDAP2_RootDSETest.php
Changed
(renamed from Net_LDAP2-2.0.9/tests/Net_LDAP2_RootDSETest.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/Net_LDAP2_SearchTest.php
Changed
(renamed from Net_LDAP2-2.0.9/tests/Net_LDAP2_SearchTest.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/Net_LDAP2_UtilTest.php
Changed
(renamed from Net_LDAP2-2.0.9/tests/Net_LDAP2_UtilTest.php)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/ldapconfig.ini.dist
Changed
(renamed from Net_LDAP2-2.0.9/tests/ldapconfig.ini.dist)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/ldapldifconfig.ini.dist
Changed
(renamed from Net_LDAP2-2.0.9/tests/ldapldifconfig.ini.dist)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/ldif_data/changes.ldif
Changed
(renamed from Net_LDAP2-2.0.9/tests/ldif_data/changes.ldif)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/ldif_data/malformed_encoding.ldif
Changed
(renamed from Net_LDAP2-2.0.9/tests/ldif_data/malformed_encoding.ldif)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/ldif_data/malformed_syntax.ldif
Changed
(renamed from Net_LDAP2-2.0.9/tests/ldif_data/malformed_syntax.ldif)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/ldif_data/malformed_wrapping.ldif
Changed
(renamed from Net_LDAP2-2.0.9/tests/ldif_data/malformed_wrapping.ldif)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/ldif_data/sorted_w40.ldif
Changed
(renamed from Net_LDAP2-2.0.9/tests/ldif_data/sorted_w40.ldif)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/ldif_data/sorted_w50.ldif
Changed
(renamed from Net_LDAP2-2.0.9/tests/ldif_data/sorted_w50.ldif)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/ldif_data/unsorted_w30.ldif
Changed
(renamed from Net_LDAP2-2.0.9/tests/ldif_data/unsorted_w30.ldif)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/ldif_data/unsorted_w50.ldif
Changed
(renamed from Net_LDAP2-2.0.9/tests/ldif_data/unsorted_w50.ldif)
View file
Net_LDAP2-2.0.12.tgz/Net_LDAP2-2.0.12/tests/ldif_data/unsorted_w50_WIN.ldif
Changed
(renamed from Net_LDAP2-2.0.9/tests/ldif_data/unsorted_w50_WIN.ldif)
View file
Net_LDAP2-2.0.9.tgz/package.xml -> Net_LDAP2-2.0.12.tgz/package.xml
Changed
@@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<package packagerversion="1.9.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> +<package packagerversion="1.9.1" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>Net_LDAP2</name> <channel>pear.php.net</channel> <extends>Net_LDAP</extends> @@ -9,8 +9,8 @@ features but has some own too. With Net_LDAP2 you have: * A simple object-oriented interface to connections, searches entries and filters. - * Support for tls and ldap v3. - * Simple modification, deletion and creation of ldap entries. + * Support for TLS and LDAP v3. + * Simple modification, deletion and creation of LDAP entries. * Support for schema handling. Net_LDAP2 layers itself on top of PHP's existing ldap extensions.</description> @@ -20,10 +20,10 @@ <email>beni@php.net</email> <active>yes</active> </lead> - <date>2010-02-16</date> - <time>18:22:51</time> + <date>2011-10-27</date> + <time>15:47:11</time> <version> - <release>2.0.9</release> + <release>2.0.12</release> <api>2.0.0</api> </version> <stability> @@ -32,20 +32,22 @@ </stability> <license>LGPLv3 License</license> <notes> -* fixed package (package.xml was unclean so 2.0.8 wouldnt install) +* inmproved performance with large search results +* Fixed some minor issues with Net_LDAP2_Filter and Net_LDAP2->dnExists() +* Added NOT filter to Net_LDAP2_Filter::create() so negating is more easily now </notes> <contents> <dir name="/"> - <file md5sum="0eeb50d1377a190d52ef398ab46a0f09" name="Net/LDAP2/Entry.php" role="php" /> - <file md5sum="7fb8c0a166ea6d5700027864d95f68cf" name="Net/LDAP2/Filter.php" role="php" /> + <file md5sum="05fd3f6b48d8fd9b051b3fdf65bf70ce" name="Net/LDAP2/Entry.php" role="php" /> + <file md5sum="8f7ef7c2e521fc3d0918b214e90bb074" name="Net/LDAP2/Filter.php" role="php" /> <file md5sum="516f12c6c29882ebeb4e4468dc15b8b2" name="Net/LDAP2/RootDSE.php" role="php" /> - <file md5sum="8f8af289fdfa2b1e7d93fb8b96b1a2ce" name="Net/LDAP2/Schema.php" role="php" /> - <file md5sum="e5532a12b900bf78a7928cccf1cd0f7f" name="Net/LDAP2/Search.php" role="php" /> + <file md5sum="d4828f4ce70510df89efb0af2a00684b" name="Net/LDAP2/Schema.php" role="php" /> + <file md5sum="2c4e16599a43fce59ad3c6ae9824435c" name="Net/LDAP2/Search.php" role="php" /> <file md5sum="7beac3e06fdebeb66201734ad864aaaf" name="Net/LDAP2/Util.php" role="php" /> - <file md5sum="5aeee118d38b36ddf139e55e4cda88f8" name="Net/LDAP2/LDIF.php" role="php" /> + <file md5sum="ce2774b05682bb0c1140eb61fe571f81" name="Net/LDAP2/LDIF.php" role="php" /> <file md5sum="632316377b1b5d6951a5ee56d0762495" name="Net/LDAP2/SchemaCache.interface.php" role="php" /> <file md5sum="b936c0b601331086414fd31d6c0ac58a" name="Net/LDAP2/SimpleFileSchemaCache.php" role="php" /> - <file md5sum="9c4c99c97debc7195e4e7f6e51313b6b" name="Net/LDAP2.php" role="php" /> + <file md5sum="fb530249a570df1e86dfc4216af2ed5b" name="Net/LDAP2.php" role="php" /> <file md5sum="b476ac5b669241a6c98f1e561a04f231" name="doc/manual.html" role="doc" /> <file md5sum="f7a30a3acb682c23879c15f33c5ea165" name="doc/README.txt" role="doc" /> <file md5sum="542c5f79a0c65a6145dc46b91109ed47" name="doc/RootDSE.txt" role="doc" /> @@ -56,14 +58,14 @@ <file md5sum="c3f8c2de85caf3c5ff17e4b7d4dacc64" name="doc/examples/search_entries.php" role="doc" /> <file md5sum="1abf3f70a7aff5f890ddced2ff57486b" name="doc/examples/add_entry.php" role="doc" /> <file md5sum="75bdbca18104a6da0d88dc28d37b405f" name="doc/examples/modify_entry.php" role="doc" /> - <file md5sum="7a4e60a718b46f1af26bcb5ed152fa0e" name="doc/examples/modify_entry2.php" role="doc" /> + <file md5sum="1d5e00f2f7dae4e960eaba1ad73a00ef" name="doc/examples/modify_entry2.php" role="doc" /> <file md5sum="9279cfaa392f216c745879bef5958862" name="doc/examples/schema_cache.php" role="doc" /> <file md5sum="a3435a100a7188bb00160a911fcf5e32" name="tests/AllTests.php" role="test" /> <file md5sum="b685685ba3de34cb4ca1beb00d8d273f" name="tests/Net_LDAP2_EntryTest.php" role="test" /> - <file md5sum="67d62dd0387a9408f227878607a45277" name="tests/Net_LDAP2_FilterTest.php" role="test" /> + <file md5sum="0471d27234452e52b7e2f33b4222857b" name="tests/Net_LDAP2_FilterTest.php" role="test" /> <file md5sum="cccb2dc78f8c512e2a94265460d7566d" name="tests/Net_LDAP2_RootDSETest.php" role="test" /> <file md5sum="69304a41c367ce060086fb194eb7940b" name="tests/Net_LDAP2_SearchTest.php" role="test" /> - <file md5sum="b1b3ff4218265f9cdfcc134429ed797e" name="tests/Net_LDAP2Test.php" role="test" /> + <file md5sum="b8d20add35acf8d0db0b1f5a2e89d2e4" name="tests/Net_LDAP2Test.php" role="test" /> <file md5sum="bcdfb54c3f9924f59eb3d9378d79f537" name="tests/Net_LDAP2_UtilTest.php" role="test" /> <file md5sum="611bc5c89e2eb706ddcb36a6d3a96e85" name="tests/Net_LDAP2_LDIFTest.php" role="test" /> <file md5sum="68c022feb6d6d7bc94f0694cce502954" name="tests/ldapconfig.ini.dist" role="test" /> @@ -750,5 +752,55 @@ * Fixed Bug #17057 (problem with parsing certain NOT-Filters) </notes> </release> + <release> + <date>2010-02-16</date> + <version> + <release>2.0.9</release> + <api>2.0.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license>LGPLv3 License</license> + <notes> +* fixed package (package.xml was unclean so 2.0.8 wouldnt install) + </notes> + </release> + <release> + <date>2010-08-23</date> + <version> + <release>2.0.10</release> + <api>2.0.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license>LGPLv3 License</license> + <notes> +* Added schema handling methods to make schema checks more easily accessible +* Bugfix for #17245. The check in the code was not working properly. Schema checking is considered the users responsibility. + If now an attribute is requested that is not set at the entry, an empty string is returned. +* Bugfix for #17770. Some Net_LDAP2 files were included with relative path ("Util.php"), not absolute ("Net/LDAP2/Util.php"). +* Bugfix for #17314. LDIF support for attributes with modifiers ("attr1;binary"). + </notes> + </release> + <release> + <date>2011-01-19</date> + <version> + <release>2.0.11</release> + <api>2.0.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license>LGPLv3 License</license> + <notes> +* (doc issue) Fix for #17861: Missing komma in example +* Fix for #18202: Adding attributes to a Fresh Entry saving and laterly updating fails + </notes> + </release> </changelog> </package>
View file
Net_LDAP2-2.0.9.tgz/Net_LDAP2-2.0.9/Net/LDAP2.php
Deleted
@@ -1,1808 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -/** -* File containing the Net_LDAP2 interface class. -* -* PHP version 5 -* -* @category Net -* @package Net_LDAP2 -* @author Tarjej Huse <tarjei@bergfald.no> -* @author Jan Wagner <wagner@netsols.de> -* @author Del <del@babel.com.au> -* @author Benedikt Hallinger <beni@php.net> -* @copyright 2003-2007 Tarjej Huse, Jan Wagner, Del Elson, Benedikt Hallinger -* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3 -* @version SVN: $Id: LDAP2.php 295147 2010-02-16 07:51:15Z beni $ -* @link http://pear.php.net/package/Net_LDAP2/ -*/ - -/** -* Package includes. -*/ -require_once 'PEAR.php'; -require_once 'Net/LDAP2/RootDSE.php'; -require_once 'Net/LDAP2/Schema.php'; -require_once 'Net/LDAP2/Entry.php'; -require_once 'Net/LDAP2/Search.php'; -require_once 'Net/LDAP2/Util.php'; -require_once 'Net/LDAP2/Filter.php'; -require_once 'Net/LDAP2/LDIF.php'; -require_once 'Net/LDAP2/SchemaCache.interface.php'; -require_once 'Net/LDAP2/SimpleFileSchemaCache.php'; - -/** -* Error constants for errors that are not LDAP errors. -*/ -define('NET_LDAP2_ERROR', 1000); - -/** -* Net_LDAP2 Version -*/ -define('NET_LDAP2_VERSION', '2.0.9'); - -/** -* Net_LDAP2 - manipulate LDAP servers the right way! -* -* @category Net -* @package Net_LDAP2 -* @author Tarjej Huse <tarjei@bergfald.no> -* @author Jan Wagner <wagner@netsols.de> -* @author Del <del@babel.com.au> -* @author Benedikt Hallinger <beni@php.net> -* @copyright 2003-2007 Tarjej Huse, Jan Wagner, Del Elson, Benedikt Hallinger -* @license http://www.gnu.org/copyleft/lesser.html LGPL -* @link http://pear.php.net/package/Net_LDAP2/ -*/ -class Net_LDAP2 extends PEAR -{ - /** - * Class configuration array - * - * host = the ldap host to connect to - * (may be an array of several hosts to try) - * port = the server port - * version = ldap version (defaults to v 3) - * starttls = when set, ldap_start_tls() is run after connecting. - * bindpw = no explanation needed - * binddn = the DN to bind as. - * basedn = ldap base - * options = hash of ldap options to set (opt => val) - * filter = default search filter - * scope = default search scope - * - * Newly added in 2.0.0RC4, for auto-reconnect: - * auto_reconnect = if set to true then the class will automatically - * attempt to reconnect to the LDAP server in certain - * failure conditionswhen attempting a search, or other - * LDAP operation. 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_backoff = initial reconnection delay period (in seconds). - * max_backoff = maximum reconnection delay period (in seconds). - * - * @access protected - * @var array - */ - protected $_config = array('host' => 'localhost', - 'port' => 389, - 'version' => 3, - 'starttls' => false, - 'binddn' => '', - 'bindpw' => '', - 'basedn' => '', - 'options' => array(), - 'filter' => '(objectClass=*)', - 'scope' => 'sub', - 'auto_reconnect' => false, - 'min_backoff' => 1, - 'current_backoff' => 1, - 'max_backoff' => 32); - - /** - * List of hosts we try to establish a connection to - * - * @access protected - * @var array - */ - protected $_host_list = array(); - - /** - * List of hosts that are known to be down. - * - * @access protected - * @var array - */ - protected $_down_host_list = array(); - - /** - * LDAP resource link. - * - * @access protected - * @var resource - */ - protected $_link = false; - - /** - * Net_LDAP2_Schema object - * - * This gets set and returned by {@link schema()} - * - * @access protected - * @var object Net_LDAP2_Schema - */ - protected $_schema = null; - - /** - * Schema cacher function callback - * - * @see registerSchemaCache() - * @var string - */ - protected $_schema_cache = null; - - /** - * Cache for attribute encoding checks - * - * @access protected - * @var array Hash with attribute names as key and boolean value - * to determine whether they should be utf8 encoded or not. - */ - protected $_schemaAttrs = array(); - - /** - * Cache for rootDSE objects - * - * 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, Net_LDAP2 needs several lookups to this object, so - * caching increases performance significally. - * - * @access protected - * @var array - */ - protected $_rootDSE_cache = array(); - - /** - * Returns the Net_LDAP2 Release version, may be called statically - * - * @static - * @return string Net_LDAP2 version - */ - public static function getVersion() - { - return NET_LDAP2_VERSION; - } - - /** - * Configure Net_LDAP2, connect and bind - * - * Use this method as starting point of using Net_LDAP2 - * to establish a connection to your LDAP server. - * - * Static function that returns either an error object or the new Net_LDAP2 - * object. Something like a factory. Takes a config array with the needed - * parameters. - * - * @param array $config Configuration array - * - * @access public - * @return Net_LDAP2_Error|Net_LDAP2 Net_LDAP2_Error or Net_LDAP2 object - */ - public static function &connect($config = array()) - { - $ldap_check = self::checkLDAPExtension(); - if (self::iserror($ldap_check)) { - return $ldap_check;
View file
Net_LDAP2-2.0.9.tgz/Net_LDAP2-2.0.9/Net/LDAP2/Entry.php
Deleted
@@ -1,1055 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -/** -* File containing the Net_LDAP2_Entry interface class. -* -* PHP version 5 -* -* @category Net -* @package Net_LDAP2 -* @author Jan Wagner <wagner@netsols.de> -* @author Tarjej Huse <tarjei@bergfald.no> -* @author Benedikt Hallinger <beni@php.net> -* @copyright 2009 Tarjej Huse, Jan Wagner, Benedikt Hallinger -* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3 -* @version SVN: $Id: Entry.php 286787 2009-08-04 06:03:12Z beni $ -* @link http://pear.php.net/package/Net_LDAP2/ -*/ - -/** -* Includes -*/ -require_once 'PEAR.php'; -require_once 'Util.php'; - -/** -* Object representation of a directory entry -* -* This class represents a directory entry. You can add, delete, replace -* attributes and their values, rename the entry, delete the entry. -* -* @category Net -* @package Net_LDAP2 -* @author Jan Wagner <wagner@netsols.de> -* @author Tarjej Huse <tarjei@bergfald.no> -* @author Benedikt Hallinger <beni@php.net> -* @license http://www.gnu.org/copyleft/lesser.html LGPL -* @link http://pear.php.net/package/Net_LDAP2/ -*/ -class Net_LDAP2_Entry extends PEAR -{ - /** - * Entry ressource identifier - * - * @access protected - * @var ressource - */ - protected $_entry = null; - - /** - * LDAP ressource identifier - * - * @access protected - * @var ressource - */ - protected $_link = null; - - /** - * Net_LDAP2 object - * - * This object will be used for updating and schema checking - * - * @access protected - * @var object Net_LDAP2 - */ - protected $_ldap = null; - - /** - * Distinguished name of the entry - * - * @access protected - * @var string - */ - protected $_dn = null; - - /** - * Attributes - * - * @access protected - * @var array - */ - protected $_attributes = array(); - - /** - * Original attributes before any modification - * - * @access protected - * @var array - */ - protected $_original = array(); - - - /** - * Map of attribute names - * - * @access protected - * @var array - */ - protected $_map = array(); - - - /** - * Is this a new entry? - * - * @access protected - * @var boolean - */ - protected $_new = true; - - /** - * New distinguished name - * - * @access protected - * @var string - */ - protected $_newdn = null; - - /** - * Shall the entry be deleted? - * - * @access protected - * @var boolean - */ - protected $_delete = false; - - /** - * Map with changes to the entry - * - * @access protected - * @var array - */ - protected $_changes = array("add" => array(), - "delete" => array(), - "replace" => array() - ); - /** - * Internal Constructor - * - * Constructor of the entry. Sets up the distinguished name and the entries - * attributes. - * You should not call this method manually! Use {@link Net_LDAP2_Entry::createFresh()} - * or {@link Net_LDAP2_Entry::createConnected()} instead! - * - * @param Net_LDAP2|ressource|array &$ldap Net_LDAP2 object, ldap-link ressource or array of attributes - * @param string|ressource $entry Either a DN or a LDAP-Entry ressource - * - * @access protected - * @return none - */ - protected function __construct(&$ldap, $entry = null) - { - $this->PEAR('Net_LDAP2_Error'); - - // set up entry resource or DN - if (is_resource($entry)) { - $this->_entry = &$entry; - } else { - $this->_dn = $entry; - } - - // set up LDAP link - if ($ldap instanceof Net_LDAP2) { - $this->_ldap = &$ldap; - $this->_link = $ldap->getLink(); - } elseif (is_resource($ldap)) { - $this->_link = $ldap; - } elseif (is_array($ldap)) { - // Special case: here $ldap is an array of attributes, - // this means, we have no link. This is a "virtual" entry. - // We just set up the attributes so one can work with the object - // as expected, but an update() fails unless setLDAP() is called. - $this->setAttributes($ldap); - } - - // if this is an entry existing in the directory, - // then set up as old and fetch attrs - if (is_resource($this->_entry) && is_resource($this->_link)) { - $this->_new = false; - $this->_dn = @ldap_get_dn($this->_link, $this->_entry); - $this->setAttributes(); // fetch attributes from server - } - } - - /** - * Creates a fresh entry that may be added to the directory later on - * - * Use this method, if you want to initialize a fresh entry. - * - * The method should be called statically: $entry = Net_LDAP2_Entry::createFresh(); - * You should put a 'objectClass' attribute into the $attrs so the directory server - * knows which object you want to create. However, you may omit this in case you - * don't want to add this entry to a directory server. - * - * The attributes parameter is as following: - * <code> - * $attrs = array( 'attribute1' => array('value1', 'value2'), - * 'attribute2' => 'single value' - * ); - * </code> - *
View file
Net_LDAP2-2.0.9.tgz/Net_LDAP2-2.0.9/Net/LDAP2/Filter.php
Deleted
@@ -1,519 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -/** -* File containing the Net_LDAP2_Filter interface class. -* -* PHP version 5 -* -* @category Net -* @package Net_LDAP2 -* @author Benedikt Hallinger <beni@php.net> -* @copyright 2009 Benedikt Hallinger -* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3 -* @version SVN: $Id: Filter.php 295143 2010-02-16 07:38:46Z beni $ -* @link http://pear.php.net/package/Net_LDAP2/ -*/ - -/** -* Includes -*/ -require_once 'PEAR.php'; -require_once 'Util.php'; - -/** -* Object representation of a part of a LDAP filter. -* -* This Class is not completely compatible to the PERL interface! -* -* The purpose of this class is, that users can easily build LDAP filters -* without having to worry about right escaping etc. -* A Filter is built using several independent filter objects -* which are combined afterwards. This object works in two -* modes, depending how the object is created. -* If the object is created using the {@link create()} method, then this is a leaf-object. -* If the object is created using the {@link combine()} method, then this is a container object. -* -* LDAP filters are defined in RFC-2254 and can be found under -* {@link http://www.ietf.org/rfc/rfc2254.txt} -* -* Here a quick copy&paste example: -* <code> -* $filter0 = Net_LDAP2_Filter::create('stars', 'equals', '***'); -* $filter_not0 = Net_LDAP2_Filter::combine('not', $filter0); -* -* $filter1 = Net_LDAP2_Filter::create('gn', 'begins', 'bar'); -* $filter2 = Net_LDAP2_Filter::create('gn', 'ends', 'baz'); -* $filter_comp = Net_LDAP2_Filter::combine('or',array($filter_not0, $filter1, $filter2)); -* -* echo $filter_comp->asString(); -* // This will output: (|(!(stars=\0x5c0x2a\0x5c0x2a\0x5c0x2a))(gn=bar*)(gn=*baz)) -* // The stars in $filter0 are treaten as real stars unless you disable escaping. -* </code> -* -* @category Net -* @package Net_LDAP2 -* @author Benedikt Hallinger <beni@php.net> -* @license http://www.gnu.org/copyleft/lesser.html LGPL -* @link http://pear.php.net/package/Net_LDAP2/ -*/ -class Net_LDAP2_Filter extends PEAR -{ - /** - * Storage for combination of filters - * - * This variable holds a array of filter objects - * that should be combined by this filter object. - * - * @access protected - * @var array - */ - protected $_subfilters = array(); - - /** - * Match of this filter - * - * If this is a leaf filter, then a matching rule is stored, - * if it is a container, then it is a logical operator - * - * @access protected - * @var string - */ - protected $_match; - - /** - * Single filter - * - * If we operate in leaf filter mode, - * then the constructing method stores - * the filter representation here - * - * @acces private - * @var string - */ - protected $_filter; - - /** - * Create a new Net_LDAP2_Filter object and parse $filter. - * - * This is for PERL Net::LDAP interface. - * Construction of Net_LDAP2_Filter objects should happen through either - * {@link create()} or {@link combine()} which give you more control. - * However, you may use the perl iterface if you already have generated filters. - * - * @param string $filter LDAP filter string - * - * @see parse() - */ - public function __construct($filter = false) - { - // The optional parameter must remain here, because otherwise create() crashes - if (false !== $filter) { - $filter_o = self::parse($filter); - if (PEAR::isError($filter_o)) { - $this->_filter = $filter_o; // assign error, so asString() can report it - } else { - $this->_filter = $filter_o->asString(); - } - } - } - - /** - * Constructor of a new part of a LDAP filter. - * - * The following matching rules exists: - * - equals: One of the attributes values is exactly $value - * Please note that case sensitiviness is depends on the - * attributes syntax configured in the server. - * - begins: One of the attributes values must begin with $value - * - ends: One of the attributes values must end with $value - * - contains: One of the attributes values must contain $value - * - present | any: The attribute can contain any value but must be existent - * - greater: The attributes value is greater than $value - * - less: The attributes value is less than $value - * - greaterOrEqual: The attributes value is greater or equal than $value - * - lessOrEqual: The attributes value is less or equal than $value - * - approx: One of the attributes values is similar to $value - * - * If $escape is set to true (default) then $value will be escaped - * properly. If it is set to false then $value will be treaten as raw filter value string. - * You should escape yourself using {@link Net_LDAP2_Util::escape_filter_value()}! - * - * Examples: - * <code> - * // This will find entries that contain an attribute "sn" that ends with "foobar": - * $filter = new Net_LDAP2_Filter('sn', 'ends', 'foobar'); - * - * // This will find entries that contain an attribute "sn" that has any value set: - * $filter = new Net_LDAP2_Filter('sn', 'any'); - * </code> - * - * @param string $attr_name Name of the attribute the filter should apply to - * @param string $match Matching rule (equals, begins, ends, contains, greater, less, greaterOrEqual, lessOrEqual, approx, any) - * @param string $value (optional) if given, then this is used as a filter - * @param boolean $escape Should $value be escaped? (default: yes, see {@link Net_LDAP2_Util::escape_filter_value()} for detailed information) - * - * @return Net_LDAP2_Filter|Net_LDAP2_Error - */ - public static function &create($attr_name, $match, $value = '', $escape = true) - { - $leaf_filter = new Net_LDAP2_Filter(); - if ($escape) { - $array = Net_LDAP2_Util::escape_filter_value(array($value)); - $value = $array[0]; - } - switch (strtolower($match)) { - case 'equals': - $leaf_filter->_filter = '(' . $attr_name . '=' . $value . ')'; - break; - case 'begins': - $leaf_filter->_filter = '(' . $attr_name . '=' . $value . '*)'; - break; - case 'ends': - $leaf_filter->_filter = '(' . $attr_name . '=*' . $value . ')'; - break; - case 'contains': - $leaf_filter->_filter = '(' . $attr_name . '=*' . $value . '*)'; - break; - case 'greater': - $leaf_filter->_filter = '(' . $attr_name . '>' . $value . ')'; - break; - case 'less': - $leaf_filter->_filter = '(' . $attr_name . '<' . $value . ')'; - break; - case 'greaterorequal': - case '>=': - $leaf_filter->_filter = '(' . $attr_name . '>=' . $value . ')'; - break; - case 'lessorequal': - case '<=': - $leaf_filter->_filter = '(' . $attr_name . '<=' . $value . ')'; - break; - case 'approx': - case '~=': - $leaf_filter->_filter = '(' . $attr_name . '~=' . $value . ')'; - break; - case 'any': - case 'present': // alias that may improve user code readability - $leaf_filter->_filter = '(' . $attr_name . '=*)'; - break; - default:
View file
Net_LDAP2-2.0.9.tgz/Net_LDAP2-2.0.9/Net/LDAP2/LDIF.php
Deleted
@@ -1,924 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -/** -* File containing the Net_LDAP2_LDIF interface class. -* -* PHP version 5 -* -* @category Net -* @package Net_LDAP2 -* @author Benedikt Hallinger <beni@php.net> -* @copyright 2009 Benedikt Hallinger -* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3 -* @version SVN: $Id: LDIF.php 294038 2010-01-26 08:12:46Z beni $ -* @link http://pear.php.net/package/Net_LDAP2/ -*/ - -/** -* Includes -*/ -require_once 'PEAR.php'; -require_once 'Net/LDAP2.php'; -require_once 'Net/LDAP2/Entry.php'; -require_once 'Net/LDAP2/Util.php'; - -/** -* LDIF capabilitys for Net_LDAP2, closely taken from PERLs Net::LDAP -* -* It provides a means to convert between Net_LDAP2_Entry objects and LDAP entries -* represented in LDIF format files. Reading and writing are supported and may -* manipulate single entries or lists of entries. -* -* Usage example: -* <code> -* // Read and parse an ldif-file into Net_LDAP2_Entry objects -* // and print out the DNs. Store the entries for later use. -* require 'Net/LDAP2/LDIF.php'; -* $options = array( -* 'onerror' => 'die' -* ); -* $entries = array(); -* $ldif = new Net_LDAP2_LDIF('test.ldif', 'r', $options); -* do { -* $entry = $ldif->read_entry(); -* $dn = $entry->dn(); -* echo " done building entry: $dn\n"; -* array_push($entries, $entry); -* } while (!$ldif->eof()); -* $ldif->done(); -* -* -* // write those entries to another file -* $ldif = new Net_LDAP2_LDIF('test.out.ldif', 'w', $options); -* $ldif->write_entry($entries); -* $ldif->done(); -* </code> -* -* @category Net -* @package Net_LDAP2 -* @author Benedikt Hallinger <beni@php.net> -* @license http://www.gnu.org/copyleft/lesser.html LGPL -* @link http://pear.php.net/package/Net_LDAP22/ -* @see http://www.ietf.org/rfc/rfc2849.txt -* @todo Error handling should be PEARified -* @todo LDAPv3 controls are not implemented yet -*/ -class Net_LDAP2_LDIF extends PEAR -{ - /** - * Options - * - * @access protected - * @var array - */ - protected $_options = array('encode' => 'base64', - 'onerror' => null, - 'change' => 0, - 'lowercase' => 0, - 'sort' => 0, - 'version' => null, - 'wrap' => 78, - 'raw' => '' - ); - - /** - * Errorcache - * - * @access protected - * @var array - */ - protected $_error = array('error' => null, - 'line' => 0 - ); - - /** - * Filehandle for read/write - * - * @access protected - * @var array - */ - protected $_FH = null; - - /** - * Says, if we opened the filehandle ourselves - * - * @access protected - * @var array - */ - protected $_FH_opened = false; - - /** - * Linecounter for input file handle - * - * @access protected - * @var array - */ - protected $_input_line = 0; - - /** - * counter for processed entries - * - * @access protected - * @var int - */ - protected $_entrynum = 0; - - /** - * Mode we are working in - * - * Either 'r', 'a' or 'w' - * - * @access protected - * @var string - */ - protected $_mode = false; - - /** - * Tells, if the LDIF version string was already written - * - * @access protected - * @var boolean - */ - protected $_version_written = false; - - /** - * Cache for lines that have build the current entry - * - * @access protected - * @var boolean - */ - protected $_lines_cur = array(); - - /** - * Cache for lines that will build the next entry - * - * @access protected - * @var boolean - */ - protected $_lines_next = array(); - - /** - * Open LDIF file for reading or for writing - * - * new (FILE): - * Open the file read-only. FILE may be the name of a file - * or an already open filehandle. - * If the file doesn't exist, it will be created if in write mode. - * - * new (FILE, MODE, OPTIONS): - * Open the file with the given MODE (see PHPs fopen()), eg "w" or "a". - * FILE may be the name of a file or an already open filehandle. - * PERLs Net_LDAP2 "FILE|" mode does not work curently. - * - * OPTIONS is an associative array and may contain: - * encode => 'none' | 'canonical' | 'base64' - * Some DN values in LDIF cannot be written verbatim and have to be encoded in some way: - * 'none' No encoding. - * 'canonical' See "canonical_dn()" in Net::LDAP::Util. - * 'base64' Use base64. (default, this differs from the Perl interface. - * The perl default is "none"!) - * - * onerror => 'die' | 'warn' | NULL - * Specify what happens when an error is detected. - * 'die' Net_LDAP2_LDIF will croak with an appropriate message. - * 'warn' Net_LDAP2_LDIF will warn (echo) with an appropriate message. - * NULL Net_LDAP2_LDIF will not warn (default), use error(). - * - * change => 1 - * Write entry changes to the LDIF file instead of the entries itself. I.e. write LDAP - * operations acting on the entries to the file instead of the entries contents. - * This writes the changes usually carried out by an update() to the LDIF file. - * - * lowercase => 1 - * Convert attribute names to lowercase when writing. - * - * sort => 1 - * Sort attribute names when writing entries according to the rule: - * objectclass first then all other attributes alphabetically sorted by attribute name - * - * version => '1'
View file
Net_LDAP2-2.0.9.tgz/Net_LDAP2-2.0.9/Net/LDAP2/Schema.php
Deleted
@@ -1,516 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -/** -* File containing the Net_LDAP2_Schema interface class. -* -* PHP version 5 -* -* @category Net -* @package Net_LDAP2 -* @author Jan Wagner <wagner@netsols.de> -* @author Benedikt Hallinger <beni@php.net> -* @copyright 2009 Jan Wagner, Benedikt Hallinger -* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3 -* @version SVN: $Id: Schema.php 286718 2009-08-03 07:30:49Z beni $ -* @link http://pear.php.net/package/Net_LDAP2/ -* @todo see the comment at the end of the file -*/ - -/** -* Includes -*/ -require_once 'PEAR.php'; - -/** -* Syntax definitions -* -* Please don't forget to add binary attributes to isBinary() below -* to support proper value fetching from Net_LDAP2_Entry -*/ -define('NET_LDAP2_SYNTAX_BOOLEAN', '1.3.6.1.4.1.1466.115.121.1.7'); -define('NET_LDAP2_SYNTAX_DIRECTORY_STRING', '1.3.6.1.4.1.1466.115.121.1.15'); -define('NET_LDAP2_SYNTAX_DISTINGUISHED_NAME', '1.3.6.1.4.1.1466.115.121.1.12'); -define('NET_LDAP2_SYNTAX_INTEGER', '1.3.6.1.4.1.1466.115.121.1.27'); -define('NET_LDAP2_SYNTAX_JPEG', '1.3.6.1.4.1.1466.115.121.1.28'); -define('NET_LDAP2_SYNTAX_NUMERIC_STRING', '1.3.6.1.4.1.1466.115.121.1.36'); -define('NET_LDAP2_SYNTAX_OID', '1.3.6.1.4.1.1466.115.121.1.38'); -define('NET_LDAP2_SYNTAX_OCTET_STRING', '1.3.6.1.4.1.1466.115.121.1.40'); - -/** -* Load an LDAP Schema and provide information -* -* This class takes a Subschema entry, parses this information -* and makes it available in an array. Most of the code has been -* inspired by perl-ldap( http://perl-ldap.sourceforge.net). -* You will find portions of their implementation in here. -* -* @category Net -* @package Net_LDAP2 -* @author Jan Wagner <wagner@netsols.de> -* @author Benedikt Hallinger <beni@php.net> -* @license http://www.gnu.org/copyleft/lesser.html LGPL -* @link http://pear.php.net/package/Net_LDAP22/ -*/ -class Net_LDAP2_Schema extends PEAR -{ - /** - * Map of entry types to ldap attributes of subschema entry - * - * @access public - * @var array - */ - public $types = array( - 'attribute' => 'attributeTypes', - 'ditcontentrule' => 'dITContentRules', - 'ditstructurerule' => 'dITStructureRules', - 'matchingrule' => 'matchingRules', - 'matchingruleuse' => 'matchingRuleUse', - 'nameform' => 'nameForms', - 'objectclass' => 'objectClasses', - 'syntax' => 'ldapSyntaxes' - ); - - /** - * Array of entries belonging to this type - * - * @access protected - * @var array - */ - protected $_attributeTypes = array(); - protected $_matchingRules = array(); - protected $_matchingRuleUse = array(); - protected $_ldapSyntaxes = array(); - protected $_objectClasses = array(); - protected $_dITContentRules = array(); - protected $_dITStructureRules = array(); - protected $_nameForms = array(); - - - /** - * hash of all fetched oids - * - * @access protected - * @var array - */ - protected $_oids = array(); - - /** - * Tells if the schema is initialized - * - * @access protected - * @var boolean - * @see parse(), get() - */ - protected $_initialized = false; - - - /** - * Constructor of the class - * - * @access protected - */ - protected function __construct() - { - $this->PEAR('Net_LDAP2_Error'); // default error class - } - - /** - * Fetch the Schema from an LDAP connection - * - * @param Net_LDAP2 $ldap LDAP connection - * @param string $dn (optional) Subschema entry dn - * - * @access public - * @return Net_LDAP2_Schema|NET_LDAP2_Error - */ - public function fetch($ldap, $dn = null) - { - if (!$ldap instanceof Net_LDAP2) { - return PEAR::raiseError("Unable to fetch Schema: Parameter \$ldap must be a Net_LDAP2 object!"); - } - - $schema_o = new Net_LDAP2_Schema(); - - if (is_null($dn)) { - // get the subschema entry via root dse - $dse = $ldap->rootDSE(array('subschemaSubentry')); - if (false == Net_LDAP2::isError($dse)) { - $base = $dse->getValue('subschemaSubentry', 'single'); - if (!Net_LDAP2::isError($base)) { - $dn = $base; - } - } - } - - // Support for buggy LDAP servers (e.g. Siemens DirX 6.x) that incorrectly - // call this entry subSchemaSubentry instead of subschemaSubentry. - // Note the correct case/spelling as per RFC 2251. - if (is_null($dn)) { - // get the subschema entry via root dse - $dse = $ldap->rootDSE(array('subSchemaSubentry')); - if (false == Net_LDAP2::isError($dse)) { - $base = $dse->getValue('subSchemaSubentry', 'single'); - if (!Net_LDAP2::isError($base)) { - $dn = $base; - } - } - } - - // Final fallback case where there is no subschemaSubentry attribute - // in the root DSE (this is a bug for an LDAP v3 server so report this - // to your LDAP vendor if you get this far). - if (is_null($dn)) { - $dn = 'cn=Subschema'; - } - - // fetch the subschema entry - $result = $ldap->search($dn, '(objectClass=*)', - array('attributes' => array_values($schema_o->types), - 'scope' => 'base')); - if (Net_LDAP2::isError($result)) { - return $result; - } - - $entry = $result->shiftEntry(); - if (!$entry instanceof Net_LDAP2_Entry) { - return PEAR::raiseError('Could not fetch Subschema entry'); - } - - $schema_o->parse($entry); - return $schema_o; - } - - /** - * Return a hash of entries for the given type - * - * Returns a hash of entry for th givene type. Types may be: - * objectclasses, attributes, ditcontentrules, ditstructurerules, matchingrules, - * matchingruleuses, nameforms, syntaxes - * - * @param string $type Type to fetch - * - * @access public - * @return array|Net_LDAP2_Error Array or Net_LDAP2_Error - */ - public function &getAll($type) - { - $map = array('objectclasses' => &$this->_objectClasses, - 'attributes' => &$this->_attributeTypes, - 'ditcontentrules' => &$this->_dITContentRules,
View file
Net_LDAP2-2.0.9.tgz/Net_LDAP2-2.0.9/Net/LDAP2/Search.php
Deleted
@@ -1,614 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -/** -* File containing the Net_LDAP2_Search interface class. -* -* PHP version 5 -* -* @category Net -* @package Net_LDAP2 -* @author Tarjej Huse <tarjei@bergfald.no> -* @author Benedikt Hallinger <beni@php.net> -* @copyright 2009 Tarjej Huse, Benedikt Hallinger -* @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPLv3 -* @version SVN: $Id: Search.php 286718 2009-08-03 07:30:49Z beni $ -* @link http://pear.php.net/package/Net_LDAP2/ -*/ - -/** -* Includes -*/ -require_once 'PEAR.php'; - -/** -* Result set of an LDAP search -* -* @category Net -* @package Net_LDAP2 -* @author Tarjej Huse <tarjei@bergfald.no> -* @author Benedikt Hallinger <beni@php.net> -* @license http://www.gnu.org/copyleft/lesser.html LGPL -* @link http://pear.php.net/package/Net_LDAP22/ -*/ -class Net_LDAP2_Search extends PEAR implements Iterator -{ - /** - * Search result identifier - * - * @access protected - * @var resource - */ - protected $_search; - - /** - * LDAP resource link - * - * @access protected - * @var resource - */ - protected $_link; - - /** - * Net_LDAP2 object - * - * A reference of the Net_LDAP2 object for passing to Net_LDAP2_Entry - * - * @access protected - * @var object Net_LDAP2 - */ - protected $_ldap; - - /** - * Result entry identifier - * - * @access protected - * @var resource - */ - protected $_entry = null; - - /** - * The errorcode the search got - * - * Some errorcodes might be of interest, but might not be best handled as errors. - * examples: 4 - LDAP_SIZELIMIT_EXCEEDED - indicates a huge search. - * Incomplete results are returned. If you just want to check if there's anything in the search. - * than this is a point to handle. - * 32 - no such object - search here returns a count of 0. - * - * @access protected - * @var int - */ - protected $_errorCode = 0; // if not set - sucess! - - /** - * Cache for all entries already fetched from iterator interface - * - * @access protected - * @var array - */ - protected $_iteratorCache = array(); - - /** - * What attributes we searched for - * - * The $attributes array contains the names of the searched attributes and gets - * passed from $Net_LDAP2->search() so the Net_LDAP2_Search object can tell - * what attributes was searched for ({@link searchedAttrs()) - * - * This variable gets set from the constructor and returned - * from {@link searchedAttrs()} - * - * @access protected - * @var array - */ - protected $_searchedAttrs = array(); - - /** - * Cache variable for storing entries fetched internally - * - * This currently is only used by {@link pop_entry()} - * - * @access protected - * @var array - */ - protected $_entry_cache = false; - - /** - * Constructor - * - * @param resource &$search Search result identifier - * @param Net_LDAP2|resource &$ldap Net_LDAP2 object or just a LDAP-Link resource - * @param array $attributes (optional) Array with searched attribute names. (see {@link $_searchedAttrs}) - * - * @access public - */ - public function __construct(&$search, &$ldap, $attributes = array()) - { - $this->PEAR('Net_LDAP2_Error'); - - $this->setSearch($search); - - if ($ldap instanceof Net_LDAP2) { - $this->_ldap =& $ldap; - $this->setLink($this->_ldap->getLink()); - } else { - $this->setLink($ldap); - } - - $this->_errorCode = @ldap_errno($this->_link); - - if (is_array($attributes) && !empty($attributes)) { - $this->_searchedAttrs = $attributes; - } - } - - /** - * Returns an array of entry objects - * - * @return array Array of entry objects. - */ - public function entries() - { - $entries = array(); - - while ($entry = $this->shiftEntry()) { - $entries[] = $entry; - } - - return $entries; - } - - /** - * Get the next entry in the searchresult. - * - * This will return a valid Net_LDAP2_Entry object or false, so - * you can use this method to easily iterate over the entries inside - * a while loop. - * - * @return Net_LDAP2_Entry|false Reference to Net_LDAP2_Entry object or false - */ - public function &shiftEntry() - { - if ($this->count() == 0 ) { - $false = false; - return $false; - } - - if (is_null($this->_entry)) { - $this->_entry = @ldap_first_entry($this->_link, $this->_search); - $entry = Net_LDAP2_Entry::createConnected($this->_ldap, $this->_entry); - if ($entry instanceof Net_LDAP2_Error) $entry = false; - } else { - if (!$this->_entry = @ldap_next_entry($this->_link, $this->_entry)) { - $false = false; - return $false; - } - $entry = Net_LDAP2_Entry::createConnected($this->_ldap, $this->_entry); - if ($entry instanceof Net_LDAP2_Error) $entry = false; - } - return $entry; - } - - /** - * Alias function of shiftEntry() for perl-ldap interface - * - * @see shiftEntry() - * @return Net_LDAP2_Entry|false - */ - public function shift_entry() - {
View file
Net_LDAP2-2.0.9.tgz/Net_LDAP2-2.0.9/doc/examples/modify_entry2.php
Deleted
@@ -1,60 +0,0 @@ -<?php -/** -* This is a short example on how to modify a specific entry in the -* directory using Net_LDAP2. -* The way described here is the more compact one but may be useful too. -* The diference is, that this way we use the $ldap object to modify -* the entry directly on the server. -*/ - -// We use the fetch_entry.php example to get the LDAP-Entry -// which we will modify now. -include_once 'fetch_entry.php'; - -// Okay, we should have a valid Net_LDAP2_Entry object that represents -// a real existing entry in our directory. - -// What we do now is to specify some actions that should be performed. -// Note, that the same rules as in the long version discussed in modify_entry.php -// aplly here too, so for replacing attributes, we must specify the absolute new state. -$changes = array( - 'add' => array( - 'mail' => array('foo@example.org', 'test2@example.org'), - 'telephoneNumber' => '1234567890' - ), - 'replace' => array( - 'mail' => array('test1@example.org', 'test2@example.org') - ) - - 'delete' = array( - 'mail' => 'test2@example.org', - 'telephoneNumber' => null // the null value is important here, sincearray - ) // mode (indexed, associative) is needed to be homogenous -); - -// Now it is time to transfer the changes to the ldap -// directory. However, for security reasons, these lines -// are commented out. -// You have two options to carry out the changes, with a small but often -// very important difference: -// The first call will carry out the actions in the order "add->delete->replace", -// while the latter will perform the changes in the order you define. -// (add->replace->delete, in our example) - - -/* -// METHOD 1: ORDER = add->delete->replace -$result = $ldap->modify($entry, $changes); -if (Net_LDAP2::isError($result)) { - die('Unable to update entry: '.$result->getMessage()); -} -*/ - -/* -// METHOD 2: ORDER = add->replace->delete -$result = $ldap->modify($entry, array('changes' => $changes)); -if (Net_LDAP2::isError($result)) { - die('Unable to update entry: '.$result->getMessage()); -} -*/ -?> \ No newline at end of file
View file
Net_LDAP2-2.0.9.tgz/Net_LDAP2-2.0.9/tests/Net_LDAP2Test.php
Deleted
@@ -1,887 +0,0 @@ -<?php -// Call Net_LDAP2Test::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Net_LDAP2Test::main"); -} - -require_once "PHPUnit/Framework/TestCase.php"; -require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Net/LDAP2.php'; -require_once 'Net/LDAP2/Entry.php'; - -/** - * Test class for Net_LDAP2. - * Generated by PHPUnit_Util_Skeleton on 2007-10-09 at 10:32:36. - */ -class Net_LDAP2Test extends PHPUnit_Framework_TestCase { - /** - * Stores the LDAP configuration - */ - var $ldapcfg = false; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() { - require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Net_LDAP2Test"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Load ldap config and adjust appropriately - * - * @access protected - */ - protected function setUp() { - $this->ldapcfg = $this->getTestConfig(); - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @access protected - */ - protected function tearDown() { - } - - /** - * This checks if a valid LDAP testconfig is present and loads it. - * - * If so, it is loaded and returned as array. If not, false is returned. - * - * @return false|array - */ - public function getTestConfig() { - $config = false; - $file = dirname(__FILE__).'/ldapconfig.ini'; - if (file_exists($file) && is_readable($file)) { - $config = parse_ini_file($file, true); - } else { - return false; - } - // validate ini - $v_error = $file.' is probably invalid. Did you quoted values correctly?'; - $this->assertTrue(array_key_exists('global', $config), $v_error); - $this->assertTrue(array_key_exists('test', $config), $v_error); - $this->assertEquals(7, count($config['global']), $v_error); - $this->assertEquals(7, count($config['test']), $v_error); - - // reformat things a bit, for convinience - $config['global']['server_binddn'] = - $config['global']['server_binddn'].','.$config['global']['server_base_dn']; - $config['test']['existing_attrmv'] = explode('|', $config['test']['existing_attrmv']); - return $config; - } - - /** - * Establishes a working connection - * - * @return Net_LDAP2 - */ - public function &connect() { - // Check extension - if (true !== Net_LDAP2::checkLDAPExtension()) { - $this->markTestSkipped('PHP LDAP extension not found or not loadable. Skipped Test.'); - } - - // Simple working connect and privilegued bind - $lcfg = array( - 'host' => $this->ldapcfg['global']['server_address'], - 'port' => $this->ldapcfg['global']['server_port'], - 'basedn' => $this->ldapcfg['global']['server_base_dn'], - 'binddn' => $this->ldapcfg['global']['server_binddn'], - 'bindpw' => $this->ldapcfg['global']['server_bindpw'], - 'filter' => '(ou=*)', - ); - $ldap = Net_LDAP2::connect($lcfg); - $this->assertType('Net_LDAP2', $ldap, 'Connect failed but was supposed to work. Check credentials and host address. If those are correct, file a bug!'); - return $ldap; - } - -/* ---------- TESTS ---------- */ - - /** - * testCheckLDAPExtension(). - * - * @todo can we unload modules at runtime?? - */ - public function testCheckLDAPExtension() { - if (extension_loaded('ldap')) { - // If extension is already loaded, then we must get true. - $this->assertTrue(Net_LDAP2::checkLDAPExtension()); - } else { - // If not, we should be able to load it - but may fail - $this->assertThat(Net_LDAP2::checkLDAPExtension(), - $this->logicalOr($this->isInstanceOf('Net_LDAP2_Error'), $this->equalTo(true))); - } - } - - /** - * Tests if getVersion() works correctly - */ - public function testGetVersion() { - $this->assertTrue(defined('NET_LDAP2_VERSION')); - $this->assertEquals(NET_LDAP2_VERSION, Net_LDAP2::getVersion()); - } - - /** - * Tests if the server can connect and bind correctly - */ - public function testConnectAndPrivileguedBind() { - // Check extension - if (true !== Net_LDAP2::checkLDAPExtension()) { - $this->markTestSkipped('PHP LDAP extension not found or not loadable. Skipped Test.'); - } - - if (!$this->ldapcfg) { - $this->markTestSkipped('No ldapconfig.ini found. Skipping test!'); - } else { - // This connect is supposed to fail - $lcfg = array( - 'host' => 'pear.net-ldap.test.hostunknown.cno', - ); - $ldap = Net_LDAP2::connect($lcfg); - $this->assertType('Net_LDAP2_Error', $ldap, 'Connect succeeded but was supposed to fail!'); - - // Failing with multiple hosts - $lcfg = array( - 'host' => array('pear.net-ldap.test.hostunknown1.cno', 'pear.net-ldap.test.hostunknown2.cno'), - ); - $ldap = Net_LDAP2::connect($lcfg); - $this->assertType('Net_LDAP2_Error', $ldap, 'Connect succeeded but was supposed to fail!'); - - // Simple working connect and privilegued bind - $ldap =& $this->connect(); - - // Working connect and privilegued bind with first host down - $lcfg = array( - 'host' => array( - 'pear.net-ldap.test.hostunknown1.cno', - $this->ldapcfg['global']['server_address'] - ), - 'port' => $this->ldapcfg['global']['server_port'], - 'binddn' => $this->ldapcfg['global']['server_binddn'], - 'bindpw' => $this->ldapcfg['global']['server_bindpw'], - ); - $ldap = Net_LDAP2::connect($lcfg); - $this->assertType('Net_LDAP2', $ldap, 'Connect failed but was supposed to work. Check credentials and host address. If those are correct, file a bug!'); - } - } - - /** - * Tests if the server can connect and bind anonymously, if supported (->cfg and ldap mode) - */ - public function testConnectAndAnonymousBind() { - // Check extension - if (true !== Net_LDAP2::checkLDAPExtension()) { - $this->markTestSkipped('PHP LDAP extension not found or not loadable. Skipped Test.'); - } - - if (!$this->ldapcfg) { - $this->markTestSkipped('No ldapconfig.ini found. Skipping test!'); - } elseif ($this->ldapcfg['global']['server_cap_anonymous'] == true) { - // Simple working connect and anonymous bind - $lcfg = array( - 'host' => $this->ldapcfg['global']['server_address'], - 'port' => $this->ldapcfg['global']['server_port'], - ); - $ldap = Net_LDAP2::connect($lcfg); - $this->assertType('Net_LDAP2', $ldap, 'Connect failed but was supposed to work. Check address and if server supports anonymous bind. If those are correct, file a bug!'); - } else { - $this->markTestSkipped('Server does not support anonymous bind (see ldapconfig.ini). Skipping test.'); - }
View file
Net_LDAP2-2.0.9.tgz/Net_LDAP2-2.0.9/tests/Net_LDAP2_FilterTest.php
Deleted
@@ -1,319 +0,0 @@ -<?php -// Call Net_LDAP2_FilterTest::main() if this source file is executed directly. -if (!defined("PHPUnit_MAIN_METHOD")) { - define("PHPUnit_MAIN_METHOD", "Net_LDAP2_FilterTest::main"); -} - -require_once "PHPUnit/Framework/TestCase.php"; -require_once "PHPUnit/Framework/TestSuite.php"; - -require_once 'Net/LDAP2/Filter.php'; - -/** - * Test class for Net_LDAP2_Filter. - * Generated by PHPUnit_Util_Skeleton on 2007-10-09 at 10:34:23. - */ -class Net_LDAP2_FilterTest extends PHPUnit_Framework_TestCase { - /** - * @var string default filter string to test with - */ - var $filter_str = '(&(cn=foo)(ou=bar))'; - - /** - * Runs the test methods of this class. - * - * @access public - * @static - */ - public static function main() { - require_once "PHPUnit/TextUI/TestRunner.php"; - - $suite = new PHPUnit_Framework_TestSuite("Net_LDAP2_FilterTest"); - $result = PHPUnit_TextUI_TestRunner::run($suite); - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - */ - protected function setUp() { - } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @access protected - */ - protected function tearDown() { - } - - /** - * This tests the perl compatible creation of filters through parsing of an filter string - */ - public function testCreatePerlCompatible() { - $filter_o = new Net_LDAP2_Filter($this->filter_str); - $this->assertType('Net_LDAP2_Filter', $filter_o); - $this->assertEquals($this->filter_str, $filter_o->asString()); - - $filter_o_err = new Net_LDAP2_Filter('some bad filter'); - $this->assertType('PEAR_Error', $filter_o_err->asString()); - } - - /** - * Test correct parsing of filter strings through parse() - */ - public function testParse() { - $parsed_dmg = Net_LDAP2_Filter::parse('some_damaged_filter_str'); - $this->assertType('PEAR_Error', $parsed_dmg); - - $parsed_dmg2 = Net_LDAP2_Filter::parse('(invalid=filter)(because=~no-surrounding brackets)'); - $this->assertType('PEAR_Error', $parsed_dmg2); - - $parsed_dmg3 = Net_LDAP2_Filter::parse('((invalid=filter)(because=log_op is missing))'); - $this->assertType('PEAR_Error', $parsed_dmg3); - - $parsed_dmg4 = Net_LDAP2_Filter::parse('(invalid-because-becauseinvalidoperator)'); - $this->assertType('PEAR_Error', $parsed_dmg4); - - $parsed_dmg5 = Net_LDAP2_Filter::parse('(&(filterpart>=ok)(part2=~ok)(filterpart3_notok---becauseinvalidoperator))'); - $this->assertType('PEAR_Error', $parsed_dmg5); - - $parsed1 = Net_LDAP2_Filter::parse($this->filter_str); - $this->assertType('Net_LDAP2_Filter', $parsed1); - $this->assertEquals($this->filter_str, $parsed1->asString()); - - // To verify bug #16738 is fixed. - // In 2.0.6 there was a problem with the splitting of the filter parts if the next part was also an combined filter - $parsed2_str = "(&(&(objectClass=posixgroup)(objectClass=foogroup))(uniquemember=uid=eeggs,ou=people,o=foo))"; - $parsed2 = Net_LDAP2_Filter::parse($parsed2_str); - $this->assertType('Net_LDAP2_Filter', $parsed2); - $this->assertEquals($parsed2_str, $parsed2->asString()); - - // To verify bug #17057 is fixed - // In 2.0.7 there was a problem parsing certain not-combined filter strings. - $parsed3_str = "(!(jpegPhoto=*))"; - $parsed3 = Net_LDAP2_Filter::parse($parsed3_str); - $this->assertType('Net_LDAP2_Filter', $parsed3); - $this->assertEquals($parsed3_str, $parsed3->asString()); - - $parsed3_complex_str = "(&(someAttr=someValue)(!(jpegPhoto=*)))"; - $parsed3_complex = Net_LDAP2_Filter::parse($parsed3_complex_str); - $this->assertType('Net_LDAP2_Filter', $parsed3_complex); - $this->assertEquals($parsed3_complex_str, $parsed3_complex->asString()); - - } - - - /** - * This tests the basic create() method of creating filters - */ - public function testCreate() { - // Test values and an array containing the filter - // creating methods and an regex to test the resulting filter - $testattr = 'testattr'; - $testval = 'testval'; - $combinations = array( - 'equals' => "/\($testattr=$testval\)/", - 'begins' => "/\($testattr=$testval\*\)/", - 'ends' => "/\($testattr=\*$testval\)/", - 'contains' => "/\($testattr=\*$testval\*\)/", - 'greater' => "/\($testattr>$testval\)/", - 'less' => "/\($testattr<$testval\)/", - 'greaterorequal' => "/\($testattr>=$testval\)/", - 'lessorequal' => "/\($testattr<=$testval\)/", - 'approx' => "/\($testattr~=$testval\)/", - 'any' => "/\($testattr=\*\)/" - ); - - foreach ($combinations as $match => $regex) { - // escaping is tested in util class - $filter = Net_LDAP2_Filter::create($testattr, $match, $testval, false); - - $this->assertType('Net_LDAP2_Filter', $filter); - $this->assertRegExp($regex, $filter->asString(), "Filter generation failed for MatchType: $match"); - } - - // test creating failure - $filter = Net_LDAP2_Filter::create($testattr, 'test_undefined_matchingrule', $testval); - $this->assertType('PEAR_Error', $filter); - } - - /** - * Tests, if asString() works - */ - public function testAsString() { - $filter = Net_LDAP2_Filter::create('foo', 'equals', 'bar'); - $this->assertType('Net_LDAP2_Filter', $filter); - $this->assertEquals('(foo=bar)', $filter->asString()); - $this->assertEquals('(foo=bar)', $filter->as_string()); - } - - /** - * Tests, if printMe() works - */ - public function testPrintMe() { - if (substr(strtolower(PHP_OS), 0,3) == 'win') { - $testfile = '/tmp/Net_LDAP2_Filter_printMe-Testfile'; - } else { - $testfile = 'c:\Net_LDAP2_Filter_printMe-Testfile'; - } - $filter = Net_LDAP2_Filter::create('testPrintMe', 'equals', 'ok'); - $this->assertType('Net_LDAP2_Filter', $filter); - - // print success: - ob_start(); - $printresult = $filter->printMe(); - ob_end_clean(); - $this->assertTrue($printresult); - - // PrintMe if Filehandle is an error (e.g. if some PEAR-File db is used): - $err = new PEAR_Error(); - $this->assertType('PEAR_Error', $filter->printMe($err)); - - // PrintMe if filter is damaged, - // $filter_dmg is used below too, to test printing to a file with - // damaged filter - $filter_dmg = new Net_LDAP2_Filter('damaged_filter_string'); - - // write success: - $file = @fopen($testfile, 'w'); - if (is_writable($testfile) && $file) { - $this->assertTrue($filter->printMe($file)); - $this->assertType('PEAR_Error', $filter_dmg->printMe($file)); // dmg. filter - @fclose($file); - } else { - $this->markTestSkipped("$testfile could not be opened in write mode, skipping write test"); - } - // write failure: - $file = @fopen($testfile, 'r'); - if (is_writable($testfile) && $file) { - $this->assertType('PEAR_Error', $filter->printMe($file)); - @fclose($file); - @unlink($testfile); - } else { - $this->markTestSkipped("$testfile could not be opened in read mode, skipping write test"); - } - }
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.