Cross-platform authentiated windows share

Viewed 2565

I am trying to figure out how to access an authenticated windows file share from .net core (supplying domain / username / password) from Linux.

I have a .NET framework based sample project that does this in Windows operating system just fine. https://github.com/nddipiazza/SambaFetcher (in particular https://github.com/nddipiazza/SambaFetcher/blob/master/SmbFetcher/UNCAccess.cs )

But it relies on the NetApi32.dll directly so it will not work from Linux.

Is there some way from .NET core to do this authentication?

1 Answers

You can use this library: SMBLibrary which supports SMB2. I'll quote the description here:

SMBLibrary is an open-source C# SMB 1.0/CIFS, SMB 2.0 and SMB 2.1 server implementation.

SMBLibrary gives .NET developers an easy way to share a directory / file system / virtual file system, with any operating system that supports the SMB protocol.

SMBLibrary is modular, you can take advantage of Integrated Windows Authentication and the Windows storage subsystem on a Windows host or use independent implementations that allow for cross-platform compatibility.

SMBLibrary shares can be accessed from any Windows version since Windows NT 4.0.

It's mostly for coding a server, but it also has a client part here: https://github.com/TalAloni/SMBLibrary/tree/master/SMBLibrary/Client

Related