Python Forum
ldap3 question, using a variable in search string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ldap3 question, using a variable in search string
#1
I'm trying to figure out how to put in a variable in my search string for ldap3. I want to create a loop that goes through a list of usernames and does an Active Directory search thru each username.

First statement binds me to Domain Controller, the second one does a search. I'm trying to have a variable at the end of the second statement for the sAMAccountName. I want "adname" to be my variable. How do I do that?

conn = Connection([server1], user='domain\\user', password='password', auto_bind=True)

conn.search('dc=test,dc=mydomain,dc=com', '(&(objectCategory=person)(objectClass=user)(sAMAccountName=adname))')
Thanks in advance.
Reply
#2
I got it resolved guys. Thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  question about changing the string value of a list element jacksfrustration 4 2,061 Feb-08-2025, 07:43 AM
Last Post: jacksfrustration
  How to read a file as binary or hex "string" so that I can do regex search? tatahuft 3 1,046 Dec-19-2024, 11:57 AM
Last Post: snippsat
  Writing a Linear Search algorithm - malformed string representation Drone4four 10 4,035 Jan-10-2024, 08:39 AM
Last Post: gulshan212
  String to List question help James_Thomas 6 2,382 Sep-06-2023, 02:32 PM
Last Post: deanhystad
  Replacing String Variable with a new String Name kevv11 2 1,631 Jul-29-2023, 12:03 PM
Last Post: snippsat
  syntax error question - string mgallotti 5 2,626 Feb-03-2023, 05:10 PM
Last Post: mgallotti
  Need help on how to include single quotes on data of variable string hani_hms 5 7,120 Jan-10-2023, 11:26 AM
Last Post: codinglearner
  Ldap3 Python print(conn.entries) doesnt work ilknurg 15 10,907 Dec-28-2022, 11:22 AM
Last Post: shad
  python r string for variable mg24 3 6,846 Oct-28-2022, 04:19 AM
Last Post: deanhystad
  USE string data as a variable NAME rokorps 1 1,498 Sep-30-2022, 01:08 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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