On Sep 9, 2009, at 1:32 PM, Zhang Huangbin wrote: > > I want to replace cn=cn2 by cn=cn4 if it exist, or add cn=cn4 > directly if 'cn=cn2' donesn't exist. > > If cn=cn2 is not exist, [(ldap.MOD_DELETE, 'cn', 'cn2')] will raise > an error. > If cn=cn2 is not exist, [(ldap.MOD_ADD, 'cn', 'cn4')] will add > cn=cn4, but can't delete 'cn=cn2'.
Oops, forget to mention that i will modify more attributes every time, not only 'cn'. Such as: ---- mod_attrs = [ (ldap.MOD_XXX, attr1, value1), (ldap.MOD_XXX, attr2, [value2]), ... ] self.conn.modify_s(dn, mod_attrs) ---- Is there a better way to modify it except using several 'try:...except:...' block? -- Best Regards. Zhang Huangbin - Open Source Mail Server Solution for Red Hat(R) Enterprise Linux, CentOS, Debian, Ubuntu: http://www.iredmail.org/ ------------------------------------------------------------------------------ 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