Skip to Content
avatar image
Former Member

Get local machine data

Hello,

I have a Webynpro Java app. integrated into SAP Portal Netweaver 7.3.

I need to know, through the same app., details (IP address, MAC address, PC name, ...) of the machine who is launching the app. I know how to get the IP address:

String ipAddress = WDProtocolAdapter.getProtocolAdapter().getRequestObject().getClientHostAddress();

But how can I get the other parameters?

This is because I need to restrict the app. running only to some specific machines, not all of them... any other ideas?

Thanks!

Miguel.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Jun 11, 2012 at 04:33 AM

    Hi,

    There are a few restrictions there. On the request, just some information will be available to the server, basically to protect the Client.

    But there are ways to retrieve clientInformation - but the client needs to 'agree' with that - this should be true to every single technology that exposes this kind of information.

    I will use a 'BIG' guess here:

    - Both your users and in fact all your users * USE * Internet Explorer to browse your WDP Application.

    Let's say the statement above is true, you could for instance use some simple javascript (ActiveX actually doing the job) to retrieve this information out of the Client using WMI:

    [code]

    var locator = new ActiveXObject ("WbemScripting.SWbemLocator");

    var service = locator.ConnectServer(".");

    var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");

    [/code]

    This variable properties will contain a list of all the NetworkAdapters of that computer. You may want to get more information around here:

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa394217(v=vs.85).aspx

    There are some ways of using JS with WDJ. For instance, you can use NW Event API (EPCF) (http://help.sap.com/saphelp_nw73/helpdata/en/4a/337cde50161c62e10000000a42189c/content.htm) to communicate back and forth with WDJ. You can find some other articles here in the SDN about this topic - I'm just not used to the new SDN otherwise I would post a hyperlink here for you.

    Of course, the solution above is dependent on browser settings: At least a popup (or the yellow bar on top) should display warning the user the webpage wants to execute an ActiveX; and I believe also this should be marked as Unsafe - no matter what, you let your internal user know what is going on and why there is such thing and you block the content if you don't get the MACAddress you want.

    Hope it helps,

    D.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 08, 2012 at 05:32 AM

    Hi Miguel,

    You can get the MAC Address using: java.ne.NetworkInterface --- getHardwareAddress()

    <Java 6 onwards only>

    For PC Name use: InetAddress.getLocalHost().getHostName()

    Regards,

    Manoj

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Manoj,

      I typed your methods, but it gives me the server's MAC address & HostName, not the local machine's.

      The requirement is the following...

      We have an app. (webdynpro java app.) running in our SAP Portal 7.3; then there is an user who should access this app. in machine A but NOT in machine B (he can access all the rest of SAP Portal apps.).

      We need to restrict this access directly in the webdynpro java app... we though about to get the machine MAC address or name, and restrict the access. But maybe there's another solution, like to read a file located in the local machine B, or a machine's B system variable, or... any idea???

      Thanks!

      Miguel Angel.