Get Client's Mac address at server side in WCF service C#\ [duplicate]
Asked Answered
C

1

0

I have WCF service hosted as windows service, I am trying to get clients (WPF client) Mac address at server end (WCF side). I have tried using following line of code but it gives me IP address of client that too in ::1 format. RemoteEndpointMessageProperty prop = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;

prop.Address is ::1

How can I get client Mac address so that I can differentiate among the client hitting my service. There could be scenarios where clients under same network may give me same IP address and that is reason I am looking for Mac address to identity client's call.

Clop answered 10/2, 2021 at 19:42 Comment(0)
V
0

Quick question: are you able to work with/modify the WPF code?

My thought is you could have the WPF client generate a unique code upon initialization, and include that along with each of its requests to the server.

Veronikaveronike answered 10/2, 2021 at 19:49 Comment(5)
I can but that would not go with the application architecture that I am working currently and may require more changes. However, if at all changes at WPF end is required, that means adding headers when I am establishing a connection with my server? Although, this is not what I am not really looking for, but to keep it as last resort, could you help in providing some sample code please. Thanks for the prompt check!Clop
Hmm. MAC addresses are not part of IPv4/IPv6 packets, so I don't think you could get that from the request alone.Veronikaveronike
Okay, so again if at all I can not get this through, any suggestions that you can provide attaching client's identity when client is making request?Clop
Here's an old post asking a similar question; you may be able to use the ServiceSecurityContext.Current.PrimaryIdentity property of the requester as their identity, but I have not tested this. link: linkVeronikaveronike
No luck. Just tried and as written in the post's comment, its null for me as well. Thanks for checking this out. I am also finding old posts and nowhere I can get a solution which meets my requirement!!!Clop

© 2022 - 2024 — McMap. All rights reserved.