How to connect to WSUS server using WSUS remote API from a web API? - windows-update

I am trying to connect to WSUS server remotely from my web application built in ASP.NET Core 2.0. I am using the Microsoft.UpdateServices.Administration.dll to achieve this. I was able to establish successful connection to the server when I built a C# console application and used the same dll file in assembly reference.
I have referred to these similar posts but I have not found an answer yet.
- Is there RESTful webservice calls avaible in WSUS
- How to make a SOAP call to WSUS Server
[I am sorry for not maintaining indentation and proper formatting in the sample code.]
Below is the sample code from the console app which worked:
using System;
using System.Reflection;
using Microsoft.UpdateServices.Administration;
namespace WsusRemoteConnectivityConsoleApp
{
class Program
{
static void Main(string[] args)
{
IUpdateServer remoteServer =
AdminProxy.GetUpdateServer("WsusServer1",false,8530);
Console.WriteLine(remoteServer.Name);
}
}
}
The expected output as well as the actual output in the console app is "WsusServer1".
But using the same line of code in the web app, I am not able to connect to the WSUS server. I receive exception saying that "The requested security protocol is not supported" in this line
IUpdateServer remoteServer =
AdminProxy.GetUpdateServer("WsusServer1",false,8530);
Any help is appreciated.
Thanks.

if you have setup SSL, you should use:
AdminProxy.GetUpdateServer("WsusServer1",true,8531);

Related

Error opening MDB file on network location with EntityFrameworkCore.jet.oledb 3.1

I have a project opening up MS Access DBs on a network folder. The project is a .net core 3.1 webapi.
EDIT: I'm using EntityFrameworkCore.Jet.OleDb v3.1 with provider in connection string Provider=Microsoft.ACE.OLEDB.12.0.
It very simply updates a list of boards based on new ones
public void SyncBoards(List<Board> boards)
{
_cutriteDbContext.RemoveRange(boards);
_cutriteDbContext.SaveChanges();
_cutriteDbContext.AddRange(boards);
_cutriteDbContext.SaveChanges();
}
I'm getting the error (sanitized)
System.Data.OleDb.OleDbException (0x80004005): The Microsoft Access
database engine cannot open or write to the file
'\{SHAREDFOLDER}{PATH_TO_FILE}\imatv11.mdb'. It is already opened
exclusively by another user, or you need permission to view and write
its data.
This works fine in IIS Express when debugging from VS 2019. I believe this is because the API doesn't have the credentials to access the file. The DBs do not have password protection. Is there a way to provide credentials to the file?
I had to set the identity in the IIS application pool in advanced settings.

Get List of COM+ services running on remote servers?

How I can get list COM+ services running on remote servers? and how to set identity to com+ server remotely.
You can use the COM+ Administration API to accomplish this. It allows you to administer services in the local or remote catalog. See this article for guidance on how to get and set properties. Here's a simple example written in C#. You will add a reference to the COM + 1.0 Admin Type Library
using COMAdmin;
COMAdminCatalogCollection applications;
COMAdminCatalog catalog;
catalog = new COMAdminCatalog();
// To connect to a remote server you would user the following
catalog.Connect(serverName);
applications = (COMAdminCatalogCollection)catalog.GetCollection("Applications");
applications.Populate();
foreach (COMAdminCatalogObject application in applications)
{
//do something with the application
if (application.Name.Equals("MyAppName"))
{
application.Value["Identity"] = #"MACHINE\UserName";
application.Value["Password"] = #"UserPassword";
}
}

camel route for opc-ua milo project

I am working on creating a Camel, Spring boot application that implements the OPC-UA connection. Till now, I was successfully able to run the examples obtained from Eclipse milo github repository.
Now, my task is to create a camel route that will connect to the opc-ua server that is running on a different machine, read data from there and store in a jms queue.
Till now, I am able to run the BrowseNodeExample and ReadNodeExample where I am connecting to a server simulator (Top Server V6). In the example code, when connecting to the server, the endpoint of the server is given as - "opc.tcp://127.0.0.1:49384/SWToolbox.TOPServer.V6"
Now in the camel routing piece of code, in the .configure() part, what shall I write in the .from() part. The piece of code is as -
#Override
public void configure() throws Exception {
from("opc.tcp://127.0.0.1:49384/SWToolbox.TOPServer.V6")
.process(opcConnection)
.split(body().tokenize(";"))
.to(opcBean.getKarafQueue());
}
While searching for the solution I came across one option: milo-server:tcp://127.0.0.1:49384/SWToolbox.TOPServer.V6/nodeId=2&namespaceUri=http://examples.freeopcua.github.io. I tried that but it didn't work. In both the cases I get the below error:
ResolveEndpointFailedException: Failed to resolve endpoint: (endpoint
given) due to: No component found with scheme: milo-server (or
opc.tcp)
You might want to add the camel-opc component to your project.
I've found one on Github
and also milo version on maven central for the OPC-UA connection.
Hope that helps :-)
The ResolveEndpointFailedException is quite clear, Camel cannot find the component. That means that the auto-discovery failed to load the definition in the META-INF directory.
Have you checked that the camel-milo jar is contained in your fat-jar/war?
As a workaround you can add the component manualy via
CamelContext context = new DefaultCamelContext();
context.addComponent("foo", new FooComponent(context));
http://camel.apache.org/how-do-i-add-a-component.html
or in your case
#Override
public void configure() throws Exception {
getContext().addComponent("milo-server", new org.apache.camel.component.milo.server.MiloServerComponent());
from("milo-server:tcp://127.0.0.1:49384/SWToolbox.TOPServer.V6/nodeId=2&namespaceUri=http://examples.freeopcua.github.io")
...
}
Furthermore be aware that milo-server starts an OPC UA server. As I understood your question you want to connect to an OPC UA server. Therefore you need the milo-client component.
camel-milo client at github

