ldap_filter.php-add-dn.diff (821 b) added by Gunnstein Lye
Index: Authentication/src/filters/ldap/ldap_filter.php
===================================================================
--- Authentication/src/filters/ldap/ldap_filter.php (revision 10730)
+++ Authentication/src/filters/ldap/ldap_filter.php (working copy)
@@ -293,6 +293,13 @@
$this->data[$attribute][] = $attributes[$attribute][$i];
}
}
+
+ // DN is a 'special' attribute and is not returned by ldap_get_attributes()
+ if ( strtolower( $attribute ) == 'dn' )
+ {
+ // An entry can only have one DN
+ $this->data[$attribute] = $entryDN;
+ }
}
}
ldap_test.php-add-dn.diff (1.5 kb) added by Gunnstein Lye
Description: Test for the provided patch
Index: Authentication/tests/filters/ldap/ldap_test.php
===================================================================
--- Authentication/tests/filters/ldap/ldap_test.php (revision 10733)
+++ Authentication/tests/filters/ldap/ldap_test.php (working copy)
@@ -330,6 +330,25 @@
$this->assertEquals( $expected, $filter->fetchData() );
}
+ /**
+ * Test for issue #15244 (DN can not be retrieved from the LDAP filter (patch)).
+ */
+ public function testLdapFetchExtraDataDN()
+ {
+ $credentials = new ezcAuthenticationPasswordCredentials( 'jan.modaal', 'qwerty' );
+ $ldap = new ezcAuthenticationLdapInfo( self::$host, self::$format, self::$base, self::$port );
+ $authentication = new ezcAuthentication( $credentials );
+ $filter = new ezcAuthenticationLdapFilter( $ldap );
+ $filter->registerFetchData( array( 'uid', 'dn' ) );
+ $authentication->addFilter( $filter );
+ $this->assertEquals( true, $authentication->run() );
+
+ $expected = array( 'uid' => array( 'jan.modaal' ),
+ 'dn' => 'uid=jan.modaal,dc=ezctest,dc=ez,dc=no'
+ );
+ $this->assertEquals( $expected, $filter->fetchData() );
+ }
+
public function testLdapInfo()
{
$ldap = ezcAuthenticationLdapInfo::__set_state( array( 'host' => self::$host, 'format' => self::$format, 'base' => self::$base, 'port' => self::$port, 'protocol' => ezcAuthenticationLdapFilter::PROTOCOL_TLS ) );