15

We have started using SharePoint Online included with our Office 365 subscription. Our windows users can install software that automatically syncs the Shared Documents from SharePoint to their Windows computers. How do I enable my Linux (Ubuntu) users to do the same?

I thought WebDav would work, but my attempts always fail, mostly with "HTTP Error: FORBIDDEN". Specifically, I try to add a server via Nautilus file browse and fail:

Server: mycompany.sharepoint.com
Port: 443
Tppe: Secure WebDav (HTTPS)
Folder: /
User name: first.last@mycompany.com
Password: ********

HTTP Error: FORBIDDEN

I have tried changing User Name to:

 mycompany\first.last

I have tried changing folder to:

 /Shared%20Documents

and various other paths based on web searches to no avail.

Should this work? Is there a better solution?

2
  • 1
    Did you ever find a solution? I have a similar problem. Dec 10 '15 at 18:57
  • Unfortunately no (though I haven't checked recently to see if MS changed anything). We also have BOX.COM which does support WebDav and have mostly switched to that...thereby wasting all our SharePoint storage. :(
    – proximous
    Dec 11 '15 at 1:30
7

Connecting to Office365 Sharepoint (or 'OneDrive for Business') by WebDAV requires an existing authentication cookie. You can't log in with a username and password in your WebDAV client. On Windows you can achieve this by adding the Sharepoint site to Internet Explorer's list of Intranet Sites and then logging in with Internet Explorer and ticking 'Keep me logged in', then it will let you map the network drive in Windows Explorer.

The only way I have found to do this on Linux is with Konqueror, because it contains both a web browser and a WebDAV-enabled file browser. You can log in to the Sharepoint site in the Konqueror browser, then the Konqueror file browser can use that cookie to authenticate to WebDAV.

1
  • 1
    Doesn't work for me, I'm getting error 111 (?) when trying to connect to webdavs://xxx.sharepoint.com/yyy/after successfully logging in with the web browser part of Konqueror.
    – nidi
    Mar 9 '18 at 12:38
4

It is indeed possible, but I don't have a smooth solution yet. I'm mounting SharePoint Drives with davfs2. For this to work you have to authenticate with a browser (by simply accessing your SharePoint site). You then have to extract the Cookies named "rtFa" and "FedAuth". They have to be pasted at the end of the file /etc/davfs2/davfs2.conf like so:

add_header Cookie rtFa=<your cookie here>;FedAuth=<your other cookie here>;

Also add the following line:

use_locks 0

To mount the share, I use the URL of the SharePoint-Webinterface-URL of the Share, without the default.aspx at the end. I also entered them into /etc/fstab, so I can easily mount them:

https://myinstitution.sharepoint.com/sites/path/to/my/share/      /path/to/my/mountpoint   davfs   user,rw,noauto  0       0

To get the cookies to the davfs2.conf file, I use Chrome with the cookies.txt Extension, so I can save them to a file cookies.txt with two clicks. Then I wrote a small Ruby-Script which parses this file and adds the line to the davfs2.conf file. I currently have a sympolic link from /etc/davfs2/davfs2.conf to a file on my home directory, but the cleaner way of doing it would be a config file per user (which davfs2 allows afaik). It's far from ideal, but it does the job for now.

#!/usr/bin/ruby

davfsFile = "/path/to/the/file/davfs2.conf"  # Replace this
cookiesFile = "/path/to/the/file/cookies.txt"  # Replace this
cookies = File.read(cookiesFile).split("\n").map{|c| c.split("\t")}
`rm #{cookiesFile}`

cookies.select!{|c| c[5]=="rtFa" || c[5]=="FedAuth"}
cookieline = "add_header Cookie #{cookies[0][5]}=#{cookies[0][6]};#{cookies[1][5]}=#{cookies[1][6]};"

davfsconf = File.read(davfsFile).split("\n")
davfsconf[-1]=cookieline
File.write(davfsFile, davfsconf.join("\n"))

File transfer is fast and usable, directory access is almost unusably slow, something like ls */bla takes 40 s in a directory with 30 entries... I'm investigating the cause and I will post here when I know more...

2
  • I like your idea. I wonder if you solved directory browsing slowdown? Jun 19 at 3:24
  • I did not change anything, however Microsoft did improve their service (for instance we don't suffer downtime every monday after school breaks anymore). It is now rather usable this way. Jun 22 at 6:35
4

This works with the latest version of rclone which is 1.50 at the moment:

https://rclone.org/downloads/

OneDrive for Business is basically sharepoint, it works by the rclone setup as described here:

https://rclone.org/onedrive/ (check the limitations!)

So basically you run in a terminal:

rclone config

Then type n, then type a name and choose option 22 after (this may change, but the onedrive option is meant here). Then hit enter twice (client id and secret are not needed) and then n for no advanced config. Then enter y for autoconfig (your browser should open and it's convenient if you're logged in, it will redirect and show a succes message in the browser.

Go back to the terminal and choose 1 for onedrive. This should show you a drive, choose 0. Next message, choose y to confirm, the next y too.

Now you have the config setup, so you can mount the share as:

rclone --vfs-cache-mode writes mount onedrive: ~/OneDrive

where onedrive is the name of the share you created and ~/OneDrive is the folder in your home directory where you mount it.

If something goes wrong with mounting, you can umount with:

fusermount -uz ~/OneDrive/

You may have noticed that shared folders are not there. It's not supported in rclone at the moment for the business version. To work around that, you can use WebDAV config to mount it. More on that can be found here:

https://rclone.org/webdav/

for vendor choose sharepoint so your config looks something like:

[onedriveShared]
type = webdav
url = https://domain.sharepoint.com/personal/firstname_lastname_domain_com/Documents
vendor = sharepoint
user = firstname.lastname@domain.com
pass = encryptes_pass

The issue here is that you would need to add this for every share. Unfortunately Microsoft didn't deem it necessary to support Linux so my advice is and was to stay away from their products and use the ones that work out of the box.

1
  • RClone mounting Sharepoint with WebDav worked out great for me. To get the URL for a shared root directory (instead of your personal space), you just have open a shared folder and look at the URL to find what listurl is equal to. To make mounting more convienent, this gist shows how to create a systemctl service that supports multiple remotes. Jan 23 at 4:14
0

I confirm that konqueror does work. However as far as i was told spfilezilla connects to onedrive for business and sharepoint with an anonymous token. See here: https://github.com/suoko/spfilezilla If that's true we can make davfs create the anonymous token

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.