[Freeipa-devel] [PATCH] Handle LDAP exceptions better

Rob Crittenden rcritten at redhat.com
Mon Aug 27 18:24:37 UTC 2007


Kevin McCarthy wrote:
> Rob Crittenden wrote:
>> LDAP exception strings were lost in the conversion to Faults over XML-RPC. 
>> This includes the LDAP error string within the IPA one.
>>
>> Als oneed to put a try/except around attempts to determine user uniqueness.
> 
> Looks good.  There is a funny character in the patch below though:
> 
>> # HG changeset patch
>> # User rcritten at redhat.com
>> # Date 1188236728 14400
>> # Node ID e340b4ad049faa1545871d1169c01cc751aa5d8b
>> # Parent  655d8fb84fa886a54fd31668c842ebaf685c3c60
>> Include any LDAP error strings in XML-RPC Fault exceptions
>> Put a try/except around attempts to determine user uniqueness
>>
>> diff -r 655d8fb84fa8 -r e340b4ad049f ipa-server/xmlrpc-server/funcs.py
>> --- a/ipa-server/xmlrpc-server/funcs.py	Fri Aug 24 10:31:45 2007 -0700
>> +++ b/ipa-server/xmlrpc-server/funcs.py	Mon Aug 27 13:45:28 2007 -0400
>> @@ -192,11 +192,10 @@ class IPAServer:
>>          uid = self.__safe_filter(uid)
>>          filter = "(&(uid=%s)(objectclass=posixAccount))" % uid
>>   
>> -        entry = self.__get_entry(self.basedn, filter, ['dn','uid'], opts)
>> -
>> -        if entry is not None:
>> +        try:
>> +            entry = self.__get_entry(self.basedn, filter, ['dn','uid'], opts)
>>              return 0
>> -        else:
>> +        except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
>>              return 1
>>  
>>      def get_user_by_uid (self, uid, sattrs=None, opts=None):
>> diff -r 655d8fb84fa8 -r e340b4ad049f ipa-server/xmlrpc-server/ipaxmlrpc.py
>> --- a/ipa-server/xmlrpc-server/ipaxmlrpc.py	Fri Aug 24 10:31:45 2007 -0700
>> +++ b/ipa-server/xmlrpc-server/ipaxmlrpc.py	Mon Aug 27 13:45:28 2007 -0400
>> @@ -36,6 +36,7 @@ import ipaserver
>>  import ipaserver
>>  import funcs
>>  from ipa import ipaerror
>> +import ldap
>>  
>>  import string
>>  import base64
>> @@ -150,7 +151,12 @@ class ModXMLRPCRequestHandler(object):
>>              response = dumps(response, methodresponse=1, allow_none=1)
>>          except ipaerror.IPAError, e:
>>              self.traceback = True
>> -            response = dumps(Fault(e.code, str(e)))
>> +
>> +            if (isinstance(e.detail, ldap.LDAPError)):
>> +u               err = ": %s: %s" % (e.detai 
> Achim

l.args[0]['desc'], e.detail.args[0].get('info',''))
>   ^^^
> probably this was a mistake?

Yes, just noticed that myself. I can be replaced with a space.

rob

> 
> 
>> +                response = dumps(Fault(e.code, str(e) + err))
>> +            else:
>> +                response = dumps(Fault(e.code, str(e)))
>>          except:
>>              self.traceback = True
>>              # report exception back to server
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Freeipa-devel mailing list
>> Freeipa-devel at redhat.com
>> https://www.redhat.com/mailman/listinfo/freeipa-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3245 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20070827/d68cb324/attachment.bin>


More information about the Freeipa-devel mailing list