zakird / pyad

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

Error when searching for a user in Active Directory #155

Open BhanuPrakashSamoju opened 2 years ago

BhanuPrakashSamoju commented 2 years ago

Hi,

I am trying to connect to an active directory and search for a user on my domain. But I am getting below error while searching using common name(from_cn) & distinguished name (from_dn).

Kindly help me understand why this error occurs.

from pyad import * pyad.set_defaults(ldap_server="testlab.com", username="u20@testlab.com", password="**") user1 = aduser.ADUser.from_dn("cn=u10, ou=AEO-POC, dc=testlab, dc=com")

com_error Traceback (most recent call last)

in ----> 1 user1 = aduser.ADUser.from_dn("cn=u10, ou=staff, dc=testlab, dc=com") 2 print(user1) ~\AppData\Local\Continuum\anaconda3\lib\site-packages\pyad\adobject.py in from_dn(cls, distinguished_name, options) 129 def from_dn(cls, distinguished_name, options={}): 130 "Generates ADObject based on distinguished name" --> 131 return cls(distinguished_name, None, options) 132 133 @classmethod ~\AppData\Local\Continuum\anaconda3\lib\site-packages\pyad\adobject.py in __init__(self, distinguished_name, adsi_ldap_com_object, options) 86 self.default_ldap_port 87 ) ---> 88 self.__set_adsi_obj() 89 else: 90 raise Exception("Either a distinguished name or a COM object must be provided to create an ADObject") ~\AppData\Local\Continuum\anaconda3\lib\site-packages\pyad\adobject.py in __set_adsi_obj(self) 55 self.default_username, 56 self.default_password, ---> 57 flag) 58 59 elif self.default_ssl: ~\AppData\Local\Continuum\anaconda3\lib\site-packages\win32com\client\dynamic.py in OpenDSObject(self, *args) com_error: (-2147352567, 'Exception occurred.', (0, 'Active Directory', 'The server is not operational.\r\n', None, 0, -2147016646), None)

Thanks & regards, Bhanu Prakash.