Oct-16-2018, 01:28 AM
I changed the initialization to a more verbose loglevel:
l = ldap.initialize(uri, trace_level=4, trace_file=sys.stderr)added this to try block:
l.set_option(ldap.OPT_REFERRALS, 0)I also added one more attribute, so I know I'm getting data specifically from AD/LDAP:
attributes = ['operatingSystem','name']I then re-ran the code, and got the following. So, AD is definitely returning the data I want, just I'm not accessing it correctly. Any thoughts on how to access it?
Output:*** <ldap.ldapobject.SimpleLDAPObject instance at 0x1115e3950> ldaps://ldap-host-here:636 - SimpleLDAPObject.simple_bind
(('username@domain', 'password-here', None, None), {})
=> result:
1
*** <ldap.ldapobject.SimpleLDAPObject instance at 0x1115e3950> ldaps://ldap-host-here:636 - SimpleLDAPObject.result4
((1, 1, -1, 0, 0, 0), {})
=> result:
(97, [], 1, [])
CheckIfHostInAD - Getting hostnames in dtveng.net, base DC=ds,DC=dtveng,DC=net, criteria (&(objectclass=computer)(cn=d010220021199))
*** <ldap.ldapobject.SimpleLDAPObject instance at 0x1115e3950> ldaps://ldap-host-here:636 - SimpleLDAPObject.search_ext
(('blah=ds,blah=blah,DC=net',
2,
'(&(objectclass=computer)(cn=hostname-here))',
('operatingSystem', 'name'),
0,
None,
None,
-1,
0),
{})
=> result:
2
*** <ldap.ldapobject.SimpleLDAPObject instance at 0x1115e3950> ldaps://ldap-host-here:636 - SimpleLDAPObject.result4
((2, 1, -1, 0, 0, 0), {})
=> result:
(101,
[(u'CN=CN-here,OU=blah,OU=blah2,OU=blah3,OU=blah4,DC=blah5,DC=blah6,DC=blah7',
{u'name': ['hostname-here'],
u'operatingSystem': ['Red Hat Enterprise Linux']}),
(None, [u'ldaps://ldap-host-here/CN=Configuration,DC=blah,DC=blah,DC=blah'])],
2,
[])
*** <ldap.ldapobject.SimpleLDAPObject instance at 0x1115e3950> ldaps://ldap-host-here:636 - SimpleLDAPObject.unbind_ext
((None, None), {})
=> result:
None