Cross-platform authentiated windows share - .net-core

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?

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

Does all web hosting providers support ASP.NET websites?

I'm totally new to deploying websites and I read some articles and facebook posts that some hosting providers does not support ASP.NET, our website was built using ASP.NET webforms, any input is appreciated, Thank you!
You can't run your windows software on a Mac computer? and a Mac computer can't run its software on windows?
A web server is a computer. In fact, say you using LAMP (Linux, Apache, MySQL, PHP). That's called a developer stack. If you decide to say use some other web development language? Well, you can't then just expect your software to work on that computer.
So, if you say write your software to work on IBM's WebSphere computer, then if that web hosting computer does not have those languages, coding systems and support? Then you can't run your software on that computer.
If you write your software to work with Apache web server? Then the web hosting computer will have to be setup and support running Apache.
When you develop a asp.net site? Then the web server used is IIS (internet information services). So how this works is really not different then a desktop computer.
You can even find asp.net hosting (and yes, it is in fact a windows hosting system), but some support MySQL as the database server, and don't offer say SQL server services.
So, yes you not only have to find a web hosting company that supports .net, but ALSO one that supports the systems and the tools and the software you created. You can not more just toss Mac software on your windows computer, then you can say toss some asp.net software on some computer that not even windows based.
A computer is a computer is a computer. And a web hosting computer is NOT any different in this regards.
So, you have two choices:
you can look at what your current web hosting provider supports, and then go download or whatever the developer tools for that particular web hosting plan. In other words, you look at your current web hosting, and choose the programming lanauges, database system and tools they support. If you don't use those tools then your software will not work on that web site.
Or, you can adopt a set of tools, build that software and then go find a web hosting plan that supports your particular development tools.
Keep in mind that a LOT of lower cost asp.net hosting plans do NOT support asp.net web applications. They support asp.net web sites, but not asp.net web applications. But in general, most hosting plans outline what tools and systems they support.
So when you go to a hosting provider? They have Linux plans, and then they also will have aps.net (windows) hosting plans. They are often $2-$3 more per month - but in general the cost difference is not much different at all.
So, web servers no more run software then what you have running on your desktop computer.

ASP.NET (macOS) - Send Windows Credentials in SQL Connection

I'm a contractor working remotely on a legacy ASP.NET application. I'm struggling to stand up a local instance of the project due to the error SQL Exception - SQL Server does not exist or access denied. I suspect this is because of the use of Windows Authentication for the SQL databases backing the project.
Before I launch into a lot more detail I'll ask my question: what are my options to pass Windows credentials to an SQL server in an ASP.NET project built on OSX?
I believe I've proven this is possible with some steps I'll detail below, but the actual implementation in an ASP.NET project is escaping me due to my inexperience with everything .NET, and the many-fold differences between my setup and the typical dev.
Standard Dev Setup
The devs I'm working alongside are using Windows machines housed in their corporate domain, running Visual Studio 2012. Because they're already logged into their machines with the appropriate credentials, the use of Integrated Security=SSPI in the SQL connection string "just works".
My Setup
I'm running a Mac Mini outside of their corporate domain, and using Visual Studio in conjunction with Mono to support the .NET Framework-based project. Passing the SSPI option won't work out of the box because I'm not connected to any Active Directory. That said, I do have valid credentials to log into their network.
What's worked so far
I've proven that a connection to their network resources is possible:
When logged into a virtual Windows machine, I can connect to a shared drive on that network with the credentials I was provided.
I then set up that same shared drive on my Mac Mini with those same credentials.
Using SQL Pro for MSSQL, I was able to connect to the desired database using my credentials.
As I understand it, what I'm looking for can be accomplished on Windows with Credential Manager, so bottom line I think I'm looking for the equivalent solution on OSX that plays nicely with ASP.NET project as compiled by Visual Studio.

Making an installer for a web app with database and a windows service