Side-loaded Windows 8.1 application generates an exception when calling methods of an RESTful Web API

I have developed a Line-of-Business (LOB) Windows 8.1 application for one of our clients. The app was developed in Visual Studio 2015, on my 64-bit Windows 8.1 Enterprise laptop. The application makes use of a RESTful Web API that is running under IIS Express on the same laptop. The IIS Express has been configured to expose the RESTful Web API to the outside world, such that I can make Web API calls with Fiddler from a different machine. My app works just fine when I test it with the VS2015 Simulator, even when I configure it to use the correct IP address of the Web API (not the localhost).
The client wants to deploy this app in production on some DELL tablets that will run Windows 10. I have one of these tablets and it has 64-bit Windows 10 Enterprise on it. When I side-load my app on the tablet, I launch it and I save in its settings the URL for the Web API service. I relaunch the app, but the first call into the Web API fails to complete. I log an exception informing me that "An error occurred while sending the request". The inner exception message is "Unable to connect to the remote server". The line of code that triggers this exception is this one:
HttpResponseMessage response = await WebApiHttpClient.GetAsync("api/user", HttpCompletionOption.ResponseContentRead).ConfigureAwait(continueOnCapturedContext: false);
where the WebApiHttpClient object is a class static member constructed like this:
if (WebApiHttpClient == null)
{
WebApiHttpClient = new HttpClient(WebApiAuthClientHandler)
{
BaseAddress = new Uri(_serviceUri), // _serviceUri is a string that looks like this "http://10.120.5.201:53045"
Timeout = new TimeSpan(0, 0, 150)
};
WebApiHttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
The WebApiAuthClientHandler is also a class static member that is instantiated like this:
if (WebApiAuthClientHandler == null)
{
WebApiAuthClientHandler = new HttpClientHandler()
{
Credentials = CredentialCache.DefaultNetworkCredentials,
ClientCertificateOptions = ClientCertificateOption.Automatic
};
}
The exception is triggered about 21 seconds after my call so it can't be a timeout since the timeout is set to 150 seconds.
The Web API is running on my laptop, as I mentioned before and using the node.js iisexpress-proxy tool I managed to expose the local URL to the outside world so that I can make Web API calls using Fiddler running on the tablet.
Also, in my app's Package.appxmanifest/Capabilities I have checked the "Private Networks (Client & Server)".
The Event Viewer does not log any additional information.
Can anyone make a suggestion on why the error is triggered?
TIA,
Eddie
The error message I have in my 3rd comment was caused by the fact that I had Fiddler running at the same time. When running without Fiddler, the application receives a different error, but that will be the subject of a different question here, on StackOverflow.

Using SQL Server CE 4.0 with Entity Framework on Windows Azure

I am using SQL Server CE 4.0 with WebApi on Windows Azure Websites. I have been successfully able to deploy SQL Server CE. The weird problem I am facing is that my site is able to log me in using the same DB but I am not able to use any of the controllers to fetch the data.
I am using same connection string for both. The only difference is that for logging in I am using WebSecurity as I have enabled OAuth on the site.
Can someone throw some light on how to debug and fix this issue? The error I am getting for the calls is
Format of the initialization string does not conform to specification
starting at index 0.
However the same string works for authentication, change password, adding OAuth connections etc.
Thanks in advance
I connected to the site using FTP. I was not giving the site name as domain name and it was denying me access earlier. On connecting, I got hold of the Web.config file and I found something interesting. While publishing the site, the web.config was modified to add another connectionstring with the name of context_DatabasePublish.
This string had following details connectionString="ContextName_DatabasePublish.ConnetionString" providerName="System.Data.SqlClient"
Also there was a new section called context added to the entityframework section of the config file with all the details for the context to use but again pointing to same connection string. The provider it is using is sql and not sqlce. I believe that is the reason it was failing.
I uploaded my normal config file and the site started working. I need to explore more on to why and how the new connection string got added. I will post the details in comments.