adldap / adLDAP

adLDAP is a PHP class that provides LDAP authentication and integration with Active Directory.
GNU Lesser General Public License v2.1
424 stars 204 forks source link

PHP Notice: Undefined offset: 2 #115

Open yarosdev opened 8 years ago

yarosdev commented 8 years ago

When user is member of multiple groups.

After research, I fiund out that $i <= $attributes[$key]['count'] should be rewritten $i < $attributes[$key]['count']

adldap\adldap\src\Objects\Ldap\Entry.php at line 52

        $keys = array_keys($attributes);

        foreach ($keys as $key) {
            if (is_array($attributes[$key]) && array_key_exists(0, $attributes[$key])) {
                // If the entry has multiple attributes, we'll make sure we loop through each one
                if (array_key_exists('count', $attributes[$key]) && $attributes[$key]['count'] > 1) {
                    $data = [];

                    for ($i = 0; $i <= $attributes[$key]['count']; $i++) {
                       $data[] = $attributes[$key][$i]; // LINE 52
                    }

                    $this->setAttribute($key, array_filter($data));
                } else {
                    // Looks like only one attribute exists, let's set it
                    $this->setAttribute($key, $attributes[$key][0]);
                }
            }
        }
jonathanjuursema commented 7 years ago

I had the same issue, and the fix works for me as well!

ellej16 commented 7 years ago

Hi @jonathanjuursema , @Yarisrespect , has this been fixed on the repository or not?

Just so future devs wouldnt encounter this. The fix works for me as well.

Cheers!

strebl commented 7 years ago

This repo is dead! Use Adldap2/Adldap2 instead. Not to hard to migrate 👌🏻

jonathanjuursema commented 7 years ago

Good to know. It seems we have already migrated away from this repo. :)