code/services/LDAPService.php
public function updateLDAPFromMember(Member $member)
    {
        if (!$this->enabled()) {
            return;
        }
        if (!$member->GUID) {
            throw new ValidationException('Member missing GUID. Cannot update LDAP user');
        }

        $data = $this->getUserByGUID($member->GUID);
        if (empty($data['objectguid'])) {
            throw new ValidationException('LDAP synchronisation failure: user missing GUID');
        }

        if (empty($member->Username)) {
            throw new ValidationException('Member missing Username. Cannot update LDAP user');
        }

        $dn = $data['distinguishedname'];

        // Normalise username to lowercase to ensure we don't have duplicates of different cases
        $member->Username = strtolower($member->Username);

        try {
            // If the common name (cn) has changed, we need to ensure they've been moved
            // to the new DN, to avoid any clashes between user objects.
            if ($data['cn'] != $member->Username) {
                $newDn = sprintf('CN=%s,%s', $member->Username, preg_replace('/^CN=(.+?),/', '', $dn));
                $this->move($dn, $newDn);
                $dn = $newDn;
            }
        } catch (\Exception $e) {
            throw new ValidationException('LDAP move failure: '.$e->getMessage());
        }

        try {
            $attributes = [
                'displayname' => sprintf('%s %s', $member->FirstName, $member->Surname),
                'name' => sprintf('%s %s', $member->FirstName, $member->Surname),
                'userprincipalname' => sprintf(
                    '%s@%s',
                    $member->Username,
                    $this->gateway->config()->options['accountDomainName']
                ),
            ];
            foreach ($member->config()->ldap_field_mappings as $attribute => $field) {
                $relationClass = $member->getRelationClass($field);
                if ($relationClass) {
                    // todo no support for writing back relations yet.
                } else {
                    $attributes[$attribute] = $member->$field;
                }
            }

            $this->update($dn, $attributes);
        } catch (\Exception $e) {
            throw new ValidationException('LDAP synchronisation failure: '.$e->getMessage());
        }
    }
public function updateLDAPFromMember(Member $member)
    {
        if (!$this->enabled()) {
            return;
        }
        if (!$member->GUID) {
            throw new ValidationException('Member missing GUID. Cannot update LDAP user');
        }

        $data = $this->getUserByGUID($member->GUID);
        if (empty($data['objectguid'])) {
            throw new ValidationException('LDAP synchronisation failure: user missing GUID');
        }

        if (empty($member->Username)) {
            throw new ValidationException('Member missing Username. Cannot update LDAP user');
        }

        $dn = $data['distinguishedname'];

        // Normalise username to lowercase to ensure we don't have duplicates of different cases
        $member->Username = strtolower($member->Username);

        try {
            // If the common name (cn) has changed, we need to ensure they've been moved
            // to the new DN, to avoid any clashes between user objects.
            if ($data['cn'] != $member->Username) {
                $newDn = sprintf('CN=%s,%s', $member->Username, preg_replace('/^CN=(.+?),/', '', $dn));
                $this->move($dn, $newDn);
                $dn = $newDn;
            }
        } catch (\Exception $e) {
            throw new ValidationException('LDAP move failure: '.$e->getMessage());
        }

        try {
            $attributes = [
                'displayname' => sprintf('%s %s', $member->FirstName, $member->Surname),
                'name' => sprintf('%s %s', $member->FirstName, $member->Surname),
                'userprincipalname' => sprintf(
                    '%s@%s',
                    $member->Username,
                    $this->gateway->config()->options['accountDomainName']
                ),
            ];
            foreach ($member->config()->ldap_field_mappings as $attribute => $field) {
                $relationClass = $member->getRelationClass($field);
                if ($relationClass) {
                    // todo no support for writing back relations yet.
                } else {
                    $attributes[$attribute] = $member->$field;
                }
            }

            $this->update($dn, $attributes);
        } catch (\Exception $e) {
            throw new ValidationException('LDAP synchronisation failure: '.$e->getMessage());
        }
    }
Update the Member data back to the corresponding LDAP user object.

@param Member $member
@throws ValidationException