Best Practice: How to use Group Policy Preferences to Secure Local Administrator Groups

Best Practice: How to use Group Policy Preferences to Secure Local Administrator Groups

One problem I see all the time is IT administrator never being able to control who is a local administrator of any particular computer. The problem is that when you give someone local admin access to a computer (because they legitimately need it) you cant stop them from giving admin access to someone else on the same computer. When this does happen it is also its almost impossible to discover as you have to run a query every computer to see who is in the local admin group and then figure out which account should be a member. Once solution to this is of course following Microsoft best practice and not give your users local admin access to their PC or Server and in an utopian environment this would be possible but we all live in the real world where managers have admin access to their PC’s and developers are allowed to install any software they want. So how do you give a users full admin access to a computer but stop them from adding more people to the local admin group on a computer? Use Group Policy Preference of course.

But first a bit of History… Since Group Polices were first introduced with Windows 2000 there was an setting called “Restricted Groups” which allows you to control the membership of a group. This option had two modes one called “Members” option which I also call the “Iron Fist” mode and the other “Members Of” option which is much gentler. The “Members” option removes any groups or users that are not explicitly specified and the “Members Of” option just adds a specific group which out removing any existing groups. The “Members” option was really good at cleaning up those rogue members of the local admin group but its was also really hard to setup as you had to have a new group policy every time you wanted a different list of members in local group on a computer. The “Members Of” option was a lot easier to maintain as you could layer multiple group policies on top of each other but this normally resulted in just adding another layer of group to the pile of groups that were already in the local administrators group. The other problem was the “Members” option would override the “Members Of” option so there was really no way of mixing the two modes.

BUT…  Group Policy Preferences can use Variables which enabled you to be very extremely granular in controlling you local admin group while still having “Iron Fist” control. Muuhhaaaahahahahah!!!



 

How do I setup a restricted local administrator group?

The following steps will need to be applied to a GPO that is applied to the computer objects you want to control the local administrator groups. Note: You must make sure you don’t have any other Group Policy “Restricted Groups” settings applied to your computers as they will always override the group policy preferences settings.

Step 1. Open the Group Policy Management Consol and edit the group policy that is applied to the scope of computers that you want to control.

Step 2. Go to the Computer Configuration > Preferences > Control Panel Settings > Local User and Groups option (see Image 1.).

image

Image 1. Local User and Group

Step 3. Now click on Actions > New > Local Group

Step 4. Now you will be need to select “Administrators (built-in)” from the group name as this always selects the built-in administrators group even if you have renamed it to obfuscate the name of the admin account.

Step 5. Tick both “Delete all member users” and “Delete all member groups”. These two options will automatically remove any users or groups that are not explicitly being added to the group. You only need to do this on item number 1 in the list of settings as that setting will be processed last.

Step 6. Now you will need to make sure you have added back in the Domain Admin’s and Local Administrator groups so that you don’t totally lock yourself out of the computer. To do this click the “Add…” button to bring up the “Local Group Member” dialogue box (see Image 2)

image

Image 2. Local Group Member

Step 7. Now type “BuiltIn\Administrator” in the Name field and click OK (see Image 3.)

Note: The image below is wrong… it should be “BUILTIN\Administrator”

image

Image 3. Local Administrators group added to the local administrators group

Step 8. You should also add “DOMAINNAME\Domain Admins” as it is a good practice to have the DA account as a member of the local admin group on all computers in the domain.  To do this we are going to use the DomainName variables. Click “Add…” again and now click in the “Name:” text field and then press F3. This will now bring up the “Select Variable” dialogue box (See Image 4.). Click on the “DomainName” field and press “Select” and then “OK”. (alternatively you could type %DomainName% in the name field and just press OK.)

Note: The image below is also wrong… The bottom image should be “BUILTIN\Administrator”

image

Image 4. Selecting the DomainName Variable

You should now see the following which will restrict the local administrator group to only have the Domain Admins and the local administrator.

Note: The image below is wrong. It should be “BUILTIN\Administrator”

image

Image 5. Basic local administration group setting

So what you as? I can do this already with the “Restricted Groups” Group Policy setting. Well only having the local Administrator and Domain Admin’s in the local admin group is not not much use unless you are willing to give everyone the local admin password or give them all Domain Admin’s privileges (Like that ever happens) when ever they needed admin access. Well again this is where Group Policy Preferences can help.

 

How to add individuals to a single computer?

