Python Forum
Ldap3 Python print(conn.entries) doesnt work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ldap3 Python print(conn.entries) doesnt work
#5
(Mar-15-2022, 07:25 AM)Gribouillis Wrote: So you want to convert a search result which is a bytes string to json. What does the bytes string look like? Can you post it here? Also how have you tried to convert it to json?

Here is my search result:


(True, {'result': 0, 'description': 'success', 'dn': '', 'message': '', 'referrals': None, 'type': 'searchResDone'}, [{'raw_dn': b'CN=user G\xc3\xbc\xc3\xa7l\xc3\xbc,OU=DEVELOPERS,OU=ANKARA,OU=TURKIYE,OU=TRD-GLOBAL,DC=TRD,DC=local', 'dn': 'CN=User1,OU=DEVELOPER,OU=ANKARA,OU=TURKIYE,OU=TRD-GLOBAL,DC=TRD,DC=local', 'raw_attributes': {}, 'attributes': {}, 'type': 'searchResEntry'}, {'uri': ['ldap://ForestDnsZones.TRD.local/DC=ForestDnsZones,DC=TRD,DC=local'], 'type': 'searchResRef'}, {'uri': ['ldap://DomainDnsZones.TRD.local/DC=DomainDnsZones,DC=TRD,DC=local'], 'type': 'searchResRef'}, {'uri': ['ldap://TRD.local/CN=Configuration,DC=TRD,DC=local'], 'type': 'searchResRef'}], {'base': 'dc=my,dc=server', 'scope': 2, 'dereferenceAlias': 3, 'sizeLimit': 0, 'timeLimit': 0, 'typesOnly': False, 'filter': '(sAMAccountName=user1)', 'attributes': ['1.1'], 'type': 'searchRequest', 'controls': None})
I've try:

result= conn.search('dc=my,dc=server', f'(sAMAccountName={username})')
print(result)
result2 = json.dump(result)
print(result2)
I got:

TypeError: Object of type 'bytes' is not JSON serializable
Reply


Messages In This Thread
RE: Ldap3 Python print(conn.entries) doesnt work - by ilknurg - Mar-15-2022, 08:00 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  equalto validator doesnt work robertkwild 1 240 Jun-02-2024, 06:16 AM
Last Post: Pedroski55
  print doesnt work in a function ony 2 461 Mar-11-2024, 12:42 PM
Last Post: Pedroski55
  Pydoc documentation doesnt work Cosmosso 5 4,643 Nov-25-2023, 11:17 PM
Last Post: vidito
  sqlite3 Conn Insert Value Error TylerDunbar 3 890 Sep-04-2023, 06:32 PM
Last Post: deanhystad
  pip install requests doesnt work misodca 8 7,460 Jul-07-2023, 08:04 AM
Last Post: zyple
  pip install pystyle doesnt work person_probably 2 2,328 Sep-23-2022, 02:59 PM
Last Post: person_probably
  Why doesnt chunk generation work? LotosProgramer 1 2,042 Apr-02-2022, 08:25 AM
Last Post: deanhystad
  if conditions in the for indentation doesnt work ? Sutsro 6 4,132 Jun-15-2021, 11:45 PM
Last Post: bowlofred
  Why doesn't this print statement work? stylingpat 10 6,125 Mar-23-2021, 07:54 PM
Last Post: buran
  I have two Same Code but One of them Doesnt Work beginner721 6 3,290 Jan-22-2021, 10:56 PM
Last Post: beginner721

Forum Jump:

User Panel Messages

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