code/services/LDAPService.php
public function createLDAPUser(Member $member)
    {
        if (!$this->enabled()) {
            return;
        }
        if (empty($member->Username)) {
            throw new ValidationException('Member missing Username. Cannot create LDAP user');
        }
        if (!$this->config()->new_users_dn) {
            throw new Exception('LDAPService::new_users_dn must be configured to create LDAP users');
        }

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

        // Create user in LDAP using available information.
        $dn = sprintf('CN=%s,%s', $member->Username, $this->config()->new_users_dn);

        try {
            $this->add($dn, [
                'objectclass' => 'user',
                'cn' => $member->Username,
                'accountexpires' => '9223372036854775807',
                'useraccountcontrol' => '66048',
                'userprincipalname' => sprintf(
                    '%s@%s',
                    $member->Username,
                    $this->gateway->config()->options['accountDomainName']
                ),
            ]);
        } catch (\Exception $e) {
            throw new ValidationException('LDAP synchronisation failure: '.$e->getMessage());
        }

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

        // Creation was successful, mark the user as LDAP managed by setting the GUID.
        $member->GUID = $user['objectguid'];
    }
public function createLDAPUser(Member $member)
    {
        if (!$this->enabled()) {
            return;
        }
        if (empty($member->Username)) {
            throw new ValidationException('Member missing Username. Cannot create LDAP user');
        }
        if (!$this->config()->new_users_dn) {
            throw new Exception('LDAPService::new_users_dn must be configured to create LDAP users');
        }

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

        // Create user in LDAP using available information.
        $dn = sprintf('CN=%s,%s', $member->Username, $this->config()->new_users_dn);

        try {
            $this->add($dn, [
                'objectclass' => 'user',
                'cn' => $member->Username,
                'accountexpires' => '9223372036854775807',
                'useraccountcontrol' => '66048',
                'userprincipalname' => sprintf(
                    '%s@%s',
                    $member->Username,
                    $this->gateway->config()->options['accountDomainName']
                ),
            ]);
        } catch (\Exception $e) {
            throw new ValidationException('LDAP synchronisation failure: '.$e->getMessage());
        }

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

        // Creation was successful, mark the user as LDAP managed by setting the GUID.
        $member->GUID = $user['objectguid'];
    }
Creates a new LDAP user from the passed Member record.
Note that the Member record must have a non-empty Username field for this to work.

@param Member $member