quoteDN.phpt Revision 1.1 (4 years, 5 months ago)

Location: [ Horde CVS ] / framework / LDAP / tests / quoteDN.phpt View: Annotate | Download

Log Message

Add a quoteDN() method that attempts to ensure RFC 1485-compliant
quoting of LDAP DNs. This won't be relied on by Turba because it was
introduced too late, but it's here for new code to use and as the
reference implementation.

Checkout

--TEST--
Horde_LDAP::quoteDN() tests
--FILE--
<?php

require_once dirname(__FILE__) . '/../LDAP.php';

echo Horde_LDAP::quoteDN(array(array('cn', 'John Smith'),
                               array('dc', 'example'),
                               array('dc', 'com'))) . "\n";

echo Horde_LDAP::quoteDN(array(array('cn', 'Smith, John'),
                               array('dc', 'example'),
                               array('dc', 'com'))) . "\n";

echo Horde_LDAP::quoteDN(array(array('cn', ' John Smith'),
                               array('dc', 'example'),
                               array('dc', 'com'))) . "\n";

echo Horde_LDAP::quoteDN(array(array('cn', 'John Smith '),
                               array('dc', 'example'),
                               array('dc', 'com'))) . "\n";

echo Horde_LDAP::quoteDN(array(array('cn', 'John  Smith'),
                               array('dc', 'example'),
                               array('dc', 'com'))) . "\n";

echo Horde_LDAP::quoteDN(array(array('cn', 'John+Smith'),
                               array('dc', 'example'),
                               array('dc', 'com'))) . "\n";

echo Horde_LDAP::quoteDN(array(array('cn', 'John "Bugsy" Smith'),
                               array('dc', 'example'),
                               array('dc', 'com'))) . "\n";

?>
--EXPECT--
cn=John Smith,dc=example,dc=com
cn="Smith, John",dc=example,dc=com
cn=" John Smith",dc=example,dc=com
cn="John Smith ",dc=example,dc=com
cn="John  Smith",dc=example,dc=com
cn="John+Smith",dc=example,dc=com
cn="John \"Bugsy\" Smith",dc=example,dc=com