[python-win32] Creating users with ADSI

Pierre Hjälm pierre.hjalm at dis.uu.se
Fri Oct 31 06:46:14 EST 2003


Why does the code below give this error message?:

Traceback (most recent call last):
  File "usertest2.py", line 12, in ?
    aduser.Setinfo()
  File "<COMObject <unknown>>", line 2, in Setinfo
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147019886), None)


# code
from win32com.client import Dispatch

adsi=Dispatch("ADsNamespaces")
ou=adsi.GetObject("","LDAP://ou=Employees,dc=test,dc=local")
# above line changed to protect the innocent ;)

aduser=ou.Create("User","cn=test")

aduser.Put("sAMAccountName","test")
aduser.Put("givenName","test")
aduser.Put("sn","test")
aduser.Put("userPrincipalName","test")
aduser.Setinfo()

-- 
  Pierre Hjälm, Systems Administrator
  Department of Information Science, Uppsala University, Sweden
  email:pierre.hjalm at dis.uu.se  phone:+46-(0)18-4711044  fax:+46-(0)18-554422



More information about the Python-win32 mailing list