# get current computer name

**URL:** <https://forum.servoy.com/t/get-current-computer-name/4898>\
**Category:** Classic Servoy\
**Created:** [October 17, 2005, 8:57pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898 "2005-10-17T20:57:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sammyzheng](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@sammyzheng](https://forum.servoy.com/u/sammyzheng)\
**Post date:** [October 17, 2005, 8:57pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898/1 "2005-10-17T20:57:10Z")

</div>

Hi all,

Need your expertise again. Is there a function that can just pull the system ID (for Windows 2000) ?

thanks,  
sammy

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [October 17, 2005, 10:51pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898/2 "2005-10-17T22:51:07Z")

</div>

With my tools plugin [Servoy Components – Plugins, Beans, Web Components, Angular Services & Servoy Developer Consulting](http://www.it2be.com/plugins.htm) you can do this:```  
var user = plugins.it2be\_tools.client().userName;

```auto

AND, it's FREE
```

---

<div class="post-metadata">

**Author:** ![sammyzheng](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@sammyzheng](https://forum.servoy.com/u/sammyzheng)\
**Post date:** [October 18, 2005, 12:03am UTC](https://forum.servoy.com/t/get-current-computer-name/4898/3 "2005-10-18T00:03:32Z")

</div>

> IT2BE:  
> With my tools plugin [Servoy Components – Plugins, Beans, Web Components, Angular Services & Servoy Developer Consulting](http://www.it2be.com/plugins.htm) you can do this:```  
> var user = plugins.it2be\_tools.client().userName;
> 
> ```auto
> 
> AND, it's FREE
> 
> ```

thanks! the plugin works great on servoy developer but on the client side i get an error. Do have I have to push the plugin out to the clients somehow?

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [October 18, 2005, 7:25am UTC](https://forum.servoy.com/t/get-current-computer-name/4898/4 "2005-10-18T07:25:53Z")

</div>

Nope, you shouldn’t. Java/Servoy takes care of that. Let me investigate later today and see what I can come up with…

---

<div class="post-metadata">

**Author:** ![sammyzheng](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@sammyzheng](https://forum.servoy.com/u/sammyzheng)\
**Post date:** [October 18, 2005, 9:46pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898/5 "2005-10-18T21:46:01Z")

</div>

> IT2BE:  
> Nope, you shouldn’t. Java/Servoy takes care of that. Let me investigate later today and see what I can come up with…

This is the line of code I used:

globals.g\_main\_scan1 = plugins.it2be\_tools.client().hostName

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [October 20, 2005, 10:57am UTC](https://forum.servoy.com/t/get-current-computer-name/4898/6 "2005-10-20T10:57:09Z")

</div>

Hai Sammy, I don’t see an issue either using developer or client over here. I suggest you download the latest version of the tools plugin which I uploaded here today [Servoy Components – Plugins, Beans, Web Components, Angular Services & Servoy Developer Consulting](http://www.it2be.com/plugins.htm#tools) and see if the issue still occurs.

If the issue persist can you check if there is any error message in your logging/console?

Please inform me about your progress.

Cheers,

---

<div class="post-metadata">

**Author:** ![Westy](https://avatars.discourse-cdn.com/v4/letter/w/9de053/32.png) [@Westy](https://forum.servoy.com/u/Westy)\
**Post date:** [November 12, 2006, 3:53pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898/7 "2006-11-12T15:53:58Z")

</div>

I have a customer who only wants to allow his employees to access our solution from the computer they use in his office. I have tried using gethostName and userName which do come close to what I need, but they are not foolproof.

Ideally I would like to check on something like the operating system’s registration code, to assure that the user cannot easily bypass the login system. Has anyone figured out a way to assure that client access is only from a specific computer?

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [November 12, 2006, 4:01pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898/8 "2006-11-12T16:01:27Z")

</div>

Why don’t you offer the option to logon to a solution via the ldap plugin. I am working on/testing active directory support…

---

<div class="post-metadata">

**Author:** ![Westy](https://avatars.discourse-cdn.com/v4/letter/w/9de053/32.png) [@Westy](https://forum.servoy.com/u/Westy)\
**Post date:** [November 12, 2006, 5:34pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898/9 "2006-11-12T17:34:13Z")

</div>

I was hoping to give this option to all my customers, because I suspect many of them would not want every employee to have complete access to the solution away from the office. I suspect that many of them do not have a ldap environment, so it seems like that would not be a good solution in this situation.

So far my thoughts on possible approaches are as follows. At time of first login allow user option to check a checkbox that says something like “Only allow access from the computer I am currently using”. If checked, a method would capture a unique piece of information regarding the client computer. Subsequent logins would check that piece of information to make sure it matches the current client computer’s information. If the information is blank they would be allowed in after they entered their username and password (assumption being that the checkbox was never checked), otherwise the unique id would have to match the unique id of their computer in order for them to enter.

Regarding the unique id for the client computer, at first I thought that hostName would work, but then after testing I realized that when used remotely it includes the ip address in addition to the computer name. The ip address could easily change, so that does not seem like a good option. The operating system login userName also seemed like a possibility, but someone could get around that pretty easily. Any other ideas?

---

<div class="post-metadata">

**Author:** ![chartpacs](https://avatars.discourse-cdn.com/v4/letter/c/8edcca/32.png) [@chartpacs](https://forum.servoy.com/u/chartpacs)\
**Post date:** [November 13, 2006, 2:43am UTC](https://forum.servoy.com/t/get-current-computer-name/4898/10 "2006-11-13T02:43:26Z")

</div>

Westy, would it help to grab the computer’s MAC address and associate that with each user? Marcel’s Tools plugin has a function to grab this address.

---

<div class="post-metadata">

**Author:** ![Westy](https://avatars.discourse-cdn.com/v4/letter/w/9de053/32.png) [@Westy](https://forum.servoy.com/u/Westy)\
**Post date:** [November 13, 2006, 4:15am UTC](https://forum.servoy.com/t/get-current-computer-name/4898/11 "2006-11-13T04:15:32Z")

</div>

The sample code includes:

```auto
var addresses = plugins.it2be_tools.client().MACAddress;
if (addresses) {
	for (var i = 0 ; i < addresses.length ; i++) {
		message += "MAC address " + (i + 1) + ":\t\t" + addresses[i] + "\n";
	}
} else {
	message += "MAC address(es):\t\tnot available" + "\n";
}

```

Under what conditions would there be multiple MAC addresses for one client computer and when would there be none?

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [November 13, 2006, 7:01am UTC](https://forum.servoy.com/t/get-current-computer-name/4898/12 "2006-11-13T07:01:24Z")

</div>

None shouldn’t happen. Multiple MAC addresses occur when you have more than one network card. Typical for Laptops with WLAN and LAN.

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [November 13, 2006, 1:27pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898/13 "2006-11-13T13:27:49Z")

</div>

Don’t forget - you can write out your own “Client Preference”. In the past - I’ve just generated a random number - and written it to the preferences on the local client (and stored it in the DB for that user). Then on login - check to see if that number is in the client prefs.

The MAC address is also a good idea - because those don’t change (unless they change the network card).

Neither is bulletproof, but are going to usually be good enough.

---

<div class="post-metadata">

**Author:** ![Westy](https://avatars.discourse-cdn.com/v4/letter/w/9de053/32.png) [@Westy](https://forum.servoy.com/u/Westy)\
**Post date:** [November 13, 2006, 1:46pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898/14 "2006-11-13T13:46:55Z")

</div>

> bcusick:  
> Don’t forget - you can write out your own “Client Preference”…

Hi Bob,

With webclient is it written to the server or the client?

---

<div class="post-metadata">

**Author:** ![Westy](https://avatars.discourse-cdn.com/v4/letter/w/9de053/32.png) [@Westy](https://forum.servoy.com/u/Westy)\
**Post date:** [November 13, 2006, 2:57pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898/15 "2006-11-13T14:57:17Z")

</div>

With webclient it appears that the MAC address is always the same, so it must be coming from the server.

Using application.getIPAddress() DOES return the ip address of the client computer when using webclient, so this may be a good option when clients have a static ip address.

Last night I did some tests using application.getIPAddress() from home with the following results (server is located at a different location at my office). At home I have a dsl line coming into a wireless router. One computer is wired directly to the router. Two other laptops are wireless. The computer connected to the router had one ip address. The two wireless laptops returned a different ip address, but both of the wireless laptops returned the SAME ip address (which surprised me).

In a common office environment where the client computer is on a local area network where there is a static internet ip address at the incoming router, but non-static local ip addresses on the client computers, will application.getIPAddress() return the router’s static ip address or the client computer’s non-static local ip address? I am not in an environment where I can test this.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [November 13, 2006, 3:21pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898/16 "2006-11-13T15:21:15Z")

</div>

When using the rich client getIPaddress will return the machines IP address. So when behind a NAT router this will be in the 192.168.x.x or 10.x.x.x or 172.16.x.x.-172.31.x.x range.  
When using the webclient/headless client/batchprocessor you end up with the server IP.  
Same goes for the MAC address.

---

<div class="post-metadata">

**Author:** ![Westy](https://avatars.discourse-cdn.com/v4/letter/w/9de053/32.png) [@Westy](https://forum.servoy.com/u/Westy)\
**Post date:** [November 13, 2006, 8:40pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898/17 "2006-11-13T20:40:12Z")

</div>

> ROCLASI:  
> When using the webclient… you end up with the server IP.

For us the getIPaddress with webclient is returning the ip address for the client and the getMACaddress is returning the MAC for the server. Still not sure about behind a NAT though.

I had expected the getIPaddress with webclient to only return the Server’s ip address, but somehow it is locating and grabbing the actual client ip address.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [November 13, 2006, 9:17pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898/18 "2006-11-13T21:17:21Z")

</div>

I stand corrected. ![:oops:]( "Embarassed")

I bet it gets the IP from Tomcat like any webserver receives it.  
Ofcourse no MAC address can be grabbed this way.

---

<div class="post-metadata">

**Author:** ![kazar](https://avatars.discourse-cdn.com/v4/letter/k/3be4f8/32.png) [@kazar](https://forum.servoy.com/u/kazar)\
**Post date:** [November 18, 2006, 10:48pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898/19 "2006-11-18T22:48:54Z")

</div>

> Westy:  
> I have a customer who only wants to allow his employees to access our solution from the computer they use in his office.

I’m thinking this must be a very silly suggestion. It just seems so basic. Why not just use the firewall to control this? Would it not be simplest to designate http and RMI ports for Servoy and close those ports in the firewall between the LAN and the outside world?

OTOH, maybe you meant he is trying to prohibit users from accessing the solution from a computer that _is_ within the LAN but that is not at their own desk? I would certainly think the suggestion that was posted to store MAC address in a Users table and test that value would do the trick … and establish an IT protocol that if the NIC is changed in any user’s computer, or if a user’s whole computer is replaced, their record in the Users table must be updated with the new MAC address.

If a test for MAC id is run on outside computers in which an end-user may change their NIC, go wireless, or buy a new computer without knowledge of IT/DBA, it does get aggravating to field those support calls and step users through locating and properly reading off that address. But I have found testing for MAC ID works pretty well for applications used only in-house.

Though I think Bob’s suggestion to edit Client Pref has the biggest cool factor.

kazar

---

<div class="post-metadata">

**Author:** ![Westy](https://avatars.discourse-cdn.com/v4/letter/w/9de053/32.png) [@Westy](https://forum.servoy.com/u/Westy)\
**Post date:** [November 19, 2006, 8:32pm UTC](https://forum.servoy.com/t/get-current-computer-name/4898/20 "2006-11-19T20:32:43Z")

</div>

In our situation the solution uses webclient, so the client is always going to be on the server. Testing for MAC will return server info. However, testing for ip address does appear to return the ip address of the computer that the user is using to access the solution. So it appears that testing for ip address may be a good approach with webclient. I am still in the process of testing this in various environments.

[Next page](https://forum.servoy.com/t/get-current-computer-name/4898.md?page=2)
