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
  Writing a Linear Search algorithm - malformed string representation Drone4four 10 946 Jan-10-2024, 08:39 AM
Last Post: gulshan212
  String to List question help James_Thomas 6 982 Sep-06-2023, 02:32 PM
Last Post: deanhystad
  Replacing String Variable with a new String Name kevv11 2 787 Jul-29-2023, 12:03 PM
Last Post: snippsat
  syntax error question - string mgallotti 5 1,316 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 2,031 Jan-10-2023, 11:26 AM
Last Post: codinglearner
  Ldap3 Python print(conn.entries) doesnt work ilknurg 15 5,764 Dec-28-2022, 11:22 AM
Last Post: shad
  python r string for variable mg24 3 2,818 Oct-28-2022, 04:19 AM
Last Post: deanhystad
  USE string data as a variable NAME rokorps 1 964 Sep-30-2022, 01:08 PM
Last Post: deanhystad
  Removing Space between variable and string in Python coder_sw99 6 6,290 Aug-23-2022, 01:15 PM
Last Post: louries
  Remove a space between a string and variable in print sie 5 1,783 Jul-27-2022, 02:36 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