Active Directory and ActivePython2.1

alan runyan runyaga at thisbox.com
Sat Nov 10 04:42:27 CET 2001


I'm trying to use ldap search filters w/ Python against Active Directory and
things are jiving.  I can get it to work w/ ASP no problem.  All help would
be *greatly* appreciated.

my problemed Python Script
    adsi = win32com.client.Dispatch('ADsNameSpaces')
    ldap=adsi.getobject('', 'LDAP:')
    ldapQuery='<LDAP://mydomain.net>;(objectClass=Person);ADsPath,cn;root'
    myDSObject = ldap.OpenDSObject(ldapQuery,'username','password', 1)

I get:
Traceback (most recent call last):
  File "E:\Python21\Pythonwin\pywin\framework\scriptutils.py", line 301, in
RunScript
    exec codeObject in __main__.__dict__
  File "E:\ZOPE\Extensions\adsi.py", line 37, in ?
  File "<COMObject <unknown>>", line 2, in OpenDSObject
com_error: (-2147352567, 'Exception occurred.', (0, 'Active Directory',
'Unspecified error\r\n', None, 0, -2147467259), None)

in VBScript/ASP

      Set conn = server.createobject("ADODB.Connection")
      conn.Provider = "ADSDSOObject"
      conn.Open "ADs Provider"
      Set rs =
conn.Execute("<LDAP://mydomain.net>;(objectClass=Person);ADsPath,objectClass
,cn;subtree")

am I doing some glaringly wrong?

any comments greatly appreciated
~runyaga






More information about the Python-list mailing list