What's the best way to replace value of attribute which can handle multiple values?

Zhang Huangbin zhbmaillistonly at gmail.com
Wed Sep 9 14:08:23 CEST 2009


On Sep 9, 2009, at 6:02 PM, Michael Ströder wrote:

> Zhang Huangbin wrote:
>> On Sep 9, 2009, at 4:54 PM, Michael Ströder wrote:
>>>> If cn=cn2 is not exist, [(ldap.MOD_DELETE, 'cn', 'cn2')] will raise
>>>> an
>>>> error.
>>> Could you please post the error raised and mention with which server
>>> you're
>>> testing?
>>>
>>> I'd try [(ldap.MOD_DELETE, 'cn',['cn2'])]
>>
>> The same error if cn=cn2 not exist: ldap.NO_SUCH_ATTRIBUTE.
>
> And how about the diagnostic message? I'd test the code with  
> trace_level=2.


bind dn: cn=vmailadmin,dc=iredmail,dc=org
operation: [(ldap.MOD_DELETE, 'enabledService', 'forward')]
ldif:
----
dn:  
mail=test22 at a.cn,ou=Users,domainName=a.cn,o=domains,dc=iredmail,dc=org
enabledService: smtp
enabledService: imap
enabledService: pop3
enabledService: deliver
----

Below is console log with 'trace_level=2':
------------
*** ldap://127.0.0.1:389 - SimpleLDAPObject.set_option ((17, 3),{})
*** ldap://127.0.0.1:389 - SimpleLDAPObject.set_option ((17, 3),{})
*** ldap://127.0.0.1:389 - SimpleLDAPObject.simple_bind  
(('cn=vmailadmin,dc=iredmail,dc=org', 'passwd', None, None),{})
=> result: 1
*** ldap://127.0.0.1:389 - SimpleLDAPObject.result3 ((1, 1, -1),{})
=> result: (97, [], 1, [])
*** ldap://127.0.0.1:389 - SimpleLDAPObject.modify_ext (('mail=test22 at a.cn 
,ou=Users,domainName=a.cn,o=domains,dc=iredmail,dc=org', [(1,  
'enabledService', 'forward')], None, None),{})
=> result: 3
*** ldap://127.0.0.1:389 - SimpleLDAPObject.result3 ((3, 1, -1),{})
=> LDAPError - NO_SUCH_ATTRIBUTE: {'info': 'modify/delete:  
enabledService: no such value', 'desc': 'No such attribute'}
Traceback (most recent call last):
   File "/usr/lib/python2.4/site-packages/web.py-0.32-py2.4.egg/web/ 
application.py", line 242, in process
     return self.handle()
   File "/usr/lib/python2.4/site-packages/web.py-0.32-py2.4.egg/web/ 
application.py", line 233, in handle
     return self._delegate(fn, self.fvars, args)
   File "/usr/lib/python2.4/site-packages/web.py-0.32-py2.4.egg/web/ 
application.py", line 412, in _delegate
     return handle_class(cls)
   File "/usr/lib/python2.4/site-packages/web.py-0.32-py2.4.egg/web/ 
application.py", line 387, in handle_class
     return tocall(*args)
   File "/var/www/iredadmin/controllers/ldap/base.py", line 23, in  
proxyfunc
     return func(self, *args, **kw)
   File "/var/www/iredadmin/controllers/ldap/user.py", line 106, in POST
     data=i,
   File "/var/www/iredadmin/libs/ldaplib/core.py", line 149, in  
proxyfunc
     return func(self, *args, **kw)
   File "/var/www/iredadmin/libs/ldaplib/user.py", line 165, in update
     self.conn.modify_s(self.dn, [(ldap.MOD_DELETE, 'enabledService',  
'forward')])
   File "/usr/lib/python2.4/site-packages/python_ldap-2.3.9-py2.4- 
linux-x86_64.egg/ldap/ldapobject.py", line 328, in modify_s
     return self.result(msgid,all=1,timeout=self.timeout)
   File "/usr/lib/python2.4/site-packages/python_ldap-2.3.9-py2.4- 
linux-x86_64.egg/ldap/ldapobject.py", line 428, in result
     res_type,res_data,res_msgid = self.result2(msgid,all,timeout)
   File "/usr/lib/python2.4/site-packages/python_ldap-2.3.9-py2.4- 
linux-x86_64.egg/ldap/ldapobject.py", line 432, in result2
     res_type, res_data, res_msgid, srv_ctrls = self.result3 
(msgid,all,timeout)
   File "/usr/lib/python2.4/site-packages/python_ldap-2.3.9-py2.4- 
linux-x86_64.egg/ldap/ldapobject.py", line 438, in result3
     ldap_result = self._ldap_call(self._l.result3,msgid,all,timeout)
   File "/usr/lib/python2.4/site-packages/python_ldap-2.3.9-py2.4- 
linux-x86_64.egg/ldap/ldapobject.py", line 96, in _ldap_call
     result = func(*args,**kwargs)
NO_SUCH_ATTRIBUTE: {'info': 'modify/delete: enabledService: no such  
value', 'desc': 'No such attribute'}

*** ldap://127.0.0.1:389 - SimpleLDAPObject.unbind_ext ((None, None),{})
192.168.6.1:49306 - - [28/Jun/2009 14:42:21] "HTTP/1.1 POST /profile/user/forwarding/test22 at a.cn 
" - 500 Internal Server Error
----------

-- 
Best Regards.

Zhang Huangbin

- Open Source Mail Server Solution for Red Hat(R) Enterprise Linux,
   CentOS, Debian, Ubuntu: http://www.iredmail.org/





More information about the python-ldap mailing list