#!/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=(',', ': '))
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1690da14-e799-4f11-a62d-3a8282e5228c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.