Home » Authentication » Auth » Bug #7654
options retrieved by parse_ini_file do not work with Auth_LDAP due to triple =
Details
| Submitted | 2006-05-17 23:27 UTC |
|---|---|
| From | fred at osuosl dot org |
| Assigned | aashley |
| Status | Closed |
| Package | Auth |
| PHP Version | 4.4.0 |
| OS | Linux x86 |
| Roadmaps | (Not assigned) |
Comments
[2006-05-17 23:27 UTC] fred at osuosl dot org
Description:
------------
We are using auth_ldap to authenticate against an LDAP server. The options are retrieved from an ini file editable by the user and parsed through parse_ini_file(.).
However, parse_ini_file translates everything to strings, for example true becomes "1".
This breaks the LDAP container: the option debug is not recognized for example, because it checks with triple equal signs ("==="), which does not match "1".
Also, when setting the LDAP version to "3", it breaks again, because a check is_int(version) is executed, which is false for "3".
I cannot see a reason why the variable type is enforced in these cases. Nothing bad will happen if we only use double equal signs and do not check for int.
I patched LDAP.php and submitted the patch below for you to include.
Thanks.
Frederic Wenzel
Maintain Project Developer
http://maintainproject.osuosl.org
Test script:
---------------
Index: LDAP.php
===================================================================
--- LDAP.php (revision 4414)
+++ LDAP.php (working copy)
@@ -254,7 +254,7 @@
$this->_debug('Successfully connected to server', __LINE__);
// switch LDAP version
- if (is_int($this->options['version']) && $this->options['version'] > 2) {
+ if ($this->options['version'] > 2) {
$this->_debug("Switching to LDAP version {$this->options['version']}", __LINE__);
@ldap_set_option($this->conn_id, LDAP_OPT_PROTOCOL_VERSION, $this->options['version']);
}
@@ -658,7 +658,7 @@
*/
function _debug($msg = '', $line = 0)
{
- if ($this->options['debug'] === true) {
+ if ($this->options['debug'] == true) {
if ($msg == '' && $this->_isValidLink()) {
$msg = 'LDAP_Error: ' . @ldap_err2str(@ldap_errno($this->_conn_id));
}
[2006-08-10 02:27 UTC] aashley at php dot net
This bug has been fixed in CVS.
If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET).
If this was a problem with the pear.php.net website, the change should be live shortly.
Otherwise, the fix will appear in the package's next release.
Thank you for the report and for helping us make PEAR better.