source/Application/Model/User.php
protected function _ldapLogin($sUser, $sPassword, $sShopID, $sShopSelect)
    {
        $aLDAPParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('aLDAPParams');
        $oLDAP = oxNew(\OxidEsales\Eshop\Core\LDAP::class, $aLDAPParams['HOST'], $aLDAPParams['PORT']);

        // maybe this is LDAP user but supplied email Address instead of LDAP login
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $sLDAPKey = $oDb->getOne("select oxldapkey from oxuser where oxuser.oxactive = 1 and oxuser.oxusername = " . $oDb->quote($sUser) . " $sShopSelect");
        if (isset($sLDAPKey) && $sLDAPKey) {
            $sUser = $sLDAPKey;
        }

        //$throws oxConnectionException
        $oLDAP->login($sUser, $sPassword, $aLDAPParams['USERQUERY'], $aLDAPParams['BASEDN'], $aLDAPParams['FILTER']);

        $aData = $oLDAP->mapData($aLDAPParams['DATAMAP']);
        if (isset($aData['OXUSERNAME']) && $aData['OXUSERNAME']) {
            // login successful

            // check if user is already in database
            $sSelect = "select oxid from oxuser where oxuser.oxusername = " . $oDb->quote($aData['OXUSERNAME']) . " $sShopSelect";
            $sOXID = $oDb->getOne($sSelect);

            if (!isset($sOXID) || !$sOXID) {
                // we need to create a new user
                //$oUser->oxuser__oxid->setValue($oUser->setId());
                $this->setId();

                // map all user data fields
                foreach ($aData as $fldname => $value) {
                    $sField = "oxuser__" . strtolower($fldname);
                    $this->$sField = new Field($aData[$fldname]);
                }

                $this->oxuser__oxactive = new \OxidEsales\Eshop\Core\Field(1);
                $this->oxuser__oxshopid = new \OxidEsales\Eshop\Core\Field($sShopID);
                $this->oxuser__oxldapkey = new \OxidEsales\Eshop\Core\Field($sUser);
                $this->oxuser__oxrights = new \OxidEsales\Eshop\Core\Field("user");
                $this->setPassword("ldap user");

                $this->save();
            } else {
                // LDAP user is already in OXID DB, load it
                $this->load($sOXID);
            }
        } else {
            /** @var UserException $oEx */
            $oEx = oxNew(UserException::class);
            $oEx->setMessage('ERROR_MESSAGE_USER_NOVALUES');
            throw $oEx;
        }
    }
protected function _ldapLogin($sUser, $sPassword, $sShopID, $sShopSelect)
    {
        $aLDAPParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('aLDAPParams');
        $oLDAP = oxNew(\OxidEsales\Eshop\Core\LDAP::class, $aLDAPParams['HOST'], $aLDAPParams['PORT']);

        // maybe this is LDAP user but supplied email Address instead of LDAP login
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $sLDAPKey = $oDb->getOne("select oxldapkey from oxuser where oxuser.oxactive = 1 and oxuser.oxusername = " . $oDb->quote($sUser) . " $sShopSelect");
        if (isset($sLDAPKey) && $sLDAPKey) {
            $sUser = $sLDAPKey;
        }

        //$throws oxConnectionException
        $oLDAP->login($sUser, $sPassword, $aLDAPParams['USERQUERY'], $aLDAPParams['BASEDN'], $aLDAPParams['FILTER']);

        $aData = $oLDAP->mapData($aLDAPParams['DATAMAP']);
        if (isset($aData['OXUSERNAME']) && $aData['OXUSERNAME']) {
            // login successful

            // check if user is already in database
            $sSelect = "select oxid from oxuser where oxuser.oxusername = " . $oDb->quote($aData['OXUSERNAME']) . " $sShopSelect";
            $sOXID = $oDb->getOne($sSelect);

            if (!isset($sOXID) || !$sOXID) {
                // we need to create a new user
                //$oUser->oxuser__oxid->setValue($oUser->setId());
                $this->setId();

                // map all user data fields
                foreach ($aData as $fldname => $value) {
                    $sField = "oxuser__" . strtolower($fldname);
                    $this->$sField = new Field($aData[$fldname]);
                }

                $this->oxuser__oxactive = new \OxidEsales\Eshop\Core\Field(1);
                $this->oxuser__oxshopid = new \OxidEsales\Eshop\Core\Field($sShopID);
                $this->oxuser__oxldapkey = new \OxidEsales\Eshop\Core\Field($sUser);
                $this->oxuser__oxrights = new \OxidEsales\Eshop\Core\Field("user");
                $this->setPassword("ldap user");

                $this->save();
            } else {
                // LDAP user is already in OXID DB, load it
                $this->load($sOXID);
            }
        } else {
            /** @var UserException $oEx */
            $oEx = oxNew(UserException::class);
            $oEx->setMessage('ERROR_MESSAGE_USER_NOVALUES');
            throw $oEx;
        }
    }
