我正在尝试使用pyad创建一个用户,我的工作是:
ou = pyad.adcontainer.ADContainer.from_dn('OU=Employees,DC=lan,DC=company,DC=com')
name = ("doe john")
newUser = pyad.aduser.ADUser.create(name, ou, password="password")
但是如果我试着让这个名字
doe, john
ou = pyad.adcontainer.ADContainer.from_dn('OU=Employees,DC=lan,DC=company,DC=com')
name = ("doe, john")
newUser = pyad.aduser.ADUser.create(name, ou, password="password")
我知道错误:
Traceback (most recent call last):
File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site- packages\pyad\adcontainer.py", line 38, in create_user
obj.SetInfo()
File "<COMObject <unknown>>", line 2, in SetInfo
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Active
Directory', 'An invalid dn syntax has been specified.\r\n', None, 0, -2147016654), None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "NamelyToAD.py", line 49, in <module>
newUser = pyad.aduser.ADUser.create(name, ou, password="Password1")
File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyad\aduser.py", line 16, in create
optional_attributes=optional_attributes
File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyad\adcontainer.py", line 47, in create_user
pyadutils.pass_up_com_exception(e)
File "C:\Users\me\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pyad\pyadutils.py", line 58, in pass_up_com_exception
raise WIN32_ERRORS.get(info['error_num'], win32Exception)(error_info=info, additional_info=additional_info)
pyad.pyadexceptions.win32Exception: 0x80072032: An invalid dn syntax has been specified.
我不知道怎么绕过逗号,我试过转义它,也包括一个chr(44),但没什么用。