I want to change the userAccountControl and password of the AD user. User is already created in AD. The user is created with python-ldap module in AD and is in 'Disabled' state and with no password.
AD is hosted on win2k8R2.
When I change the uac and password with the pythion-ldap script it throws below error:
ldap://192.168.254.1:389
(97, [])
Traceback (most recent call last):
File "C:\workspace\utils\src\u.py", line 16, in <module>
l.modify_s(dn, mod_attrs)
File "C:\Python26\lib\site-packages\ldap\ldapobject.py", line 336, in modify_s
return self.result(msgid,all=1,timeout=self.timeout)
File "C:\Python26\lib\site-packages\ldap\ldapobject.py", line 436, in result
res_type,res_data,res_msgid = self.result2(msgid,all,timeout)
File "C:\Python26\lib\site-packages\ldap\ldapobject.py", line 440, in result2
res_type, res_data, res_msgid, srv_ctrls = self.result3(msgid,all,timeout)
File "C:\Python26\lib\site-packages\ldap\ldapobject.py", line 446, in result3
ldap_result = self._ldap_call(self._l.result3,msgid,all,timeout)
File "C:\Python26\lib\site-packages\ldap\ldapobject.py", line 96, in _ldap_call
result = func(*args,**kwargs)
ldap.UNWILLING_TO_PERFORM: {'info': '00002077: SvcErr: DSID-031903A4, problem 5003 (WILL_NOT_PERFORM), data 0\n', 'desc': 'Server is unwilling to perform'}
import ldap
host = "192.168.254.1"
ip = "ldap://%s:%d"%(host, 389)
l = ldap.initialize(ip)
newUser = "vishalworld"
dn = "cn=%s,%s"%(newUser, "cn=Users,DC=example,DC=com")
print l.simple_bind_s("administrator",password)
pwd = '"abcdefgh"'.encode("utf-16-le")
mod_attrs = [
(ldap.MOD_REPLACE, "lockoutTime", 0),
(ldap.MOD_REPLACE, "unicodePwd", pwd),
]
l.modify_s(dn, mod_attrs)
First you need to add tls support to your AD.http://araihan.wordpress.com/2009/10/05/windows-server-2008-active-directory-certificate-services-ad-cs/ this is a tutorial to explain how to create the certificate
Then you need to authenticate with tls to the AD. like this
Then you can add your user for test
and TA TA!!!