Now we are going to go thorough how to add a uniquely named domain group to the local administrators group without having to set up multiple group policies objects. This scenario is very helpful if you want to grant a single user or group local administrators access on computer but still ensure that no other users or groups can be added without explicitly being approved. In the steps below the computer name is DESKTOP01 and the domain name is CONTOSO, we want to add the group “CONTOSO\DESKTOP01 Administrators” to the local administrator group but we also want the same to happen on DESKTOP02, DESKTOP03 and so on, each with their own uniquely named group based on the computer name.

Update: Having a unique group for each computer allows you to easily grant permission to for a single users to a single computer as there is a one to one mapping of domain groups to local administrator groups.

Step 9. Now go back and repeat steps 3 to 6 until you get to the Local Group Member dialogue box again (see Image 6.).

Note: This creates a second local administrator group entry in the list to work around an issue.

image

Image 6. Add Local Group Member

Step 10. Type “%DomainName%\%ComputerName% Administrators” in the Name text field and click “OK” (Image 7.)

image

Image 7. Configuration to automatically unique group to local administrators group

Now this will now automatically add a domain group called “DOMAINNAME\COMPUTERNAME Administrators” to the local administrators group on the computer to which the policy is applied and your group policy should look like Image 8.

image

Image 8. Two local administrator group settings

Update: There are two separate local administrator group setting in the policy, the first one is the setting you see in image 5 and second one is the setting you can see in image 7.

However the “CONTOSO\DESKTOP01 Administrators” group will only be added to the local administrators group on the computer DESKTOP01 if that group is already exists. Therefore you do not need to create the group until the need arises to add an individual user or group to just a single computer.

Update: This policy will not create the group in your Active Directory called “DOMAINNAME\COMPUTERNAME Administrators” and you don’t have to create it unless you want to use it to grant permission to the computer. Once you have created the group you can then add a single user to the domain group… or multiple user accounts and groups. The other advantage of having this domain group is that it is the only place where you can grant admin access to the computer without it being automatically removed there fore it makes auditing who is a local administrator on a workstation much easier as you only have to audit the domain groups. This means that you can even report on who has access to the computer when the computer isn’t even connected to the domain.

This group policy setting combined with the other setting made earlier (see Image 5.) will mean that the local administrator group on the computer DESKTOP01 in the CONTOSO domain will have the following members automatically added to the group:

  • CONTOSO\Domain Admins
  • DESKTOP01\Administrator
  • CONTOSO\DESKTOP01 Administrators

But ANY other users or groups will be automatically removed after the next group policy refresh. This does mean there is a slight window of opportunity for someone to slip in an un-authorised account into the local administrators group but they will get removed at the next policy update.

Side Note: I have found that users almost never complain that they cant add un-authorised user to the local admin account on computer. Go figure…  :)

AWSOME!!!! I hear you say… but wait there is more…

 

How do I add additional broader groups to the local administrators group?

Now that you are able to granuarlly add a single user or group to the local administrators group on a computer you might run into problems id you have more than a 1000 computers due to AD Token Bloat Issues . So to get around this we can setup some more broadly applied administrator groups to the computer that will give admin access to only a subset of computers such as all workstations or only the SQL Servers in your organisation.

Workstations Admin Groups

To apply a Workstation administrators group to the local administrators group on all workstations make sure you have a group policy only targeted to your workstations. This is normally pretty easy as most companies isolate their workstations computer accounts to one (or a select) number of Organisational Unit.

Step 11. Go back and repeat steps 6 and 7 but this time add the group “%DomainName%”\Workstations Administrators” in the name field. This will added the additional group “CONTOSO\Workstation Administrators” to the local admin group on all the workstations in your domain which will allow you to easily add all the Desktop Administrators in your organisation access to all the workstations without having to give them the local admin password or domain admin’s privileges.

Server Role Admin Groups

It gets a little tricker when you want to grant access to a server based on its role as server are sometime configured for multiple roles. So in these steps we are going to automatically added a domain group called “CONTOSO\SQL Server Administrators” to all the servers you have that have SQL Server installed on them. This will be very handy to making sure SQL service accounts or database administrators have admin access to all the servers that have Microsoft SQL Server installed. You can however make multiple version of these admin group for other roles (e.g. Exchange,SCCM,ISA) you just need to know what the best way to target the setting.

Step 12. First make sure you are editing a group policy that is applied to all your servers in your organisation.

Step 13. Repeat Step 9 and 10 and then we open the properties of the new policy setting and specify the group but this time we type “%DomainName%\SQL Server Administrators” in the name field.

