'How to fetch AD distinguished names (DN) in a bulk way
I am fetching AD distinguished name (DN) by the python code below
...
enter code herequery = '(sAMAccountName=%s)' % utils.conv.escape_filter_chars(name)
resp = self.search(query, ad_server=ad_server)
...
It fetches a DN for one single AD user.
How can I fetch DN for multiple AD user names, in a bulk way? So, I am passing a list of ad usernames and getting list of DN?
Solution 1:[1]
You can arrange an OR-type LDAP query, e.g.:
query = '(|%s)' % ''.join(['(sAMAccountName=%s)' % utils.conv.escape_filter_chars(x) for x in names])
That would produce a query like (|(sAMAccountName=foo)(sAMAccountName=bar)) that would be interpreted by LDAP server.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | raspy |
