Unable to contact Active Directory through pyad

392 Views Asked by At

I'm not able to connect to pyad module to create Active Directory objects. I'm getting an exception as shown below:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\sparava\PycharmProjects\imds_ad_pycliient\venv\lib\site-packages\pyad\adobject.py", line 135, in from_cn
    return cls(adsearch.by_cn(cn, search_base, options), None, options)
  File "C:\Users\sparava\PycharmProjects\imds_ad_pycliient\venv\lib\site-packages\pyad\adsearch.py", line 17, in by_cn
    type="GC")
  File "C:\Users\sparava\PycharmProjects\imds_ad_pycliient\venv\lib\site-packages\pyad\adquery.py", line 78, in execute_query
    self.__rs, self.__rc = command.Execute()
  File "<COMObject ADODB.Command>", line 3, in Execute
  File "C:\Users\sparava\PycharmProjects\imds_ad_pycliient\venv\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, 'Active Directory', 'The server is not operational.\r\n', None, 0, -2147217865), None)
1

There are 1 best solutions below

0
On

"The server is not operational" means that it cannot contact the server.

I assume type="GC" means that it is trying to contact the Global Catalog, which is on port 3268 by default, unless you specifically specified a different port.

So all this means that it cannot open a connection to your AD server on port 3268.

Maybe it's a network issue, or maybe it's a configuration issue in your application. If you update your question with your code, I might be able to spot something that looks off, or maybe not