Step 14. Click on the “Common” tab and then tick “Item Level Targeting” and click the “Targeting…” button.

Step 15. Click on the “New Item” in the menu bar and select the option you want to use to target all the SQL servers in your organisation and select the “File Match” option to look in the Program Files folder and see if a sub-folder exists called “Microsoft SQL Servers” (See Image 8). This is normally true for any server that has Microsoft SQL Server installed and so it will then automatically apply the SQL Server Admin group to that server if it was installed.

Note: In this example we tested that the “Microsoft SQL Server” folder exists but we could also make rule to test for the existence of a particular file or registry key.

image

Image 8. Testing to see if Microsoft SQL Server is installed.

Now any computer that SQL Server, MSDE or SQL Express installed will get the group “CONTOSO\SQL Server Administrators” automatically added to the local admin group.

This nice thing about this is that if SQL is installed on the server at some point in the future the SQL Admin group will be added automatically at the next group policy refresh without you having to do a thing.

Finally.. now you have tight control of the local administrator groups on all the computers in your domain it is now important to monitor and secure the domain groups that are being added to the local administrator groups as they now control who has admin access to all your computers. But I will save how to do that for another blog post…

95 Comments

  1. Rajan Sriram says:

    Hi Alan, it’s a great article and we have already implemented this and worked a treat, till recently. This solution worked fine for XP machines. Recently we extended the same to WIndows 7 PCs. What we were noticing was that after a few days, the %comuptername%administrators group was getting stripped off the Builtin admin group of the PCs. Found a hotfix for that issue KB976399, which appeared to fix the issue. But it has come back, where people regularly loose access. What we do, is login as admin, force the gpupdate and then it seems to work. Is there an issue with WIndows 7 that we need to address. Will be happy to hear from you, as it is biting us hard now
    Cheers

    • Alan Burchill says:

      Thanks for the feedback… not that i have heard of… just make sure that the %computername% administrators group is in a seperate configuration item and not with other settings on the group.

    • Stuart Jones says:

      Hi Alan,

      Excellent article, a query if I may.

      The local group will be created on the local computer once the preference applies, then will become active once an AD group is created with the accounts populated? Is this thinking correct. If so, you are my hero!

      Regards

      Stuart

  2. @Stuart The local admin group is already created. If the domain group is not created then it will only give a warning in the event log. If the group is then created in AD it will be added at the next policy refresh on that computer. Hope it helps

  3. Stuart says:

    Hi Alan,

    Yes, I understand, but also i have now had chance to test, it works like a charm. Thanks for your help.

    Can i ask how you cross domain groups from parent domains, to add them to child domains. I used to do this with restricted groups, but i believe that this can cause issues when applying local groups preference. Any help would be much appreciated.

    Regards

    Stuart

  4. Stuart says:

    Hi Alan,

    Do I need to specify this in the form of a variable, or actually specifying the name & group name?

    Thanks Again.

    Stuart

  5. Rich Abraham says:

    Hi Alan,
    Quick query – step 7 – you seem to be adding the Builtin\Administrators group to the local Administrators group. Surely it should be a case of adding the Builtin\Administrator user account to the local Administrators group? By default the local Administrator user account should be in the local Administrators security group. Or am I missing something?
    Cheers,
    Rich.

  6. Kjell says:

    Hi

    I’m having problem to make WinXP to follow any GPO of this type (adding/updating/delete) local user accounts.
    No problem with win7

    Is there a limitation to OS version higher than?
    any extra action required with WinXP?

    On Win7 all I need to do is gpupdate /force

    Kjell

    • Q1: Have you installed the Group Policy Client Side extentions…

    • Kjell says:

      Thanks Alan

      thats it.

      A combination of afraid of testing on our live WinXP, and to eager to run the testings, I forgot to add the extra stuff from Windows Update where the client side extensions are.

      thanks for an excellent article

      another detail.

      when adding a GPO, test it, remove it, redo another, test it, I know getting half of it, Only BuiltIn\Administrators remains in my Local Admin Group, All other are always removed.

      Do I have to reset the GPO handling in any way to get back on square 1 ? (so to speak)

      Rgds

      Kjell

    • Preference do not revert the configuration when you remove the settings. Therefore if you remove the policy the affect will be everything will stay as it was last configured… NOT revert back to original.

    • Kjell says:

      what ment was; I followed your example “Restricted Local Admin Group” by adding 2 modifications, and it worked just like described, excellent. then I removed the GPO, made a couple of other settings on the same thema, when I was done with my labb-work I wanted to re-do the original “Restricted Local Admin” as per your example. The result now is different; Only BuiltIn\Administrator makes it through a gpupdate /force, and that’s it.
      The Domain\Domain Admins are being removed now from the local machine, I’ve re-created the GPO 2-3 times already following your description trying to see where I type wrong but I can’t make the GPO kick in correctly.
      I will create a new VM and see if that one acts correctly.

      Just wanted to check if anyone has seen this behaviour.

      Kjell

    • Alan Burchill says:

      I have seen that behaviour before if you are trying to add a user or group that does not exist. To work around this make them seperatem items and it should work…

    • Kjell says:

      Ok, I will labb on that.
      In my case I tried with BuiltIn\Administrator and %DomainName%\Domain Admins just like your example above
      Local Admins is making it, but Domain Admins is being removed as if they was not part of the GPO

      If I find the workaround i will post here

      Kjell

    • Kjell says:

      Not sure exactly what I did to fix it.

      I noticed that the example stipulates BuiltIn\Administrators and when I think about it, it should be singularis form BuiltIn\Administrator. but, that alone did not fix the problem at once.
      anyway; I also removed the BuiltIn\Administrator from the GPO and run gpupdate /force several times adding and removing other users in the GPO in between every gpupdate.
      From that moment of removing the local admin everything went back to logical, the local Admin stays in the group event though it’s not part of the GPO declaration, now the group responds correctly.

      When I finally added the local Admin to the GPO it’s still acting logical as it did the first time.
      but now its in singularis form BuiltIn\Administrator

      Kjell

  7. John says:

    Hi Alan,

    Now we have 2 different administrator groups.

    Why are we using 2 separate groups such as “Administrators (built-in)” and Administrators? Can we work only on default “Administrators” group?

    Thanks.

    John

  8. You should only use the “Administrators (Built-in)” group… Not sure how you are getting a second group called “Administrators”…

  9. VT says:

    Hi Allan…I was trying the steps you have provided to add a single or group of users from a domain to the computer’s local admin account. It didnt work….My main goal is to add a group of users from a domain and make them their computer’s local admin (as a part of our reqirements)…any other suggestions please let me know… Prior testing that, I did add a test computer to the “Test OU” and assigned a policy to that Test OU after following the steps mentioned….pls advice…

    • Things to check…
      1. Does the name you are typing match a group that exists…
      2. check the event log for warnings.
      2. Are you adding multiple groups in the one policy setting… split them onto seperate entries

      Feel free to send me an email via the contact form if you have any more detail.

  10. Doug H. says:

    Hi Alan,

    Excellent tutorial, however, I did some testing on a laptop and it seems that the Group Membership is not equal to specifying the exact account name: once I applied the policy to a notebook outside the local network (over VPN), I could not successfully elevate my permissions with that account any longer. Is that an expected limitation?

    Doug

    • Hi Doug…

      Strange one… At a guese I would say that you may need to have logged on locally at least once for the caching of the credentials to work. Centainly appling the permission via a group you would have to log off and back on again after the setting has applied for the access to become affective.

      Alan

  11. ThL says:

    Step 7 makes no sense! You should add “BuiltIn\Administrator” and NOT “BuiltIn\Administrators”. Right?

    • @ThL yes i think you are right… i have update a text and put a note next to the images that are wrong. Thanks.

    • danielkr says:

      In my tests of the way Mr. Burchill wrote this up, BuiltIn\Administrators seemed to work just fine, the workstation’s local Administrators group included the user Administrator using only steps 1-8.

  12. danielkr says:

    I have a part timer working with me. I don’t want him to have domain admin rights but I want him to be a computer administrator so he can do software installs, etc. Using the steps above 1-8 I was able to clean and secure the administrators group on the test computer. Besides builtin\administrators and domainname\administrators I also wanted this one person to be an administrator but it would not add him.

    I created a second order group just as described starting in step 9, with only him being added, and it added him. I don’t understand why I had to do that. Any ideas?

    • @danielkr The second one is need for two reasons…

      1. A bug if the group does not exist cause all the actions to fail
      2. Group is MUCH better then ading a individual user as you can see the membership on the users account in AD… Otherwise it would be very dificult to audit and control this access, especially if the computer is offline.

Leave a Reply

Spam protection by WP Captcha-Free