# Using Ansible w/ Windows with strict security

**URL:** <https://forum.ansible.com/t/using-ansible-w-windows-with-strict-security/23006>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [November 11, 2016, 1:26am UTC](https://forum.ansible.com/t/using-ansible-w-windows-with-strict-security/23006 "2016-11-11T01:26:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigbookcp](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@bigbookcp](https://forum.ansible.com/u/bigbookcp)\
**Post date:** [November 11, 2016, 1:26am UTC](https://forum.ansible.com/t/using-ansible-w-windows-with-strict-security/23006/1 "2016-11-11T01:26:16Z")

</div>

Our environment is under some pretty strict security requirements and it’s causing lots of issues. First, we don’t have an active directory set up (all local accounts, I know it’s stupid but I’m just the idiot trying to clean it up). Then, we have this LocalAccountTokenFilterPolicy registry setting set to 1 so every time I try to run something I get permission errors as it lowers permissions.

I am allowed to temporarily disable the LocalAccountTokenFilterPolicy to do what I need to do, but need a mechanism to do that. I’m able to use win\_command to do switch it from 1 to 0 but can’t switch it from 0 - 1.

Is there any way to get in with WinRM through ansible then run a command as an elevated user?

Thanks!

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [November 14, 2016, 10:29am UTC](https://forum.ansible.com/t/using-ansible-w-windows-with-strict-security/23006/2 "2016-11-14T10:29:42Z")

</div>

I’m guessing that applying the LocalAccountTokenFilterPolicy kicks your ansible connection out before it can respond.

Since you are on 2.2 you should be able to use async, which might let you switch from from 0 - 1

There isn’t a way to become another user yet on windows but it is slated for 2.3 - see [https://github.com/ansible/ansible/blob/devel/docsite/rst/roadmap/ROADMAP\_2\_3.rst](https://github.com/ansible/ansible/blob/devel/docsite/rst/roadmap/ROADMAP_2_3.rst)

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Matt\_Davis](https://forum.ansible.com/u/Matt_Davis)\
**Post date:** [November 14, 2016, 4:31pm UTC](https://forum.ansible.com/t/using-ansible-w-windows-with-strict-security/23006/3 "2016-11-14T16:31:41Z")

</div>

I’m actually curious how you got LocalAccountTokenFilterPolicy to cause restriction under WinRM- I’ve tried many combos of 2008R2/2012R2/2016 under full UAC prompt requirements, domain-joined/not, various users, etc, to no avail- I can’t get it to restrict the admin group for a local user in a WinRM session. I’m actually running into UAC issues under the become prototypes (since we’re now using interactive logons instead of batch), but I can’t get that particular one to break.

---

<div class="post-metadata">

**Author:** ![bigbookcp](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@bigbookcp](https://forum.ansible.com/u/bigbookcp)\
**Post date:** [November 14, 2016, 4:50pm UTC](https://forum.ansible.com/t/using-ansible-w-windows-with-strict-security/23006/4 "2016-11-14T16:50:16Z")

</div>

I ended up giving the user explicit access to the registry key and all playbooks begin with flipping the value, doing the work, then flipping it back. We are working on a domain solution so the local accounts won’t be an issue one day…

We’re using a DoD STIG image for our windows servers which has a number of other security settings. I’ve added a screen shot of our registry that you maybe able to mimic to get it to break. We’re on 2012 for this particular server. Path is: HKLM\Software\MIcrosoft\Windows\CurrentVersion\policies\system.

If you’re using AWS I can probably share an AMI that has the issue with your account.

[![](https://lh3.googleusercontent.com/-NF9AULtpLGY/WCnqsVijl6I/AAAAAAAAAAM/v9kQRim14gMsmVjQLnS8fGe9E5EMtDlJQCLcB/s320/Registry.PNG)](https://lh3.googleusercontent.com/-NF9AULtpLGY/WCnqsVijl6I/AAAAAAAAAAM/v9kQRim14gMsmVjQLnS8fGe9E5EMtDlJQCLcB/s1600/Registry.PNG)