protected function _ldapLogin ( $ sUser , $ sPassword , $ sShopID , $ sShopSelect ) { $ aLDAPParams = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'aLDAPParams' ) ; $ oLDAP = oxNew ( \ OxidEsales \ Eshop \ Core \ LDAP :: class , $ aLDAPParams [ 'HOST' ] , $ aLDAPParams [ 'PORT' ] ) ; // maybe this is LDAP user but supplied email Address instead of LDAP login $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sLDAPKey = $ oDb -> getOne ( "select oxldapkey from oxuser where oxuser.oxactive = 1 and oxuser.oxusername = " . $ oDb -> quote ( $ sUser ) . " $sShopSelect" ) ; if ( isset ( $ sLDAPKey ) && $ sLDAPKey ) { $ sUser = $ sLDAPKey ; } //$throws oxConnectionException $ oLDAP -> login ( $ sUser , $ sPassword , $ aLDAPParams [ 'USERQUERY' ] , $ aLDAPParams [ 'BASEDN' ] , $ aLDAPParams [ 'FILTER' ] ) ; $ aData = $ oLDAP -> mapData ( $ aLDAPParams [ 'DATAMAP' ] ) ; if ( isset ( $ aData [ 'OXUSERNAME' ] ) && $ aData [ 'OXUSERNAME' ] ) { // login successful // check if user is already in database $ sSelect = "select oxid from oxuser where oxuser.oxusername = " . $ oDb -> quote ( $ aData [ 'OXUSERNAME' ] ) . " $sShopSelect" ; $ sOXID = $ oDb -> getOne ( $ sSelect ) ; if ( ! isset ( $ sOXID ) || ! $ sOXID ) { // we need to create a new user //$oUser->oxuser__oxid->setValue($oUser->setId()); $ this -> setId ( ) ; // map all user data fields foreach ( $ aData as $ fldname => $ value ) { $ sField = "oxuser__" . strtolower ( $ fldname ) ; $ this -> $ sField = new Field ( $ aData [ $ fldname ] ) ; } $ this -> oxuser__oxactive = new \ OxidEsales \ Eshop \ Core \ Field ( 1 ) ; $ this -> oxuser__oxshopid = new \ OxidEsales \ Eshop \ Core \ Field ( $ sShopID ) ; $ this -> oxuser__oxldapkey = new \ OxidEsales \ Eshop \ Core \ Field ( $ sUser ) ; $ this -> oxuser__oxrights = new \ OxidEsales \ Eshop \ Core \ Field ( "user" ) ; $ this -> setPassword ( "ldap user" ) ; $ this -> save ( ) ; } else { // LDAP user is already in OXID DB, load it $ this -> load ( $ sOXID ) ; } } else { /** @var UserException $oEx */ $ oEx = oxNew ( UserException :: class ) ; $ oEx -> setMessage ( 'ERROR_MESSAGE_USER_NOVALUES' ) ; throw $ oEx ; } }
Login for Ldap

@param string $sUser       User username
@param string $sPassword   User password
@param string $sShopID     Shop id
@param string $sShopSelect Shop select

@deprecated v5.3 (2016-10-06); LDAP will be moved to own module.

@throws $oEx if user is wrong
Login for Ldap