CA Service Management

Expand all | Collapse all

Get Logged in User's computerName

Jump to Best Answer
  • 1.  Get Logged in User's computerName

    Posted 08-17-2017 11:03 AM

    Hi there,

     

    Has anyone come across an SLCM method that can capture the logged-in user's computer name or has anyone managed to develop a plug-in capable of doing just that?

     

    I came across some javascript that utilizes the ActiveXObject in the code below but it only works if the user is logging on via Internet Explorer and that their Security settings are set to low. 

     

    Code:

    var network = new ActiveXObject('WScript.Network');
    // Show a pop up if it works
    alert(network.computerName);

     

     



  • 2.  Re: Get Logged in User's computerName

    Broadcom Employee
    Posted 08-18-2017 04:29 AM

    Good Morning Muhammad Yusuf Khan.
     
    It seems impossible to retrieve the 'hostname' through a java script. As per your earlier findings.
     
    And also seen on 'the internet':
    var WshNetwork = new ActiveXObject( "WScript.Network" );
    var MachinName = WshNetwork.ComputerName;
     
    This won't work though for java script.
    Default browser security probably won't let you create the activex object.
    And, even if it did, that would get the computer name of the client, not the server.
    But like I said that probably won't work because of default browser security.
    There is no way to get the name of the webserver from the client.
    You can pass it to the client from the server, but other than that your kinda stuck.
     
    Thanks and kind regards, Louis.



  • 3.  Re: Get Logged in User's computerName

    Posted 08-18-2017 09:06 AM

    How about something that executes\envokes a bat files that runs the 'hostname' command and returns the value into some variable?

     

    However, I don't know how to code this. But I thought my thinking would help somewhat...

     

    Regards,

    Brian



  • 4.  Re: Get Logged in User's computerName

    Posted 08-18-2017 10:10 AM

    Hi Brian,

     

    Thanks for your idea.

     

    I just Googled to see if it was possible, which it is but it also leverages off the ActiveXObject that poses the same issue as just coding for the computer name:

     

    How to run a batch script through javascript? - Stack Overflow 

     

    I did however manage to find something else. If I were to code an SLCM plug-in in java, I would need to utilize code something like that of below:

    System.getProperty("user.name"); //platform independent 
    java.net.InetAddress localMachine = java.net.InetAddress.getLocalHost();System.out.println("Hostname of local machine: " + localMachine.getHostName());

    environment - Java current machine name and logged in user? - Stack Overflow 

     

    If there are any Java developers managing the SLCM application, who could do this. Please do and share



  • 5.  Re: Get Logged in User's computerName

    Posted 08-18-2017 10:32 AM

    Plug-in would be executed on the server, not the client machine.



  • 6.  Re: Get Logged in User's computerName

    Posted 08-18-2017 10:34 AM

    And honestly, you are not looking in the right direction if you want my opinion.

     

    It this an enterprise Catalog?

     

    If yes, this information should be provided by a discovery software (SCCM not to mention it) and populated in the CMDB.

     

    You will then fetch the connected user's configuration items from the CMDB,



  • 7.  Re: Get Logged in User's computerName
    Best Answer

    Posted 08-18-2017 09:48 AM

    Hi Louis,

     

    In regards to the below, I'm not actually looking for the computer name of the server, but rather of the client machine

    This won't work though for java script.
    Default browser security probably won't let you create the activex object.
    And, even if it did, that would get the computer name of the client, not the server.

     

    What's the probability once logging an idea for this, for this idea to be implemented?

    I'm looking for functionality like $(_.user.id) but just for information pertaining to the client machine.



  • 8.  Re: Get Logged in User's computerName

    Broadcom Employee
    Posted 08-18-2017 10:07 AM

    Good Afternoon Muhammad Yusuf Khan.
     
    Thanks for your reply and about opening an Idea.
    In general I'll say, yes please do.
    For "Nothing ventured, nothing gained." or "There’s no harm in trying".
     
    It is then up to the developers there after, to see whether this can be implemented.
     
    Thanks for your effort on this and I will definitely vote-up once created.
    Kind regards, Louis.