i finished online course at udemy and now i try some stuff and i need help with pyad, trying to create active directory user in virtual machine (the code also at the machine) looked online and it looks perfect one on one but suddenly i get an error,
error with this code:
from pyad import *
pyad.set_defaults(ldap_server="DC-01-Training.Udemy.training",username="Administrator",password="abc-123")
#test create new user
user = "pyadtest"
ou = pyad.adcontainer.ADContainer.from_dn("ou=Users,dc=Udemy,dc=Training")
new_user = pyad.aduser.ADUser.create(user,ou,password="abc-123")
ERROR:
---------------------------------------------------------------------------
com_error Traceback (most recent call last)
<ipython-input-40-c8119c8ee0d8> in <module>
17 #test create
18 user = "pyadtest"
---> 19 ou = pyad.adcontainer.ADContainer.from_dn("ou=Users,dc=Udemy,dc=Training")
20 new_user = pyad.aduser.ADUser.create(user,ou,password="abc-123")
21
C:\ProgramData\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
C:\ProgramData\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")
C:\ProgramData\Anaconda3\lib\site-packages\pyad\adobject.py in __set_adsi_obj(self)
51 if self.default_ssl:
52 flag = flag | ADS_AUTHENTICATION_TYPE['ADS_USE_ENCRYPTION']
---> 53 self._ldap_adsi_obj = _ds.OpenDSObject(
54 self.__ads_path,
55 self.default_username,
C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py in OpenDSObject(self, *args)
com_error: (-2147352567, 'Exception occurred.', (0, 'Active Directory', 'There is no such object on the server.\r\n', None, 0, -2147016656), None)
``