Blocking Remote Access for Local Accounts by Group Policy

It is all about security now, and no matter how restrictive we configure our firewall rules and filters, we still got the internal users. They are the ones that click in the wrong places and install the wrong software, and when the wrong stuff get’s into our network, it can do a lot of damage. I’m talking about those viruses and worms that once inside the local network, they can spread trough it by using the local Windows accounts.

We also have those Admins that create local users on servers or workstations and use them to map network drives or run service accounts. Some other issues in using local accounts is the difficulty to detect and audit them due to account logons are not logged centrally on the domain controllers; and let’s not get into the account lock outs and password strengths policies.

In order to block remote logons by local accounts and/or local accounts that are part of the BUILTINAdministrators group, Microsoft added a new feature starting with Windows 8.1 and Windows Server 2012 R2 by introducing two new security identifiers (SIDs).

S-1-5-113: NT AUTHORITYLocal account
S-1-5-114: NT AUTHORITYLocal account and member of Administrators group

Now, whenever a user is logging in or authenticating trough the network using a local account, one, or both of the SIDs mentioned above will be added to the user’s token. It all depends if the account is just a local user or the user is also part of the BUILTINAdministrators group.

For older systems like, Windows 7, Windows 8, Windows Server 2008 R2 and Windows Server 2012 we have to install KB 2871997 in order to make this feature available.

The new SIDs for local accounts and local accounts part of the BUILTINAdministrators group     The new SID for a local user account

Making use of the two SIDs, we can grant or deny access to local users by just using a simple GPO.

 

Creating the GPO

Create a new GPO, right-click it and choose Edit.

Editing the newly created Group Policy

Since this is a computer policy, go to Computer Configuration > Policies > Windows Settings > Security Settings > Local Policies > User Rights Assignments. Here, we have four security policies that we can take advantage of:

  • Deny log on through Remote Desktop Services
  • Deny access to this computer from the network
  • Deny log on as a batch job
  • Deny log on as a service

Double click on any of the security policies listed above then check the Define these Policy settings check-box.

Enabling one of the security policy settings

Click the Add User or Group button then Browse then Locations to select our local server from the list, which is actually our domain controller. By leaving the domain in the list it is not going to work, since a domain does not have a local user account.

Choosing the account search location for the policy setting

Now we have a few choices to make: we can either deny remote access to all the local accounts on the servers or workstations where this GPO will be applied/linked or we can deny remote access to the local user accounts and local accounts that are part of the BUILTINAdministrators group. For the sake of this example I am going to choose both, since I want no local accounts or accounts part of the BUILTINAdministrators group the right to remotely access into the servers and workstations. That should be only possible using domain accounts.

After selecting the domain controller as the search location, click Advanced > Find Now. As you can see in the Search results list, we have the two local groups I mentioned at the begging of the article. Select the one for which you want to deny access to, then click OK a few times to close all the windows.

Selecting the local account to be added to the security policy setting

And OK again to save the changes for the security policy setting. Here I am denying remote access to all local user accounts and local accounts that are part of the BUILTIN\Administrators group.

Adding local user accounts and local users part of the BUILTINAdministrators group to the security policy setting

 

The last thing into making this work is to link the GPO to the Computers OU where we want this security policy to apply. Right-click the OU and choose Link an Existing GPO then, from the window that pops-up, select the GPO we just created.

Linking the new GPO to the computer OU     Selecting the new GPO and link it to the computer OU

Now that we have our GPO configured and linked to the proper OU, let’s see these security policies in action so you can decide if you can implement all of them and which one is a good fit for your environment.

 

Deny log on through Remote Desktop Services

If you configured the Deny log on through Remote Desktop Services policy setting, when a user (even if it’s part of the BUILTIN\Administrators group) tries to connect using a local account to a server or workstation affected by the GPO he or she will be denied access with the bellow message.

To sign in remotely, you need the right to sign in through Remote Desktop Services. By default, members of the Remote Desktop Users group have this right. If the group you’re in doesn’t have this right, or if the right has been removed from the Remote Desktop Users group, you need to be granted this right manually.

Error message in a Remote Desktop session when the Deny log on through Remote Desktop Services security policy is in effect

The best thing is that using a domain user account, the connection succeeds, off course if the user has the proper rights to do so. What I’m trying to say here is that, a domain user account is not affected by the security policy we just created.

Showing that the domain users are not affected by the security policy (Deny log on through Remote Desktop Services)

Deny access to this computer from the network

After we configure this security policy in our GPO, local users are restricted even more. Connection using RDP will be denied with the following error message:

The system administrator has restricted the types of logon (network or interactive) that you may use.For assistance, contact your system administrator or technical support.

Error message went trying to connect remotely using a local user account and policy Deny access to this computer from the network is in effect

If users are trying to map a drive using their local user accounts, the connection will also fail.

Logon failure: the user has not been granted the requested logon type at this computer.

Error message when trying to map a network drive using a local user account from the command line     Error message when trying to map a network drive using a local user account from the GUI

In case the the mapped drive is already there before the GPO was applied, it will still work, until reboot. After that, the mapped drive will not be able to connect using the local user account credentials.

Error message for an already mapped network drive using a local user account after the security policy was put into effect

Deny log on as a batch job

In order to test this, we need to create a batch file and add it to a Task Scheduler job, making sure we create the task to run with a local user account. Also, in the Create Task window, select Run whether user is logged on or not and Run with highest privileges options.

Creating a new Task Scheduler job and making it run with a local user account

Once we click OK and provide the password for the local user account, we get a message saying that the user has no rights to run this type of job, making our security policy implementation a success.

This task requires that the user account specified has Log on as batch job rights. For more information about setting this policy, see the Task Security Context topic in Help.

Providing the local user password for the new Task Scheduler job     Error message of the new Task Scheduler job not being able to run using a local user account because of the security policy being in effect

Deny log on as a service

As the name implies, this security policy setting allows us to deny local users to run as a service account because as you know, a lot of application owners when they install their software, they use the local user to run the service. Once we implement this security policy, no service will be able to run anymore using a local user account, and if they try, they will get an error message like the one bellow.

Windows could not start the <name of the service> service on Local Computer.
Error 1069: The service did not start due to a logon failure.

Configure a Windows service to run under a local user account     Error message of a Windows service not being able to run under a local user account because of the security policy being in effect

I know you know this, but just as a reminder, make sure you send an organizational announcement before you link the GPO with these security policies to the division/computers OU so application owners can prepare for the change. You might also need to create domain service accounts to replace the local user ones.

 

Summary

In my opinion, these are some great security options that every organization should have, but as I’ve mentioned, you need to prepare for the change. In small to medium businesses it’s easy, because you don’t have a large environment to take care of, but for enterprises…this is where it gets tricky. As always, test, communicate, then implement.

Want content like this delivered right to your

email inbox?


2 thoughts on “Blocking Remote Access for Local Accounts by Group Policy

  • 16/02/2021 at 06:17
    Permalink

    Thank you so much I spent hours looking for this! I didn’t how to add local users and you explained it well!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*

css.php