Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting an entry by DN? #187

Closed
BonkaBonka opened this issue Jun 15, 2016 · 2 comments
Closed

Getting an entry by DN? #187

BonkaBonka opened this issue Jun 15, 2016 · 2 comments

Comments

@BonkaBonka
Copy link

I'm generating some reports from LDAP and have a list of DNs that I need to look up to pull additional information. Short of decomposing the DN myself and using a search, I can't find a way to fetch an entry by DN. What am I missing?

@cannatag
Copy link
Owner

cannatag commented Jun 15, 2016

Hi, you must perform a BASE search. This means that you provide the dn as searc_base and a generic filter like (objectclass=*) as search_filter. This actually read the dn object without performing any search.

for example:

from ldap3 import Server, Connection, BASE, ALL_ATTRIBUTES
dn = 'cn=object,dc=abc,dc=com'
s = Server('my_server')
c = Connection(s, user='username', password='password')
c.search(search_base = dn,
         search_filter = '(objectClass=*)',
         search_scope = BASE,
         attributes = ALL_ATTRIBUTES)
print(c.entries)

@BonkaBonka
Copy link
Author

Aha, that cured my issue! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants