How to mount SMB users with hidden shares

On our Window Domain Controller user shares are created with $ to make them hidden shares eg \dc\user$ - is there any way to specify that in the external storage app ? I tried the following for the Share field and none worked:

$user$ $user$ $user\$ $user’$’ $user"$" $user%24

In general is there a way to pass non-standard characters to input fields.

I verified that the system running Nextcloud (13.0.5.2) stable, on CentOS 7, php 7.1 can access the DC with the smbclient command as:

smbclient -U test \dc\test$

Thanks.

I’m in the almost the same boat.

All of our students are on \server\share$\grad_year\username

I need to be able to pass in variables from LDAP to the external storage

Same here. As bluesky.ca mentioned before, I am not able to mount hidden Windows smb shares with the $user variable. I also tried to escape the $ character in different ways. Also no success. The app ‘SMB connection test’ can mount the hidden share fine, but the external storage connector can’t. Neither with the $user variable nor the with the entered username and the $ appended. I really need this feature for a usecase in multiple schools to mount the home directories of the students.

Used nextcloud version: 15.0.2

Edit: I’ve updated to nextcloud version 15.0.5 with no results. We really need this feature ASAP

Finally
I’ve found the problem.
It seems that nextcloud tries to establish the smb connection directly with php.
With an modification in /var/www/nextcloud/apps/files_external/lib/config.php you can append the “$” for the hidden user shares to the user variable.
Just add $user .= “$”; under line 203, so that it’s set before the if-statement.
But that’s just a workaround and works only with Windows Server 2008R2 and below

Solution
The final solution is to install the package php-libsmbclient, so nextcloud uses the smbclient on your nextcloud server to connect to the Windows Server with the hidden shares.
After that you can add the external storage in nextcloud.

Folder name: Choose free, it’s just the name inside of nextcloud
External Storage: SMB / CIFS
Authentication: Log-in credentials, save in database (diffrence to session is, that you can share your storage files and folders with other users)
Host: Your DC (I used the IP address)
Share: $user$

Additionaly I defined
client min protocol = SMB2
client max protocol = SMB3
in the global section of
/etc/samba/smb.conf

Hope this helps you out

1 Like

mark: afaik linuxsystems will see every windows-“hidden” user-share, though.
it’s just windows interpreting a closing “$” as “don’t show/hidden”

I know. When you use smbclient in bash everything works fine, just nextcloud needs php-libsmbclient as wrapper.

Hi,
In my case I don’t have this file: /var/www/nextcloud/public_html/apps/files_external/config.php
I find /var/www/nextcloud/public_html/apps/files_external/templates/settings.php


Where add this $user .= “$”;
How can I fix it?

Sorry, my bad.
config.php is stored in /var/www/nextcloud/apps/files_external/lib/

In the newest version of files_external you have to replace line 295 in /var/www/nextcloud/apps/files_external/lib/config.php

Replace this line:
if (rtrim($option, '$') !== false) {

With this:
if (strpos(rtrim($option, '$'), '$') !== false) {

Credits to kesselb on github (https://github.com/nextcloud/server/issues/15567)

I hope that the developers include a checkbox in the future to choose if the share is hidden or not.
It’s always a good amount of luck if the patch works in the upcoming version, otherwise you have to search for a new solution. Not really that great if you deploy pre-configured environments to hundrets of customers.

Thx, works great.

@MS-PL:
Does it still work for you with the newest release?
I’m on 20.0.4 but hidden shares don’t seem to work anymore. At least for me.