If I already have an LDAP DN, how do I get the attributes for that DN with ldap3.Connection.search()
? There is no other search criteria, I already have the DN...
I tried searching for dn attribute, but it returned no objects found. I also tried forcing search_filter
to ''
, '()'
or None
and they all returned malformed filter string.
I also couldn't find a way to do this with the abstract Reader...
In ldapsearch
you don't need to specify a search filter if you are doing a baseDN lookup...
import ldap3
ldap_conn = ldap3.Connection('ldapserver', raise_exceptions=True,
auto_bind=True, user='me', password='mypassword')
my_dn = "attrib1=blahblah, ou=org1, dc=dc1, dc=dcroot"
ldap_conn.search(
search_base=my_dn,
search_filter= '(????)', # required
search_scope=ldap3.BASE,
attributes='*'
)
print(ldap_conn.response)