application/Espo/Core/Utils/Authentication/LDAP.php
protected function createUser(array $userData, $isPortal = false)
    {
        $GLOBALS['log']->info('Creating new user ...');
        $data = array();

        // show full array of the LDAP user
        $GLOBALS['log']->debug('LDAP: user data: ' .print_r($userData, true));

        //set values from ldap server
        $ldapFields = $this->loadFields('ldap');
        foreach ($ldapFields as $espo => $ldap) {
            $ldap = strtolower($ldap);
            if (isset($userData[$ldap][0])) {
                $GLOBALS['log']->debug('LDAP: Create a user wtih ['.$espo.'] = ['.$userData[$ldap][0].'].');
                $data[$espo] = $userData[$ldap][0];
            }
        }

        //set user fields
        if ($isPortal) {
            $userFields = $this->loadFields('portalUser');
            $userFields['type'] = 'portal';
        } else {
            $userFields = $this->loadFields('user');
        }

        foreach ($userFields as $fieldName => $fieldValue) {
            $data[$fieldName] = $fieldValue;
        }

        $this->getAuth()->useNoAuth();

        $user = $this->getEntityManager()->getEntity('User');
        $user->set($data);

        $this->getEntityManager()->saveEntity($user);

        return $this->getEntityManager()->getEntity('User', $user->id);
    }
protected function createUser(array $userData, $isPortal = false)
    {
        $GLOBALS['log']->info('Creating new user ...');
        $data = array();

        // show full array of the LDAP user
        $GLOBALS['log']->debug('LDAP: user data: ' .print_r($userData, true));

        //set values from ldap server
        $ldapFields = $this->loadFields('ldap');
        foreach ($ldapFields as $espo => $ldap) {
            $ldap = strtolower($ldap);
            if (isset($userData[$ldap][0])) {
                $GLOBALS['log']->debug('LDAP: Create a user wtih ['.$espo.'] = ['.$userData[$ldap][0].'].');
                $data[$espo] = $userData[$ldap][0];
            }
        }

        //set user fields
        if ($isPortal) {
            $userFields = $this->loadFields('portalUser');
            $userFields['type'] = 'portal';
        } else {
            $userFields = $this->loadFields('user');
        }

        foreach ($userFields as $fieldName => $fieldValue) {
            $data[$fieldName] = $fieldValue;
        }

        $this->getAuth()->useNoAuth();

        $user = $this->getEntityManager()->getEntity('User');
        $user->set($data);

        $this->getEntityManager()->saveEntity($user);

        return $this->getEntityManager()->getEntity('User', $user->id);
    }
protected function createUser ( array $ userData , $ isPortal = false ) { $ GLOBALS [ 'log' ] -> info ( 'Creating new user ...' ) ; $ data = array ( ) ; // show full array of the LDAP user $ GLOBALS [ 'log' ] -> debug ( 'LDAP: user data: ' . print_r ( $ userData , true ) ) ; //set values from ldap server $ ldapFields = $ this -> loadFields ( 'ldap' ) ; foreach ( $ ldapFields as $ espo => $ ldap ) { $ ldap = strtolower ( $ ldap ) ; if ( isset ( $ userData [ $ ldap ] [ 0 ] ) ) { $ GLOBALS [ 'log' ] -> debug ( 'LDAP: Create a user wtih [' . $ espo . '] = [' . $ userData [ $ ldap ] [ 0 ] . '].' ) ; $ data [ $ espo ] = $ userData [ $ ldap ] [ 0 ] ; } } //set user fields if ( $ isPortal ) { $ userFields = $ this -> loadFields ( 'portalUser' ) ; $ userFields [ 'type' ] = 'portal' ; } else { $ userFields = $ this -> loadFields ( 'user' ) ; } foreach ( $ userFields as $ fieldName => $ fieldValue ) { $ data [ $ fieldName ] = $ fieldValue ; } $ this -> getAuth ( ) -> useNoAuth ( ) ; $ user = $ this -> getEntityManager ( ) -> getEntity ( 'User' ) ; $ user -> set ( $ data ) ; $ this -> getEntityManager ( ) -> saveEntity ( $ user ) ; return $ this -> getEntityManager ( ) -> getEntity ( 'User' , $ user -> id ) ; }
Create Espo user with data gets from LDAP server

@param  array $userData LDAP entity data
@param  boolean $isPortal Is portal user

@return \Espo\Entities\User
Create Espo user with data gets from LDAP server