Nextcloud app - mounting samba shares as external storage

Hi All,
I face an issue that I cannot solve, thus seeking input here. I gathered that folks were successful in mounting a samba share in their nextcloud instance using the externals storage app within nextcloud, but for me does not work. There is a “cool solution” for this, but its content is not fully clear to me.

The problem for not being able to mount an external share is likely due to access at the nextcloud server level. But this is in a docker container, so it is not clear how to provide access to the nextcloud app to the samba share. Accessing the share from the member server on which the nextcloud app is running works OK. Accessing the samba share from within the nextcloud shell is giving me NT_STATUS_BAD_NETWORK_NAME error. The docker container does not have (m)any utilities so it is not clear for me how to troubleshoot this. The container did not have the smbclient installed which I did to test access.

Can someone please with a working solution post how to open the necessary ports in registry to allow external storage access into nextcloud docker?
Thanks in advance

so managed to troubleshoot this a bit further: when I installed the smbclient with apt-get in the nextcloud docker container, it did not create the following folder: /var/run/samba folder thus the smbclient gave an error. Now I can access the samba share from within the docker container, I still cannot mount it nextcloud as external storage. so…

root@nextc-12345678:/# smbclient -U user@DOMAIN //ip.address/share

works as expected. I am still getting a red exclamation point when trying to set up a share as external storage within nextcloud admin GUI

forgot to include any info on my setup: have a DC Master+DC Backup based on latest Univention Corporate Server supporting about 7 Windows and Linux clients since the AD takeover.There is also another ucs1 member-server which has kopano and nextcloud I would like to include the home folders of users in nextcloud using smb/cifs. This works very well in kopano.

Have not made any progress sorting this out. To recap: I am trying to add a SMB/CIFS share in the nextcloud management UI to all my users as external storage and not succeeding.
The SAMBA share host can be pinged from within the nextcloud docker shell and the share accessed with smbclient, again from within the nextcloud shell.

When I try to mount it in the nextcloud UI, I get a red exclamation point. There is no record in the SAMBA logs of any attempt made from the nextcloud docker network or the docker host network.
Obviously, when I use the smbclient in the docker shell, I get the logs on the SAMBA server and all is OK. I tried editing the smb.conf to specify the domain in the nextcloud to no avail. The SAMBA server is a member of the domain and accessible from other clients and or from Kopano, running on the same docker host.

Separately, I installed another nextcloud app on my UCS master and have the same issue.

My network is as follows:

UCS Domain Master (Nextcloud App) ------------- UCS Domain Backup
|…|…|
|…|…\UCSMaster\Domain_User_Share
|…|
|…UCS Member Server (Kopano and Nextcloud App)
|
|
UCS Domain Joined SAMBA server (Ubuntu 18.04)
…|
…\Ubuntu\SAMBA_Share

The SAMBA_share above is accessible from the UCS Master/Backup, Windows and Linux clients, and can be mounted in Kopano File plugin as smb/cifs storage. It cannot be mounted as external storage in Nextcloud App as external storage on the UCS Master or the UCS Member Server.
I also cannot mount shares of users in the Nextcloud UI as external storage from \UCSMaster\Domain_User neither as for all users or logged into nextcloud as domain user and have each user mounting for themselves.

I failed setting up external smb storage in Nextcloud a while back and decided to try a second time. Unfortunately my efforts have failed again. I was able to connect with smbclient from the command line after installing that in the Nextcloud container, but even removing the php-smbclient so Nextcloud would fall back to regular smbclient failed.

There was no logging to be found of the attempts and using the smb test app in Nextcloud also failed with various errors, but there were other reports of it being broken as well, so I think at this point I’m a bit stuck. To go farther I think I would look into enabling some debug logging in Nextcloud somehow. Maybe that would reveal something. At this point I don’t think it’s actually trying to connect to the server at all. It also might be helpful to capture some packets as well, but I think since the issue isn’t all that critical to me I might just wait for the next update and try again then.

There was recently a blog post about something similar: https://www.univention.com/blog-en/2019/11/ucsschool-automatic-integration-of-samba-shares-into-nextcloud/

I made some progress, although the original issue is still not resolved.

I was able to create an entry in the “external storage” section for all users using the occ command line tool instead of the nextcloud admin UI
For anyone facing similar issue, the commands I used are:

Blockquote
univention-app shell nextcloud sudo -u www-data php /var/www/html/occ files_external:backends
univention-app shell nextcloud sudo -u www-data php /var/www/html/occ files_external:list
univention-app shell nextcloud sudo -u www-data php /var/www/html/occ -v files_external:create ‘Home Folder’ ‘smb’ ‘password::logincredentials’
univention-app shell nextcloud sudo -u www-data php /var/www/html/occ files_external:list
univention-app shell nextcloud sudo -u www-data php /var/www/html/occ files_external:config [mount ID from the list command] host “x.x.x.x” share “Samba_Share” domain “UCS_Domain”

The external_storage created above works fine for all users, both using a browser or dedicated clients.
The external storage UI still shows a red exclamation when I try to edit the mounted share in the nextcloud UI, and no change is saved
No meaningful log shows up in nextcloud even with debugging turned on.

Greetings all,

I’m new to Univention and Nextcloud and only having a server up for a few months, but I hope I can help with the problem.
I also have this problem sinse 16.0.6 update and been dealing with it for a few days.

The problem is caused by a bug in 16.0.6 and will be fixed in 16.0.7 (Issue 17846) related to both 17.0.1 and 16.0.6
Workaround:

  • SSH to the Univention server
  • univention-app shell nextcloud // open the internal shell
  • apt-get install nano // install nano text editor (or any other) in the container
  • nano /var/www/html/apps/files_external/lib/Lib/Backend/SMB.php // edit the SMB.php file
  • Line 57, the definition of parameter “timeout”, change it to be:
                    (new DefinitionParameter('timeout', $l->t('Timeout')))
                                    ->setType(DefinitionParameter::VALUE_HIDDEN)
                                    ->setFlag(DefinitionParameter::FLAG_OPTIONAL)
  • save file and try to add/edit External Storage

*edit: fixed a typo

Thanks Romanji
I confirm this bug and that the workaround works

Works for me as well. I was able to define several shares as admin and make them available to a particular group and it works very nicely.

Thanks @Romanji for finding the bug report and workaround and sharing it here.