py3: ipaldap: properly encode DNSName to bytes

The encode method of LDAPClient didn't return DNSName as bytes but
string in py3. In py2 it returns non-unicode string so it can be encoded
safely by ascii as to_text() method returns only ascii characters.

https://fedorahosted.org/freeipa/ticket/4985

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Martin Basti 2017-02-06 18:42:08 +01:00 committed by Jan Cholasta
parent a584758cfb
commit ab53d80883

View File

@ -849,7 +849,7 @@ class LDAPClient(object):
Principal)):
return six.text_type(val).encode('utf-8')
elif isinstance(val, DNSName):
return val.to_text()
return val.to_text().encode('ascii')
elif isinstance(val, bytes):
return val
elif isinstance(val, list):