# ansible and active directory

**URL:** <https://forum.ansible.com/t/ansible-and-active-directory/19023>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [August 14, 2015, 7:08pm UTC](https://forum.ansible.com/t/ansible-and-active-directory/19023 "2015-08-14T19:08:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerome\_jarr](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@jerome\_jarr](https://forum.ansible.com/u/jerome_jarr)\
**Post date:** [August 14, 2015, 7:08pm UTC](https://forum.ansible.com/t/ansible-and-active-directory/19023/1 "2015-08-14T19:08:29Z")

</div>

Can someone explain me how to use an active directory user to connect to the machines with ansible please ?

i joined all my computers on the AD, on my ansible machine i have this:

> cat /etc/ansible/group\_vars/windows-domain.yml

#it is suggested that these be encrypted with ansible-vault:  
ansible\_ssh\_user: [jerome@MONDOM.COM](mailto:jerome@MONDOM.COM) #jerome is in the ad admin group  
ansible\_ssh\_pass: password  
ansible\_ssh\_port: 5986  
ansible\_connection: winrm

> cat /etc/ansible/hosts

[windows-domain]  
[w7.MONDOM.COM](http://w7.MONDOM.COM)

But when i do this i get this error :

ANSIBLE\_LOAD\_CALLBACK\_PLUGINS=1 ansible windows-domain -m win\_ping -vvvv

\<[w7.MONDOM.COM](http://w7.MONDOM.COM)\> ESTABLISH WINRM CONNECTION FOR USER: on PORT 5986 TO [w7.MONDOM.COM](http://w7.MONDOM.COM)  
\<[w7.MONDOM.COM](http://w7.MONDOM.COM)\> WINRM CONNECT: transport=plaintext endpoint=[https://w7.MONDOM.COM:5986/wsman](https://w7.MONDOM.COM:5986/wsman)  
\<[w7.MONDOM.COM](http://w7.MONDOM.COM)\> WINRM CONNECTION ERROR: 401 Unauthorized.  
[w7.MONDOM.COM](http://w7.MONDOM.COM) | FAILED =\> 401 Unauthorized.

(it works fine if i use the local admin user)

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [August 16, 2015, 8:48am UTC](https://forum.ansible.com/t/ansible-and-active-directory/19023/2 "2015-08-16T08:48:24Z")

</div>

Jerome, I just wrote about this a feew weeks back. See if this walkthru helps you:

[http://hindenes.com/trondsworking/2015/07/27/ansible-and-windows-configuring-kerberosactive-directory-authentication/](http://hindenes.com/trondsworking/2015/07/27/ansible-and-windows-configuring-kerberosactive-directory-authentication/)
