With identifying if the access is internal or external?

1

I have an application in asp.mvc that has 3 (three) access types, 2 internal and 1 external. Internal access is done by LDAP and the external one by a user table.

No entanto o usuário externo também pode está na rede interna.(aqui é a xarada)

How to identify this access? Because the application consumes internal services that use different IPs for external access. So I need to know what kind of access to put the right IP for the consumption of the service.

Ex:

usuario de acesso interno com DAP quer consultar um pdf (ipInterno:56644/consulta)

Another access, but it is the same IP of the service, because it is in the internal network

Usuario de acesso externo mas na rede interna quer consultar um pdf (ipInterno:56644/consulta)

Other

Usuario de acesso externo fora da rede interna quer consultar um pdf (ipExterno:56344/consulta)
    
asked by anonymous 14.05.2018 / 14:47

1 answer

2

Since the IP of your company is fixed, you can check this way, do the IP check, if the company makes a call, if not, make another call.

Below are two ways to check external IP

First by WebClient consuming third-party service

string meuIpExternoDownload = new WebClient().DownloadString("https://api.ipify.org");

Console.WriteLine($"Meu IP por download: {meuIpExternoDownload}");

The second would be by downloading the library IpPublicKnowledge by nuget - ( Install-Package IpPublicKnowledge )

var ip = IPK.GetMyPublicIp();
var IPinfo = IPK.GetIpInfo(ip);

Console.WriteLine($"Meu IP por IpPublicKnowledge: {IPinfo.IP}");

Tip: If you choose to do this, save the External IP to some configuration file (% with%), so if the fixed IP for some reason changes, you will only need to change there.     

14.05.2018 / 15:59