Getting An IP Address in a CSLA remote data portal - networking

I'm writing an app in CSLA and want to log IP addresses, but only if the client is calling a remote data portal (such as the WCF one).
How can I get the client's IP address when executing within a remote data portal? I realize I could probably pass it with the request, but I'd like to avoid this if possible.

CSLA .NET forum thread on this topic

Related

How get the server ip in socket progrmming?

I want to create a chat application like telegram in qt quick.
I had tested the application with IP 127.0.0.1 and I send a message to the server and the server will receive the message.
Now if I deploy the application, there will be many clients and any client is the server for another client(If I understood correctly the socket programming).
So when a user wants to send a message to another user, He should have the IP of another user(that is server), So How can I solve the problem of having IP of another user?
I have a rest API(asp.net core) for signup users. Should I save the last IP of each user when he make a request in my asp.net core web api? and with get list of contact I send the last IP too?
Or there is a another way in socket progrmming?

How to get client IP in 3-tier architecture?

I am currently working on module which has the following architecture:
When a client makes a request it is forwarded to a node server which has a ELB in front of it. The node server gets the data from backend .NET code hosted in another server with a different call.
Is it possible to access the client IP in the backend code written in .NET considering this architecture?
you can get ip in node
In your request object there is a property called connection, which is a net.Socket object. The net.Socket object has a property remoteAddress but it may be possible ip server is behind proxy server so try the below code to get IP
request.headers['x-forwarded-for']
Check the below Stack Link for more answers
How to determine a user's IP address in node

Get visitor IP address from SQL Server

If we have our website deployed on server "A", and a user requests a page in this website from his machine "B". Can we get the IP Address of "B" from database server "C" which is connected to "A".
For example at the time of logging in when I authenticate my user whose credentials are stored in "C", do we have any T-SQL statement to trace the IP address of the user.
I can read the IP address using ASP.Net but I want to know if it can be done from the SQL Server itself.
I googled and which suggests using SYS.DM_EXEC_CONNECTIONS. But that is applicable when we need to get the IP Address of client connected to database.
May be it is impossible to implement what I am asking. The problem is that I am new to IT world.
I will appreciate any help or suggestion.
Thanks in advance
SQL Server doesn't know or differentiate between the different clients that connect to it. In this case, the only client SQL Server knows about is the application/scripts on your webserver (A). The actual end user B is effectively masked from SQL Server by the webserver. As far as SQL Server is concerned, the only known client is the webserver since that's the only source of connections to SQL Server.
You can get the IP from your asp.net application (as you've indicated) and pass that to SQL Server. Do remember that IPs and headers can be spoofed easily. Also, most users connect via some corporate network or ISP so the IP you get is almost certainly from a shared block used by the organization for external connections. The same user on the same computer can connect again minutes later with a completely different IP without doing anything at all.

Connecting to remote Glassfish hosted EJB

The application i'm currently working on start to enter in a pre-release phase.
In this phase, the server-side application components are to be deployed on Amazon VMs while the client-side application remains on the user machine.
This applications connects to server using JNDI and RMI to call remote EJB methods. This works well on localhost and local network.
But, when trying to connect to Amazon host, the application hangs up on context.lookup method. that's to say a JNDI context can be obtained from this remote server, but no lookup can be performed on that context.
What can I do to obtain good diagnostic on the failure ?
Are there logs that can be generated for the RMI handshake/whatever ?
Is there any way to see on server side if query really drive its way through the internet to the server ?
Also notice I've already enabled public IP usage on my Glassfish server (using recommended Oracle procedure).
EDIT According to a fast TCP capture on server, it seems that server receives the client context query with in-lan client address, which it of course isn't aware of :
query is
[3/27/2012 11:05:22 AM:169]
GIOP.......(................NameService....._is_a...................
NEO................ª.......(IDL:omg.org/SendingContext/CodeBase:1.0.
...........n........172.27.63.145.ܺ....¯«Ë........e................
........... ................... ... ...........&...............(IDL:
omg.org/CosNaming/NamingContext:1.0.
reply is
[3/27/2012 11:05:22 AM:171]
GIOP.......2............NEO................0.......(IDL:omg.org/Send
ingContext/CodeBase:1.0............ô........46.137.114.67.'5....¯
«Ë........d........................... ................... .........
.....&...........!...|...............$....f............10.241.42.208
.'6.#........g..............g........default...................g....
...........+IDL:omg.org/CosNaming/NamingContextExt:1.0..............
.......10.241.42.208.'5...M¯«Ë.... ...d... S1AS-ORB............Root
POA....TNameService............................... .................
.. ... ...........&......
(as read using SmartSniff ASCII output).
The IP in query (172.27.63.145) is my IP in my company LAN. From what I understand of communication over itnernet, it should be my company LAN public IP, no ? How can I make Glassfish client udnerstand it should use that IP ?
Diagnostic has been clearly obtained : the client, which connects from a LAN to the server, sends its own internal network private address to server, which server can't forward any answer to. As a consequence, server doesn't answer, hence the hangup.

How can I get the Url of the web site which is using my web service?

I have developed a web service and host it on my server and I would like to know who is using this web service (site Url). I tryed to use "Request.UrlReferrer" but it is not returning any thing! any suggestions/Advices?
You can't get the URL of the caller of a web service as not all callers have canonical URL's. You can however get the IP Addresses assuming that they are not behind a proxy / nat. In which case you'd get the IP of the nat / proxy.
Assuming your using an ASMX web service you can this from:
HttpContext.Current.Request.UserHostAddress
Once you have the IP Address you can try and do a reverse lookup to get the host name. I would recommend storing the IP address then writting an offline process which goes and tries to determine who owns the IP. I'm sure there are some webservices out there to help with this.
You can use Request.Url property to get all the information about the requests to your web service.
The referrer is set by the client, and the client can not set it. That is why you see nothing. If the client's are servers, then the best you can do is to get the IP of the client connection and go to that IP. If a simple setup, with no virtual hosts, then that is the "web site" that is hitting your web service.
As Josh states, the HttpRequest object is the way to go, there are a few properties on there that might help:
UserHostName - Gets the DNS name of the remote client.
UserAgent - Gets the raw user agent string of the client browser.
UserHostAddress - Gets the IP host address of the remote client.
Which might give you a bit more information to play with.

Resources