Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Whenever anyone connects through Remote Desktop to my Windows 2003 server, I want to check his computer name (hostname) along with his username so I can allow the user to log in.

I don't know scripting, if somebody can help with steps I will be thankful. I want to allow access only to specific users with specific computer names.

share|improve this question
Are you using Active Directory or is this a standalone server? – James O'Gorman Dec 1 '12 at 10:09
Are you asking the other person if he has the right to log in? (And said other person has control over his own computer, including computer name and account name). Security wise that seems doubtful. – Hennes Dec 1 '12 at 11:38
Its a standalone server.I want only as per my list of host and users person allow to login on remote – nitin Dec 1 '12 at 12:05
I am not using Active Directory. – nitin Dec 1 '12 at 12:07

Doing what you suggest with DNS is generally considered insecure (if I can penetrate your firewall and I have control of reverse DNS for my IP I can pretend to be any host I want).

A restricted list of allowed IP addresses is generally considered safer (particularly if enforced by Windows Firewall or your edge firewall -- unauthorized hosts won't even see the port as open).

share|improve this answer
Yes you are right restricted list of allowed ip address is good. But my user will connect through internet so every time their IP address is dynamic, so how do I handle this without router level & firewall. – nitin Dec 4 '12 at 11:10
. . . if the IP is dynamic hostname checking won't work either (the reverse DNS lookup will be different every time even if there's no foul play. If you were suggesting trusting a "hostname" supplied by the client please rethink your entire security model). It sounds like what you really need/want is a VPN. – voretaq7 Dec 4 '12 at 16:08

Here's a script you can use to check the client name of the connecting computer. You'll need to enter a line for every computer name that you DO want to be able to connect, which means that you'll need to know the computer name for every user who will be allowed to log on. Edit to suit your needs:

IF %CLIENTNAME% == ComputerName1 GOTO OK

IF %CLIENTNAME% == ComputerName2 GOTO OK

msg * You are not authorized to login from this location. You will be logged off in 10 seconds.

sleep 10




share|improve this answer
This is exactly I want, but please let me know how to implement in windows server 2003. I tried above script by saving the same in batch file and assign that batch file to the user profile, but it couldn't work. I also check in internet batch file won't work in windos server 2003. Please help me how to execute above script, please let me know steps. – nitin Dec 4 '12 at 11:46
What is an "internet batch file"? Also, where did you put the script when you assigned it to the user profile? – joeqwerty Dec 4 '12 at 15:12
internet means ...I tried to connect remote login through internet to windows 2003 server that time batch file won't work. – nitin Dec 5 '12 at 9:35
script will be saved as batch file and stored in C:\WINDOWS\system32\drivers\etc and then assigned to user profile – nitin Dec 5 '12 at 9:43
Can somebody revert on this. – nitin Dec 25 '12 at 11:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.