# 4.1 Ldap Authentication Not working

**URL:** <https://discourse.cakephp.org/t/4-1-ldap-authentication-not-working/8398>\
**Category:** Plugins\
**Created:** [September 18, 2020, 8:53pm UTC](https://discourse.cakephp.org/t/4-1-ldap-authentication-not-working/8398 "2020-09-18T20:53:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bugezzy](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bugezzy](https://discourse.cakephp.org/u/bugezzy)\
**Post date:** [September 18, 2020, 8:53pm UTC](https://discourse.cakephp.org/t/4-1-ldap-authentication-not-working/8398/1 "2020-09-18T20:53:46Z")

</div>

With php 7.4, the following function does not return a result. Seems to be an issue with ArrayObject not working.

LdapIdentifier.php

```
    protected function _bindUser(string $username, string $password): ?ArrayAccess
    {
        $config = $this->getConfig();
        try {
            $ldapBind = $this->_ldap->bind($config['bindDN']($username), $password);
            if ($ldapBind === true) {
                $this->_ldap->unbind();

                return new ArrayObject([
                    $config['fields'][self::CREDENTIAL_USERNAME] => $username,
                ]);
            }
        } catch (ErrorException $e) {
            $this->_handleLdapError($e->getMessage());
        }
        $this->_ldap->unbind();

        return null;
    }
```

---

<div class="post-metadata">

**Author:** ![bugezzy](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bugezzy](https://discourse.cakephp.org/u/bugezzy)\
**Post date:** [September 18, 2020, 10:07pm UTC](https://discourse.cakephp.org/t/4-1-ldap-authentication-not-working/8398/2 "2020-09-18T22:07:58Z")

</div>

Apparently this works, but debug() does not show ArrayObject with php 7.4
