Query RootDSE using Python LDAP (Misc)
This code can be found in
Chapter 20 of Active Directory Cookbook, 2nd edition
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the Misc code from this site.
import ldap
try:
l = ldap.open("dc1")
except ldap.LDAPError, e:
print e
baseDN = ""
searchScope = ldap.SCOPE_BASE
retrieveAttributes = None
searchFilter = "objectclass=*"
try:
ldap_result_id = l.search(baseDN, searchScope, searchFilter,
retrieveAttributes)
result_type, result_data = l.result(ldap_result_id, 0)
if result_type == ldap.RES_SEARCH_ENTRY:
print result_data
except ldap.LDAPError, e:
print e
|
This code has been viewed 2929 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|