I'm writing a .NET Core application in C# that will run on a Linux server, but I need to impersonate a Windows user in order to access some remote resources on a Windows Server. I have credentials to authenticate there, but all the implementations I see rely on the "Advanced Windows 32 Base API" (advapi32.dll), which is a shared Windows library not available on Linux.
How do I make this work?
I was able to get a solution by thinking outside the box a bit. I discovered that I could use SharpCifs.Core for CIFS access and the Microsoft PowerShell SDK to gain a remote PowerShell session, and get environment variables. I do wish that Microsoft would write some better cross-platform tooling.
Mono project has a kind of wrapper of several linux commands, one of them is seteuid (the linux command used for impersonation). It could be worth having a look to the NuGet package Mono.Posix.NETStandard. It seems is going to be revamped in the new .Net 5 version. I'm not sure if it can fit your needs...
Related
I have a service written in C# that relies on features in .NET 4.5 that are not yet supported in any version of mono, so I have to use Windows servers. In other cases to deploy a network service I would just SCP a jar/tar/whatever over and then SSH over the deployment process, and that can be made a part of an sh script that can distribute to wherever. But because this is Windows, I don't have those tools and I'm at a bit of a loss as to how to deploy this to 20 (or more) different servers.
So I see that there is a publish process in MSVS 2012, but it seems to make use of Windows file shares or else I'm supposed to send it to a website of some kind(???) but it doesn't look like it has any way of starting it even if I could figure out how to get it there.
Is there some product that does this in Windows or would it be easier for me to just install an SSH server? I have remote desktop access, but would prefer not to have to deploy anything manually on them.
Thank you!
Try using Powershell with WMI. [This question] (https://superuser.com/questions/337810/how-can-i-remotely-install-or-uninstall-a-service-on-windows-server-2008-r2) discussed some approaches to install windows service remotely.
I am using MonoDevelop on Windows and only get the "Local Filesystem" target for web deployment. According to this site: http://monodevelop.com/documentation/creating_asp.net_projects, I need FUSE filesystem to get an "SSH (FUSE)" target type.
Has anyone got this to run on windows? What are the steps I need to take?
The SSH (FUSE) deployment handler uses the sshfs FUSE filesystem to temporarily mount the remove filesytem into a local directory, then uses normal file operations to deploy into that directory.
As far as I know, FUSE does not run on Windows, so this feature cannot work on Windows as-is.
MonoDevelop now includes NSch, a port of the JSch SSH library, use for git support. This library supports SFTP, so it would be possible for an interested party to write a new deployment handler that would use that to do the deployment directly. I'd be happy to provide guidance to anyone interested in doing so.
As mhutch has said, this doesn't work on Windows, because Windows doesn't support Fuse.
However, you could install Dokan + Dokan SSHFS.
Then you'd need to download the monodevelop sourcecode, check for Windows, and add functionaly to mount via the dokan command line.
Then issue a pull-request on Github.
I'm running a c#.NET application as a login/logout script on a XenApp server. The application will run in a user context and I need to be able to retrieve the (client's) citrix receiver version number as well as the client os and machine name.
I'm fairly new to Citrix APIs and they don't seem to have very good documentation--anyone out there know how to accomplish this?
I found the citrix receiver version number in the windows registry on the XenApp server:
HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\Ica\Session\{SESSION_NUMBER}\Connection
where {SESSION_NUMBER} can be found in
HKEY_USERS\{SID_NUMBER}\Software\Citrix\SessionSfr
as the only subkey in that key, and where {SID_NUMBER} is the SID of the user logged into the XenApp session.
If anyone is interested, I spent the weekend writing a .NET wrapper around the Citrix CCM SDK and published the code on GitHub: CcmSdk.Net
The project targets .NET Standard 2.1 at the moment because I needed the new UTF-8 marshaling functionality that is not available in older versions. If .NET Framework support is required, you can simply copy the code to a .NET Framework 4.7+ project and use that build instead.
Citrix Workspace sepersedes Citrix Receiver, and I think the registry method mentioned here doesn't work to find out the client version of Citrix Workspace, but it was still very helpful for me because many of our clients are still using the old Citrix Receiver.
I have a C# Windows Service that needs to access to a Linux computer to get a list of files in a particular directory. What .NET 3.5SP1 method would one use that allows me to do this?
Thanks.
You'll have to create a Samba (SMB) or NFS share on the Linux box that is accessible from the Windows machine that is running your application.
You can then use the standard tools for working with files/directories in .NET to work with the files.
As mentioned in comments, you could also use the standard FTP libraries which would require configuring an FTP server on your Linux machine. SFTP is also an option...but would require a third party library on the .NET side.
Hi you can check at my open source project http://code.google.com/p/nekodrive You can use directly NekoDrive.NFS c# library that wraps my implementation of V2 e V3 NFS Protocol (V4.1 is coming).. It doesn't support the full protocol yet but It works for basic browsing/download/upload functions..
hope this helps
I'm getting confused re the range of options for development & deploying some simple code & UI to both Windows & Mac. Can anyone assist re a good direction here. I do like Ruby, however if it makes sense to move away from this (e.g. java, c#) then so be it. Which development option would people suggest for this?
REQUIREMENTS
1. Support for Windows & Mac
2. The installation should be one-click and package all required dependencies as much as possible.
3. Scheduling capability required - so either via (a) installed as a service/daemon, or (b) ability for installation to schedule periodic call to script (former is preferred)
4. Functionality component requires - ability to access/parse web-sites, and then ability to make HTTP(S) calls out to my site to store parsed data. So heave on HTTP(S) methods. Proxy support required in app, so ability for user to enter host/port/username/password for the proxy server.
DEV OPTIONS ?? - This is where I need help/advice. Some of the many options that come to mind:
1. Develop in Ruby and then find packaging product to create Windows & Mac installation packages - not sure how doable this is yet? Especially if I need the installation to effectively install as a service.
2. Develop in Java for cross-platform? but then needs users to have installed JRE?
3. Develop as Firefox addon? I'm not across this, but even if you can write custom code, then the issue would be firefox would have to be running I guess.
4. Develop windows & Mac versions separately, for example using Visual Studio Express to develop the windows version (assuming it can do HTTP work & create packages for installing services).
What would people suggest here? (would be nice to write once, push a button and then get the Mac & Windows installation packages spat out)
Thanks
I've written cross-platform C++ code and this was the kind of decision we were faced with.
Apologies in advance, but I'm not aware of any cross platform libraries that you can use for this, the systems are sufficiently different that they will require different deployment strategies.
Suggestion 1:
build your application in Mono
build two deployment strategies, separating the deployment issues into the "installers"
on windows deploy with some scripting language or installer application that inserts your app into the task scheduler, or write some simple C# code (see below)
on the Mac use the built-in UNIX cron demon to periodically call your app.
I think this strategy is fairly simple. The platform-specific effort is centered on the deployment. The app uses no resources until it runs, and it uses simple mechanisms to activate it. Logging and error handling can be done using the file system.
Suggestion #2:
write the platform independent code as an assembly
write the platform-specific code for each platform as necessary:
on windows that's a windows service or a scheduled app installed with click-once
I've been away from a mac long enough that I don;t know what the strategy is there
again, additional effort for the deployment
This solution has the overhead of writing more specific code to interface with the particular services that the OS Supports. The benefit is that it should co-exist better with the OS with the additional effort (ie: hook into OS-level resource management, reporting, logging and error management).
Note: C# interface to the Windows task scheduler here Unfortunately it's probably not Mono-compatible.
Mono will support the cross platform Windows and Mac requirement.
Mono allowed me to develop a Windows Forms executable assembly on my Windows environment and then simply execute the exact same executable using Mono on OS X.
Some of the GUI controls behave a little differently, but if you're writing a Service you will probably not be creating a complex GUI.
Checking the mono docs, I see the System.Net.WebClient class is implemented and provides a simple cross platform way to retrieve data over HTTP.
I used Visual Studio 2008 on a Windows machine to develop the application completely as I would any other .NET Windows Forms app. Then the resultant executable can be run directly on the Mac machine by passing it as an argument to the mono runtime.
You probably want to treat installation/deployment as a separate issue from the implementation of the actual application code. You may well need a platform specific installer for each supported platform, but each installer will deploy the same single binary (or set of binaries) on each platform thanks to Mono.