ZF-10193: Zend_Ldap_Ldif_Encoder encode incorrectly boolean value

Issue Type: Patch Created: 2010-07-21T02:13:26.000+0000 Last Updated: 2010-09-22T10:06:49.000+0000 Status: Resolved Fix version(s): - 1.11.1 (30/Nov/10)

Reporter: St├ęphane Gully (kerphi) Assignee: Stefan Gehrig (sgehrig) Tags: - Zend_Ldap

Related issues: Attachments:


Here is a patch to fix this issue:

<pre class="highlight">
--- a/usr/share/php/zf/Zend/Ldap/Ldif/Encoder.php
+++ b/usr/share/php/zf/Zend/Ldap/Ldif/Encoder.php
@@ -180,6 +180,10 @@ class Zend_Ldap_Ldif_Encoder
     protected function _encodeString($string, &$base64 = null)
+        if (is_bool($string)) {
+                $string = $string ? 'TRUE' : 'FALSE';
+        }
         $string = (string)$string;
         if (!is_numeric($string) && empty($string)) {
             return '';


Posted by Stefan Gehrig (sgehrig) on 2010-07-25T10:50:48.000+0000

The Zend_Ldap_Ldif_Encoder originally was not designed to handle PHP datatypes and convert them into a LDIF representation. It was designed to convert LDAP data (retrieved from the LDAP e.g.) into LDIF data. A change in this behavior would be a bc-breaking change.

Furthermore it would duplicate conversion code from Zend_Ldap_Attribute into Zend_Ldap_Ldif_Encoder which is undesirable. Zend_Ldap_Attribute currently is the only component for converting PHP datatypes from and to LDAP data representation.

The current planing is to refactor Zend_Ldap_Attribute and put all the conversion code into Zend_Ldap_Converter (which currently is just a container for some low-level conversion methods). Zend_Ldap_Ldif_Encoder could then optionally use Zend_Ldap_Converter to allow for PHP datatypes to be directly converted into LDIF data.

Currently the workaround is to use Zend_Ldap_Attribute:

<pre class="highlight">
$data = array();
Zend_Ldap_Attribute::setAttribute($data, "booleanValue", array(true, false));
$ldif = Zend_Ldap_Ldif_Encoder::encode($data);

Posted by Stefan Gehrig (sgehrig) on 2010-09-22T10:06:49.000+0000

Should be solved with the new Zend_Ldap_Converter

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.