zakird / pyad

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

Querying Domain objects with a computer thats not joined to the domain #63

Open daisydanxu opened 7 years ago

daisydanxu commented 7 years ago

I'm trying to run the instructions from

https://pypi.python.org/pypi/pyad

which stipulates to use the below command to query another domain

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

However when i do so, i get the following error

WARN: unable to connect to default domain. Computer is likely not attached to an AD domain Traceback (most recent call last): File "C:/Users//Documents/Projekt1/Demo.py", line 6, in user = pyad.aduser.ADUser.from_cn("myuser") File "C:\Python\lib\site-packages\pyad\adobject.py", line 135, in from_cn return cls(adsearch.by_cn(cn, search_base, options), None, options) File "C:\Python\lib\site-packages\pyad\adsearch.py", line 10, in by_cn raise Exception("Unable to detect default domain. Must specify search base.") Exception: Unable to detect default domain. Must specify search base.

Process finished with exit code 1

How do i fix this

daisydanxu commented 7 years ago

it seems when installing pyad, it failed to install many modules. The following errors i recieved

copying build\lib\pyad__init__.py -> build\bdist.win32\egg\pyad byte-compiling build\bdist.win32\egg\pyad\adbase.py to adbase.cpython-35.pyc File "build\bdist.win32\egg\pyad\adbase.py", line 29 print "WARN: unable to connect to default domain. Computer is likely not attached to an AD domain" ^ SyntaxError: Missing parentheses in call to 'print'

byte-compiling build\bdist.win32\egg\pyad\adcomputer.py to adcomputer.cpython-35.pyc byte-compiling build\bdist.win32\egg\pyad\adcontainer.py to adcontainer.cpython-35.pyc File "build\bdist.win32\egg\pyad\adcontainer.py", line 45 except pywintypes.com_error, e: ^ SyntaxError: invalid syntax

byte-compiling build\bdist.win32\egg\pyad\addomain.py to addomain.cpython-35.pyc byte-compiling build\bdist.win32\egg\pyad\adgroup.py to adgroup.cpython-35.pyc byte-compiling build\bdist.win32\egg\pyad\adobject.py to adobject.cpython-35.pyc File "build\bdist.win32\egg\pyad\adobject.py", line 289 except pywintypes.com_error, excpt: ^ SyntaxError: invalid syntax

byte-compiling build\bdist.win32\egg\pyad\adquery.py to adquery.cpython-35.pyc byte-compiling build\bdist.win32\egg\pyad\adsearch.py to adsearch.cpython-35.pyc byte-compiling build\bdist.win32\egg\pyad\aduser.py to aduser.cpython-35.pyc File "build\bdist.win32\egg\pyad\aduser.py", line 23 except pywintypes.com_error, excpt: ^ SyntaxError: invalid syntax

byte-compiling build\bdist.win32\egg\pyad\pyad.py to pyad.cpython-35.pyc byte-compiling build\bdist.win32\egg\pyad\pyadconstants.py to pyadconstants.cpython-35.pyc File "build\bdist.win32\egg\pyad\pyadconstants.py", line 60 0x00005011L:('S_ADS_ERRORSOCCURRED', ^ SyntaxError: invalid syntax

byte-compiling build\bdist.win32\egg\pyad\pyadexceptions.py to pyadexceptions.cpython-35.pyc File "build\bdist.win32\egg\pyad\pyadexceptions.py", line 7 print "Error Constant: %s" % self.error_info['error_constant'] ^ SyntaxError: Missing parentheses in call to 'print'

byte-compiling build\bdist.win32\egg\pyad\pyadutils.py to pyadutils.cpython-35.pyc File "build\bdist.win32\egg\pyad\pyadutils.py", line 65

byte-compiling build\bdist.win32\egg\pyad__init.py to init__.cpython-35.pyc creating build\bdist.win32\egg\EGG-INFO

spyoungtech commented 7 years ago

@daisydanxu Looks like you're trying to build with a Python2 egg. Instead of using pip/PyPI to install, try cloning the repo instead and install from there. See #58 and #60

LochyWragg commented 5 years ago

I still get the : unable to connect to default domain. Computer is likely not attached to an AD domain error while on VPN which should be able to contact main DC. Any ideas on this one?