I want to make an installer for a client which installs
a web app on IIS
a mssql db
a window service
I am totally naive to thinking of the solution for this automated deployment through an installer (msi or exe). The installer may hint the user for prerequisites for example MSSQL server and upgrading/installing IIS before the web app installation can proceed. Is it possible?
Yes, it is possible. You need to first select in an authoring tool for Windows Installer. Some examples are Windows Installer XML (WiX) and InstallShield (various editions from free to pricey). You'll have some kind of EXE bootstarpper/chainer where you can handle prerequisite installation such as windows features and database engines. Or you can choose to simply ship an MSI that detects and blocks if these are missing and put the effort on the user to manage their baseline environment. The actual MSI will then likely have features for web, service and sql. The web feature will install a bunch of files and configure the IIS meta. The windows service will install some files and create a windows service. The SQL feature will ask for connection string information, execute some sql scripts and possibly configure the web and service layers' connection strings.
Some of this can be deferred until after the installation and placed into a custom configuration utility to simplify the installer work.
There are various design decisions that can be made so it can't be answered in more detail in a simple question format.

does self hosted signalr require windows server 2012 in order to use websockets?

A self hosted application doesn't seem to run off of IIS, so does it require a specific operating system in order to enable web sockets on the server side?
Browsers will support it because they have implemented the protocol internally, most browsers won't use the operating system transport libraries so they will be able to make use of WebSockets even if the OS does not directly support it.
HTTP.SYS prior to Windows 8/2012 has no built in support for WebSockets, so although .NET 4.5 contains WebSocket classes, they won't work unless you are running .NET 4.5+ on Windows 8/2012 and that will affect self-hosting solutions running in Windows < 8.
The implementation resides in the operating system code that .NET and IIS8 just leverages. The .NET classes simply wrap calls through to HTTP.SYS so it will throw an exception on an operating system that does not have underlying support for it.
When self-hosting you can however use your own internal Web Socket server such as Fleck and tell SignalR that you in fact do support Web Sockets regardless of your OS.
Start a Fleck server in your self-hosted application (examples on their site) and as an example you can do this for a PersistentConnection self-host:
public override Task ProcessRequest(HostContext context)
{
// Override what SignalR will be telling you internally and point to your own Web Socket Server.
context.Items[HostConstants.SupportsWebSockets] = true;
context.Items[HostConstants.WebSocketServerUrl] = "ws://localhost:3000";
return base.ProcessRequest(context);
}
Disclaimer: This is an undocumented feature, the developers of SignalR have told me that this may not be possible in future versions of the library. Keep in mind that you will also need to cater for keep-alives and serializing your data to JSON so it plays nice with the SignalR clients. It still works in version 1.1.3.
I've know for sure that websockets are not supported now by doing a quick test. I created a self hosted hub and then a quick jquery client. On my windows 8 machine the querystring showed websockets, on the server 2008 r2 it showed long polling...
Yes it requires windows server 2012 check the quote below from SignalR Supported Platforms
The SignalR server component can be hosted in the following server or
client operating systems. Note that for SignalR to use WebSockets,
Windows Server 2012 or Windows 8 is required (WebSocket can be used on Windows Azure Web Sites, as long as the site's .NET framework version is set to 4.5, and Web Sockets is enabled in the site's Configuration page).
Also a good read on why can be found here

ASP .NET 2.0 on Apache (Windows XP)?

I am building an ASP .NET 2.0 web app for an intranet environment. The site may have to be hosted on an XP machine in the LAN. IIS would restrict the number of connections to 40.
My requirements are different - the number of clients in the LAN could be much higher - say upto 1000 or maybe even more.
The site is built using ASP .NET 2.0 and extensively uses ASP .NET Ajax 1.0.
What options do I have? Is hosting it on an Apache server possible? (with ASP .NET Ajax)
If not, any alternatives?
Thanks.
EDIT: I've heard about ultidev cassini. Is that a good option (ASP .NET 2.0+ ASP .NET AJAX 1.0)?
I wouldn't consider cassini, in my experience it's too slow for production. Other alternatives:
Apache + mod_mono (but your app would be running under Mono instead of "standard" .net, which may or may not bring its own problems)
Apache + mod_aspdotnet (but this mod seems rather old and unmaintained)
Buy a Windows Web Server license (2003 or 2008), but I guess that's not an option is it? :-)
With those sorts of numbers, you should be able to justify a license really - will they all be accessing the server concurrently - if not you might be able to get away with the XP hosting.
How are you managing 1000 users without a single server instance in there - surely one of them has a bit of capacity to run IIS?
You can get a Windows Web Server 2008 License from around $469
This doesn't require CALs for access, but (IANAL) you might not be able use Windows Auth with that and it should be a public facing website...

Resources