zakird / pyad

Python Active Directory Tools | *Not actively maintained*
http://zakird.github.io/pyad/
176 stars 72 forks source link

Can you use pyad.set_defaults with adquery.ADQuery()? If not, what is the correct way to query Active Directory remotely? #77

Open naloqab opened 6 years ago

naloqab commented 6 years ago

This is what I get:

Traceback (most recent call last): File ".\ldap_test2.py", line 7, in q = adquery.ADQuery() File "C:\Program Files (x86)\Python\Python36-32\lib\site-packages\pyad\adquery.py", line 39, in init self.__adodb_conn.Open("Provider=ADSDSOObject") File "", line 3, in Open File "C:\Program Files (x86)\Python\Python36-32\lib\site-packages\win32com\client\dynamic.py", line 287, in ApplyTypes result = self.oleobj.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args) pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft OLE DB Service Components', 'The parameter is incorrect.', None, 0, -2147024809), None)

daveoy commented 6 years ago

having this issue myself

gorkemgoknar commented 5 years ago

Try as following (via [ https://zakird.com/pyad/pyad.html ])


from pyad import *
pyad.set_defaults(ldap_server="dc1.domain.com", username="service_account", password="mypassword")
user = pyad.aduser.ADUser.from_cn("myuser"
```)
daveoy commented 5 years ago

ADQuery object, not ADUser object.

gorkemgoknar commented 5 years ago

There is the fix https://github.com/zakird/pyad/issues/49 , you should replace in adquery.py new version does not implement it (maintanence stopped)