Hi I use python-ldap(2.3.8) to modify AD's user password. When I run it, the password change done, it always show traceback message.
Traceback (most recent call last): File "ldapauth.py", line 141, in <module> modifyAD('userid','passwordblah') File "ldapauth.py", line 105, in modifyAD conn.modify_s(dn, attr) File "c:\lang\python\lib\site-packages\ldap\ldapobject.py", line 327, in modify_s msgid = self.modify(dn,modlist) File "c:\lang\python\lib\site-packages\ldap\ldapobject.py", line 324, in modify return self.modify_ext(dn,modlist,None,None) File "c:\lang\python\lib\site-packages\ldap\ldapobject.py", line 297, in modify_ext return self._ldap_call(self._l.modify_ext,dn,modlist,EncodeControlTuples(serverctrls),EncodeControlTuples(clientctrls)) File "c:\lang\python\lib\site-packages\ldap\ldapobject.py", line 96, in _ldap_call result = func(*args,**kwargs) TypeError: argument 1 must be string, not None snippets code: def modifyAD(username, password): LDAP_SERVER = 'ldaps://myad:636' LDAP_ADMIN = ad...@myad' LDAP_PASSWD = '' BASE_DN = '' searchScope = ldap.SCOPE_SUBTREE conn = ldap.initialize(LDAP_SERVER) ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, '-ad.pem') ldap.set_option(ldap.OPT_REFERRALS,0) conn.protocol_version = ldap.VERSION3 conn.bind_s(LDAP_ADMIN, LDAP_PASSWD) searchFilter = 'cn='+username attrs = ['unicodePwd'] ldap_result_id = conn.search_s(BASE_DN, searchScope, searchFilter, attrs) if (ldap_result_id == []): print 'user not found' else: newPassword = ('"%s"' % password).encode('utf-16-le') for dn,entry in ldap_result_id: attr = [( ldap.MOD_REPLACE, 'unicodePwd', newPassword)] try: conn.modify_s(dn, attr) except ldap.LDAPError, error: print 'error',error conn.unbind_s() Does anybody known how to solve? Best regards, ychsiao ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Python-LDAP-dev mailing list Python-LDAP-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/python-ldap-dev