Navigation

    Kopano
    • Register
    • Login
    • Search
    • Categories
    • Get Official Kopano Support
    • Recent
    Statement regarding the closure of the Kopano community forum and the end of the community edition

    only full username with domain is used in caldav and carddav

    Z-Push when using other backends
    4
    8
    728
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • BigMichi1
      BigMichi1 last edited by

      hello,

      i’m using z-push in combination with nextcloud and have a serious issue when i want to use the combined backend (imap and nextcloud) with caldav and cardav. my problem is that for caldav and carddav i need to modify the sources after each update because the %u variable in the Logon part of both backends are containing the full email address but my shares are only using the local part without the domain part. but for imap i need the full username with the domain part.
      so what i’m currently doing after each update i modify the Logon method in both backends for example the carddav backend from

      str_replace("%u", $username, CARDDAV_PATH)
      

      to

      str_replace("%u", Utils::GetLocalPartFromEmail($username), CARDDAV_PATH)
      

      so my question is there a better way to do it? maybe with a different option that i need to configure for each backend. Or can another variable be set in the config file in the urls so that it is no longer %u maybe instead %l for the local part, like it is already done for domainpart with %d.

      orlovnv 1 Reply Last reply Reply Quote 0
      • Manfred
        Manfred Kopano last edited by

        Hi @BigMichi1,

        I’ve created a JIRA issue to address this: https://jira.z-hub.io/browse/ZP-1522.

        In my opinion adding another placeholder like %l to the variables would be the best solution.

        Manfred

        1 Reply Last reply Reply Quote 0
        • BigMichi1
          BigMichi1 last edited by

          thanks, looking forward to the fix

          1 Reply Last reply Reply Quote 0
          • orlovnv
            orlovnv @BigMichi1 last edited by

            @BigMichi1 could you show your caldav and carddav php files, i have the same problem with nextcloud.

            BigMichi1 1 Reply Last reply Reply Quote 0
            • BigMichi1
              BigMichi1 @orlovnv last edited by

              @orlovnv
              nano /usr/share/z-push/backend/carddav/carddav.php

                  public function Logon($username, $domain, $password) {
                      $this->url = CARDDAV_PROTOCOL . '://' . CARDDAV_SERVER . ':' . CARDDAV_PORT . str_replace("%d", $domain, str_replace("%u", Utils::GetLocalPartFromEmail($username), CARDDAV_PATH));
                      $this->default_url = CARDDAV_PROTOCOL . '://' . CARDDAV_SERVER . ':' . CARDDAV_PORT . str_replace("%d", $domain, str_replace("%u", Utils::GetLocalPartFromEmail($username), CARDDAV_DEFAULT_PATH));
                      if (defined('CARDDAV_GAL_PATH')) {
                          $this->gal_url = CARDDAV_PROTOCOL . '://' . CARDDAV_SERVER . ':' . CARDDAV_PORT . str_replace("%d", $domain, str_replace("%u", Utils::GetLocalPartFromEmail($username), CARDDAV_GAL_PATH));
                      }
                      else {
                          $this->gal_url = false;
                      }
                      $this->server = new carddav_backend($this->url, CARDDAV_URL_VCARD_EXTENSION);
                      $this->server->set_auth($username, $password);
              
                      if (($connected = $this->server->check_connection())) {
                          ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV->Logon(): User '%s' is authenticated on '%s'", $username, $this->url));
                          $this->username = $username;
                          $this->domain = $domain;
              
                          // Autodiscover all the addressbooks
                          $this->discoverAddressbooks();
                      }
                      else {
                          //TODO: get error message
                          $error = '';
                          ZLog::Write(LOGLEVEL_ERROR, sprintf("BackendCardDAV->Logon(): User '%s' failed to authenticate on '%s': %s", $username, $this->url, $error));
                          $this->server = null;
                      }
              
                      return $connected;
                  }
              

              and

              nano /usr/share/z-push/backend/caldav/caldav.php

                  public function Logon($username, $domain, $password) {
                      $this->_caldav_path = str_replace('%u', Utils::GetLocalPartFromEmail($username), CALDAV_PATH);
                      $url = sprintf("%s://%s:%d%s", CALDAV_PROTOCOL, CALDAV_SERVER, CALDAV_PORT, $this->_caldav_path);
                      $this->_caldav = new CalDAVClient($url, $username, $password);
                      if ($connected = $this->_caldav->CheckConnection()) {
                          ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCalDAV->Logon(): User '%s' is authenticated on CalDAV '%s'", $username, $url));
                          if ($domain == "") {
                              $this->originalUsername = Utils::GetLocalPartFromEmail($username);
                          }
                          else {
                              $this->originalUsername = Utils::GetLocalPartFromEmail($username) . '@' . $domain;
                          }
                      }
                      else {
                          ZLog::Write(LOGLEVEL_WARN, sprintf("BackendCalDAV->Logon(): User '%s' is not authenticated on CalDAV '%s'", $username, $url));
                      }
              
                      return $connected;
                  }
              
              1 Reply Last reply Reply Quote 0
              • bob4os
                bob4os last edited by

                I will create a fix for you.

                You don’t need to bother with $this->originalUsername in caldav.php, because this is a remnant of changes from issue ZP-1410, not properly cleaned up.

                I think ‘%l’ is a good proposal from Manfred, so I’m going with this.

                This are the only lines of code you changed right?
                (I’m going to create a branch, it would be nice having a person testing this… I will report back as soon as I created the branch and commit.)

                1 Reply Last reply Reply Quote 0
                • bob4os
                  bob4os last edited by

                  I created a branch and pull request - if anybody wants to test this, go to https://stash.z-hub.io/projects/ZP/repos/z-push/branches and look into ZP-1522.

                  I added / expanded explanations in config files too, it should be easy to adapt your configurations.

                  1 Reply Last reply Reply Quote 0
                  • bob4os
                    bob4os last edited by

                    Pull request got merged, Z-Push release 2.6.3 will most likely contain the fix.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post