Python Forum
PyAD search function adquery
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyAD search function adquery
#1
Hi everyone,

I'm trying to search inside Active Directory with PyAD but it's not clear...

I've tried this (from : https://zakird.github.io/pyad/pyad.html#...-directory)

from pyad import adquery

q = adquery.ADQuery()

q.execute_query(
	attributes = ["distinguishedName", "description"],
	where_clause = "objectClass = 'user'",
	base_dn = "CN=users, DC=Test, DC=internal"
)

for row in q.get_results():
	print(row["distinguishedName"])
This give me a list.

But I would like to add more criteria the reduce the result.

I tried few thing including this last one ->
q.execute_query(
	attributes = ["distinguishedName", "description"],
	where_clause = ["objectClass = 'user'","CN = 'John*'"],
	base_dn = "CN=users, DC=Test, DC=internal"
)
But that give me also an error (TypeError: sequence item 2: expected str instance, list found)
So I cannot feed where_clause a list :/

Any ideas ?
[Image: NfRQr9R.jpg]
Reply
#2
try
where_clause = "objectClass = 'user' and CN = 'John*'"
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
@buran it worked ! thanks !
[Image: NfRQr9R.jpg]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  If function is false search next file mattbatt84 2 1,159 Sep-04-2022, 01:56 PM
Last Post: deanhystad
  search of a curve fitting function bluffy5 2 2,426 Dec-13-2020, 09:53 AM
Last Post: ndc85430
  Is there a way to search for function call? mtran 2 2,274 Jan-14-2020, 02:07 AM
Last Post: mtran
  Base for making a search function SheeppOSU 1 2,317 Mar-19-2019, 11:37 PM
Last Post: Yoriz
  pyad time conversion error (plus solution) PapaZod 2 3,508 Nov-25-2018, 02:42 PM
Last Post: PapaZod

Forum Jump:

User Panel Messages

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