On a fresh install of Drupal 7.x-18, I install the ldap 7.x-2.0-beta3 (tried 7.x-2.x-dev also) module, I enable Ldap server, and LDAP User, enter the creds that work in ldap 7.x-1.0-beta12 and I get the following error when I attempt to test the server:

Warning: Invalid argument supplied for foreach() in LdapServer->groupUserMembershipsFromEntry() (line 1594 of /var/www/html/sites/all/modules/ldap/ldap_servers/LdapServer.class.php).
Warning: Invalid argument supplied for foreach() in LdapServer->groupUserMembershipsFromEntry() (line 1594 of /var/www/html/sites/all/modules/ldap/ldap_servers/LdapServer.class.php).

I get the following results:

Binding with DN for non-anonymous search (cn=provisionproxy,ou=Test,o=VEC). Using password stored in configuration
Successfully bound to server

No results are returned but error thrown:
Failed to find test user vec72 by searching on uid = vec72. Error Message: Invalid DN syntax

CommentFileSizeAuthor
#1 ldap_config.txt11.41 KBfbouzek

Comments

fbouzek’s picture

StatusFileSize
new11.41 KB

Tried to attach the ldap_config.html file, but it wouldn't let me. Renamed it .txt.

fbouzek’s picture

It seems the issue is in LdapServer.class.php:

function userUserNameToExistingLdapEntry

$basedns = (is_array($this->basedn)) ? $this->basedn : array();

fbouzek’s picture

Priority: Normal » Critical

This should probably be critical since it's impossible to get past the errors.

If I change that line to :
$basedns = (is_array($this->basedn)) ? $this->basedn : array($this->basedn);
The search works, but LDAP returns the error "Invalid DN Syntax"

probably because this is what is passed to ldap_search:
ldap_search() call: base_dn: a:1:{i:0;s:5:"o=VEC";}, filter = (uid=vec72), attributes: , attrsonly = 0, sizelimit = 0, timelimit = 0, deref = , scope = 3

fbouzek’s picture

Issue summary: View changes

Added that no results are returned

fbouzek’s picture

If I hard-code
$basedns = array("o=vec");
in place of
$basedns = (is_array($this->basedn)) ? $this->basedn : array();
all results are returned correctly, but I get the following errors:

Warning: Invalid argument supplied for foreach() in LdapServer->groupUserMembershipsFromEntry() (line 1618 of /var/www/html/sites/all/modules/ldap/ldap_servers/LdapServer.class.php).
Warning: Invalid argument supplied for foreach() in LdapServer->groupUserMembershipsFromEntry() (line 1618 of /var/www/html/sites/all/modules/ldap/ldap_servers/LdapServer.class.php).
Warning: htmlspecialchars(): Invalid multibyte sequence in argument in check_plain() (line 1545 of /var/www/html/includes/bootstrap.inc).
Warning: htmlspecialchars(): Invalid multibyte sequence in argument in check_plain() (line 1545 of /var/www/html/includes/bootstrap.inc).
Warning: htmlspecialchars(): Invalid multibyte sequence in argument in check_plain() (line 1545 of /var/www/html/includes/bootstrap.inc).

fbouzek’s picture

I applied the new dev today and the issue still exists as it did before. I believe it has something to do with the serialization of the basedn.

alexanderperlis’s picture

@fbouzek, a band-aid appears here: http://drupal.org/node/1880310#comment-6926478

johnbarclay’s picture

Status: Active » Closed (duplicate)
jdurfer’s picture

Version: 7.x-2.0-beta3 » 7.x-2.x-dev
Priority: Critical » Normal
Status: Closed (duplicate) » Needs work

Using Drupal 7.x-19 (upgraded from clean 7.18) tried module (ldap 7.x-2.0-beta3) getting same error as described:

Warning: Invalid argument supplied for foreach() in LdapServer->groupUserMembershipsFromEntry()
(line 1594 of /var/www/html/sites/all/modules/ldap/ldap_servers/LdapServer.class.php).

Removed module (ldap 7.x-2.0-beta3) and installed the dev module (7.x-2.x-dev, with feb 18 date) with appropriate ldap db update and got similar but different error:

Warning: Invalid argument supplied for foreach() in LdapServer->groupUserMembershipsFromEntry()
(line 1665 of /san/DrupalUAT/sites/all/modules/ldap_servers/LdapServer.class.php).

I am successfully binding with DN for non-anonymous search with password stored in configuration

Not critical, but in need of functioning LDAP soon.

jdurfer’s picture

Using 7.x-2.x-dev dated 2013-Mar-01.

"Warning: Invalid argument supplied for foreach() in LdapServer->groupUserMembershipsFromEntry() (line 1674 of/san/DrupalUAT/sites/all/modules/ldap/ldap_servers/LdapServer.class.php)."

Keep having to add code to unserialze second time. Edit the LdapServer.class.php and put in code:

// added 01 MARCH 2013////
// debug('initDerivedProperties'); debug($this->basedn);
if (!is_array($this->basedn)) {
$basedn_unserialized = @unserialize($this->basedn);
// debug('basedn_unserialized'); debug($basedn_unserialized);
$this->basedn = $basedn_unserialized;
}
//// /////

The error subsides but it would nice if we didn't have to keep making these edits on our own.

johnbarclay’s picture

Title: Error when trying to test server on fresh install » LDAP Servers: Error when trying to test server on fresh install

I'll commit this when I get a chance to look at the larger serialization issues. Or someone else does. Its part of the general work on exportables/Features/serialization. Thanks for the nudge though.

johnbarclay’s picture

Title: LDAP Servers: Error when trying to test server on fresh install » LDAP Servers: LdapServer->basedn property instantiation

LdapServer->basedn should always be an array. In the constructor for LdapServer , LdapServer::initDerivedProperties() is always called and it sets the ->basedn property to an array. I've tweaked the code a bit to make this clearer. http://drupalcode.org/project/ldap.git/commitdiff/6c17eb074d408bdf66b6b7...

The question is still where the double serialization is occurring.

johnbarclay’s picture

Here's a modification to make sure the array is set, regardless of if its in db or not: http://drupalcode.org/project/ldap.git/commitdiff/991b8006d1f9b9b557d594...

johnbarclay’s picture

Status: Needs work » Needs review

I believe this is fixed with the requirement of ctools and some error checking in LdapServer.class.php::initDerivedProperties (see http://drupalcode.org/project/ldap.git/blame/0e7e9edfddbc19b0ab30f1b6121...).

Can someone who's had this problem before, please try to replicate it?

johnbarclay’s picture

Priority: Normal » Major
johnbarclay’s picture

Status: Needs review » Closed (duplicate)

This is clearly a duplicate of #1903014: ldap_server_get_servers: $this->basedn is not unserialized which I'm working on testing and committting now with an update hook.

johnbarclay’s picture

Issue summary: View changes

test result