Get FQDN (fully qualified domain name) from client machine - c#

I'm working on a project that will include Windows tablets as a Terminals and they will be under VPN. Setting up the tablets will not be our job, we only need to provide some endpoints for them and we'll need to authenticate the API calls from them with their FQDN. The project is .net5 Web API.
Previously the requirement was that we will use the IP address of the terminals for authenticating them and I can easily use this code for getting that:
var remoteIpAddress = HttpContext.Connection.RemoteIpAddress?.ToString();
However the request was changed and we will need to use FQDN for authentication.
The problem is that I can not get FQDN from HTTP Context as I can take the IP address.
Is there any way to get this parameter from the device?

Related

How to access WCF with SSL Protocal using IP Address?

Hope my question is clear!
I have created a WCF Service and have implemented all necessary work for SSL implementation.
From IIS to Web.config
I am able to accessing Service with following URL successfully on browser from my own PC.
https://mycomputername/wcfService.svc
but How can I access it using my IP-Address e.g:
https://192.x.x.x/wcfService.svc
Actually I have to access the web service from another PC with in my network.
The SSL certificate will be associated with a domain name, not with an IP address.
So you will have to customize how to accept the SSL certificate. If you have a .NET client, you can use ServicePointManager.ServerCertificateValidationCallback and return true to accept any certificate.
Related: How to ignore the certificate check when ssl

Getting the IP address of the client on an ASMX Web service

I am trying to Authenticate a web service by validating the IP address of the caller. The web service is meant to be internal to the network.
and in trying to do so the HttpContext.Current.Request.UserHostAddress has a weird value like "::1"
See debug point screenshot below.
Questions :
Why does this not work and give the proper ip of the client?
Is there a better way to authenticate the Web Service for an internal client?
Thanks in advance.
Why does this not work and give the proper ip of the client?
It is indeed working and you are seeing "::1" because it's a reserved loopback address for ipv6 AKA localhost or 127.0.0.1 in ipv4
IPv6
The loopback address, 0000:0000:0000:0000:0000:0000:0000:0001, may be
abbreviated to ::1 by using both rules.
Is there a better way to authenticate the Web Service for an internal client?
You have to know the difference between Authentication & Authorization, i suggest you create a new question with more details on the authentication methods that you are using in your web service

How do I route incoming requests to specific apps based on IP?

How would I route requests to different IIS apps based on the user's IP address?
I'm looking to pilot a test version of a production site to a specific IP address. I would rather not have to force these users to access a separate URL. So, I'm asking if there is a way within IIS to force the server to process the request via a secondary app based on the requesting user's IP address?
This is possible on IIS 7+ using application request routing:
http://www.iis.net/downloads/microsoft/application-request-routing

.NET Web Service Security

I have a C# web service on our website and I only want to be able to call it locally where its hosted - restricting access from the outside world. Whats the easiest way to do this without a login form? We cannot restrict the web service directory per ip (because I don't believe its static)
Alternatively, you could also host them on a separate website, which you only bind to localhost (127.0.0.1)
PS: You should really get a static IP for your webserver. Or at least reserve an IP address for the server's mac address in your DHCP server configuration.
You can setup windows authentication on the web services and require the authentication be a local account to that machine. You'll have to modify your code calling it by providing network credentials, but that will prevent people from the outside calling it.
This article should explain how to do it.

How can I create a subdomain in asp.net?

How can I create a subdomain in an asp.net C# application? I am working with an asp.net portal. In that portal I need to be able to create the subdomain at runtime. The ftp for that subdomain also needs to be the same as the main domain ftp.
There are a handful of working parts here. It sounds like the requirement is that this all happen at runtime. I am sure a lot of web hosting providers are deep into these sets of problems and likely have custom solutions.
DNS: you'll need to have an API open at the DNS host. If it's a LAN environment, you'll have to check your DNS provider on whether they have APIs exposed. (i.e. Windows Server or whatever your network operating system is). If this is a public facing site that needs to be accessed via the internet, you'll have to get those APIs from the DNS registrar. Are the subdomains to be permanent?
IIS: You'll have to setup wildcard mapping, (i.e. *.mydomain.net). When an HTTP request comes in, logic within the ASP.NET page can determine the subdomain that you're working with. You could extract the subdomain, perform a lookup on that subdomain to get more information (CustomerID, names, valid visitor IP address ranges, whathaveyou).
FTP: if you require secure logins for that subdomain, you'd have to have created AD or local machine accounts for those users. If you want anonymous access, that's OK too. There are some scripting options that you'll have to look at to have that FTP folder setup as well. That is assuming you're using IIS's FTP module. If you are using a 3rd party FTP application, that complicates the scenario even further. Their APIs would have to be investigated.
Active Directory: If you are requiring secure access for each subdomain, you'll have to create AD users and/or groups. You can certainly script the creation of users into groups. Perhaps the users will be local to your web server. That doesn't scale well if you want to add another web server, but it's certainly do-able.
subdomain's are controlled by your dns settings. Beyond that I can't understand your question.
I think the best way is to have a wildcard DNS entry - i.e. *.domain.com that points to the domain. And then use a rewriting tool, like helicontech.com, to rewrite the 1st part of the subdomain to tell your app what you're looking at.
This would use regular expressions to pass the subdomain to your app:
RewriteCond Host: (mysub).domain.com
RewriteRule (.*) /$2?subdomain=$1 [I,L,U]
There are two halves to this:
A) Changing your DNS Settings:
This varies based on your host and whatnot. Contact them and ask if you can't figure it out.
B) Changing your host settings:
This varies based on your server. I assume you're using some version of IIS.
In IIS6, you can right click a web site, select the properties page, go to the web site tab, select advanced in web site identification, and start adding bindings (Generally you'll use default or the ip address for IP Address, 80 for TCP Port (unless SSL), and the site for the host header file (e.g. www.example.com or subdomain.example.com).
In IIS7, you right click on a website and select edit bindings, then click "Add". IIS7's add screen is pretty self explanatory.
I think he wants to created a subdomain from code, using an API probably that needs to be provided by his webhost folks. Like his own DNS manager app. If I interpreted your question wrong, then I guess you probably oughta reiterate a bit more.

Categories

Resources