Nextcloud integration with Zimbra Drive

[details=“Undefined offset: -8179 at /var/www/html/nextcloud/apps/zimbradrive/lib/service/test/zimbraauthenticationserviceconnectiontest.php#161”]

Nextcloud version (version 13):
Operating system and version (Centos 7):
Apache or nginx version (Apache/2.4.6 (CentOS):
PHP version (PhP 7.1):

The issue you are facing:

Is this the first time you’ve seen this error? (Y): Yes

Steps to replicate it:

The output of your Nextcloud log in Admin > Logging:

PASTE HERE

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

[root@nc config]# cat config.php 
<?php
$CONFIG = array (
  'instanceid' => 'ocsxdqlrrln8',
  'passwordsalt' => 'uymIbFPLjsyhnIEfbmGdW51apfkYlJsmHu4',
  'secret' => 'j2uIeb9Oe7IZpxNv0H4vdsskaneyicnrGtKoDSeJPjHK',
  'trusted_domains' => 
  array (
    0 => '192.168.x.x',
  ),
  'datadirectory' => '/var/www/html/nextcloud/data',
  'overwrite.cli.url' => 'http://192.168.x.x/nextcloud',
  'dbtype' => 'sqlite3',
  'version' => '13.0.5.2',
  'dbname' => 'zdrive',
  'dbhost' => 'nc.zcs.int:443',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextclouduser',
  'dbpassword' => '*************',
  'installed' => true,
  'user_backends' => 
  array (
    0 => 
    array (
      'class' => 'OCA\\ZimbraDrive\\Auth\\ZimbraUsersBackend',
      'arguments' => 
      array (
      ),
    ),
  ),
  'loglevel' => 0,
);

The output of your Apache/nginx/system log in

:/var/www/html/nextcloud/apps/zimbradrive/lib/service/zimbraauthentication.php

[root@nc service]# cat zimbraauthentication.php 
<?php
/**
 * Zimbra Drive App
 * Copyright (C) 2017  Zextras Srl
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 * If you require any further information, feel free to contact legal@zextras.com.
 */

namespace OCA\ZimbraDrive\Service;

use OCP\IConfig;


class ZimbraAuthentication
{
    const USER_BACKEND_VAR_NAME = 'user_backends';
    const ZIMBRA_USER_BACKEND_CLASS_VALUE = 'OCA\ZimbraDrive\Auth\ZimbraUsersBackend';
    private $logger;
    /**
     * @var IConfig
     */
    private $config;

    /**
     * @param IConfig $config
     * @param LogService $logger
     */
    public function __construct(
        IConfig $config,
        LogService $logger
    )
    {
        $this->logger = $logger;
        $this->config = $config;
    }

    public function enableZimbraAuthentication()
    {
        $userBackends = $this->config->getSystemValue(self::USER_BACKEND_VAR_NAME, array());

        $zimbraUserBackend = array(
            'class' => self::ZIMBRA_USER_BACKEND_CLASS_VALUE,
            'arguments' => array (),
        );
        $userBackends[] = $zimbraUserBackend;

        $this->config->setSystemValue(self::USER_BACKEND_VAR_NAME, $userBackends);
    }

    public function disableZimbraAuthentication()
    {
        $userBackends = $this->config->getSystemValue(self::USER_BACKEND_VAR_NAME, array());

        $userBackendsWithoutZimbra = array();
        foreach($userBackends as $userBackend)
        {
            if($userBackend['class'] !== self::ZIMBRA_USER_BACKEND_CLASS_VALUE)
            {
                $userBackendsWithoutZimbra[] = $userBackend;
            }
        }
        if(count($userBackendsWithoutZimbra) === 0)
        {
            $this->config->deleteSystemValue(self::USER_BACKEND_VAR_NAME);
        }else
        {
            $this->config->setSystemValue(self::USER_BACKEND_VAR_NAME, $userBackendsWithoutZimbra);
        }
    }

    public function isZimbraAuthenticationEnabled()
    {
        $userBackends = $this->config->getSystemValue(self::USER_BACKEND_VAR_NAME, array());
        foreach($userBackends as $userBackend){
            $class = $userBackend['class'];
            if(isset($class) && $class === ZimbraAuthentication::ZIMBRA_USER_BACKEND_CLASS_VALUE)
            {
                return true;
            }
        }
        return false;
    }