# Inventory: ERROR! non-essential-servers.py:2: Expected key=value host variable assignment, got: ldap3

**URL:** <https://forum.ansible.com/t/inventory-error-non-essential-servers-py-expected-key-value-host-variable-assignment-got-ldap3/21278>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [April 26, 2016, 6:45pm UTC](https://forum.ansible.com/t/inventory-error-non-essential-servers-py-expected-key-value-host-variable-assignment-got-ldap3/21278 "2016-04-26T18:45:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jared\_Jenkins](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@Jared\_Jenkins](https://forum.ansible.com/u/Jared_Jenkins)\
**Post date:** [April 26, 2016, 6:45pm UTC](https://forum.ansible.com/t/inventory-error-non-essential-servers-py-expected-key-value-host-variable-assignment-got-ldap3/21278/1 "2016-04-26T18:45:25Z")

</div>

#!/usr/bin/env python

# -_- coding: utf-8 -_

# import class and constants

from ldap3 import Server, Connection, ALL, NTLM, Tls  
import json  
import ssl

# define the server and the connection

server = Server(‘server’, use\_ssl=True)  
conn = Connection(server, user=“domain\kace\_ldap”, password=“password”, authentication=NTLM, auto\_bind=True)  
#conn = Connection(server, user=ldapusr, password=ldappwd, authentication=NTLM, auto\_bind=True)

conn.open()  
conn.bind()  
conn.entries  
conn.search(‘OU=Servers, OU=OU, DC=Domain, DC=com’, ‘(objectclass=computer)’, attributes=[“name”])

names =   
for x in conn.response:  
names.append(x[‘attributes’][‘name’][0])

conn.unbind()

hosts = {}  
hosts[‘hosts’] = names  
var = {‘a’:True}

export = {}  
export[‘windows’] = hosts  
print json.dumps(export, sort\_keys=True, indent=4, separators=(‘,’, ': '))
