1

I am creating an website for that I need to fetch client's MAC address to identify the client. I have tried with the applets, but it was not fruitful. Please help.

Raktim Ghosh
  • 21
  • 1
  • 2
  • 1
    You should have a look at this: http://stackoverflow.com/questions/1011063/how-many-hardware-details-can-a-java-applet-discover – home Feb 24 '12 at 08:03
  • 2
    *"to identify the client"* Give them a username and log-in password instead. Trying to identify clients using hacks will fail. – Andrew Thompson Feb 24 '12 at 09:52
  • [`java.net.NetworkInterface.getHardwareAddress()`](http://docs.oracle.com/javase/6/docs/api/index.html?java/net/NetworkInterface.html) [tutorial](http://www.kodejava.org/examples/250.html) – Raffaele Feb 24 '12 at 08:00

2 Answers2

1

Using NetworkInterface only is an incomplete answer. It would work if the goal was to get the SERVERS mac-address. The poster clearly states that he wants the CLIENTS mac-address.

The way to accomplish this is either through an applet or through an ActiveX plugin component (which is not guaranteed to work outside IE).

The problem here (that you have already encountered) is that this operation (NetworkInterface) is protected in a regular applet and not allowed by the security manager. To do it, you would have to sign your applet and include a policy-file allowing the applet to access the clients system (ie the NetworkInterface class).

pap
  • 27,064
  • 6
  • 41
  • 46
  • I was trying with macaddress applet, but it was not giving satisfactory output. I did not get the MAC address from it. Can any one tell me how to use this one or any other way to get MAC address? – Raktim Ghosh Feb 27 '12 at 17:35
  • Again, you need to sign your applet and the user has to "trust" it, that is click "Yes" on the "do you trust this applet" dialog that will appear in the browser. This is how you have to do it. Browsers are very restrictive about what can and can't be done to the hosting system without the user explicitly allowing it, and for good reason. http://docs.oracle.com/javase/1.5.0/docs/guide/plugin/developer_guide/rsa_signing.html – pap Feb 28 '12 at 07:49
-1
NetworkInterface ni = NetworkInterface.getByInetAddress(address);
if (ni != null) 
byte[] mac = ni.getHardwareAddress();
Darwly
  • 344
  • 1
  • 6
  • 22