Python Forum
LDAP code to query for host not returning data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LDAP code to query for host not returning data
#2
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
Reply


Messages In This Thread
RE: LDAP code to query for host not returning data - by burvil - Oct-16-2018, 01:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Returning data on button click by buttons created by a loop bradells 3 581 Apr-23-2025, 03:01 PM
Last Post: Pedroski55
  Python: How to import data from txt, instead of running the data from the code? Melcu54 1 721 Dec-13-2024, 06:50 AM
Last Post: Gribouillis
  I think I need to delete input data because returning to start fails thelad 2 1,201 Sep-24-2024, 10:12 AM
Last Post: thelad
  Returning Column and Row Data From Spreadsheet knight2000 0 1,169 Oct-22-2023, 07:07 AM
Last Post: knight2000
  Connecting to LDAP through Python ranjansanyal2007 0 959 Oct-09-2023, 05:21 PM
Last Post: ranjansanyal2007
  Code is returning the incorrect values. syntax error 007sonic 6 3,215 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  Is the following code returning a generator expression? quazirfan 8 3,390 Apr-11-2023, 11:44 PM
Last Post: quazirfan
  Basic SQL query using Py: Inserting or querying sqlite3 database not returning data marlonbown 3 3,354 Nov-08-2022, 07:16 PM
Last Post: marlonbown
  Setup host for consistent data transfer to client via TCP Gustav97 0 1,408 Jun-27-2022, 07:33 PM
Last Post: Gustav97
  Same Data Showing Several Times With Beautifulsoup Query eddywinch82 2 2,123 May-29-2022, 11:46 PM
Last Post: eddywinch82

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020