diff --git a/doc/reference.xml b/doc/reference.xml index ae397cf..29e8781 100644 --- a/doc/reference.xml +++ b/doc/reference.xml @@ -346,7 +346,7 @@ The return value of search() is a list of 2-tuples. Each tuple consists of a distinguished name and a dictionary of attributes. The dictionary has string keys (the attribute names) and a list of strings - as it values (the attribute values). + or bytes as it values (the attribute values). @@ -360,9 +360,9 @@ attribute to be added. The parameter attrs specifies the attributes of the object. It must be a list of 2-tuples, with the first tuple entry the attribute name, and the second tuple entry a list of strings - containing the attribute values. The server parameter - can be used to override the default binding behaviour and has the same - meaning as for search(). + or bytes containing the attribute values. The server + parameter can be used to override the default binding behaviour and has the + same meaning as for search(). @@ -380,8 +380,8 @@ or delete an attribute value respectively -- the Python-LDAP MOD_* constants are supported for compatibility), the attribute name, and the attribute value. The latter must be a list of - strings. The server parameter can be used to override - the default binding behaviour and has the same meaning as for + strings or bytes. The server parameter can be used + to override the default binding behaviour and has the same meaning as for search(). diff --git a/lib/activedirectory/core/client.py b/lib/activedirectory/core/client.py index 3f93dbd..616f687 100644 --- a/lib/activedirectory/core/client.py +++ b/lib/activedirectory/core/client.py @@ -356,10 +356,10 @@ def _fixup_attrs(self, attrs): pass elif isinstance(attrs, list) or isinstance(attrs, tuple): for item in attrs: - if not isinstance(item, str): - raise TypeError('Expecting sequence of strings.') + if not isinstance(item, str) and not isinstance(item, bytes): + raise TypeError('Expecting sequence of strings or bytes.') else: - raise TypeError('Expecting sequence of strings.') + raise TypeError('Expecting sequence of strings or bytes.') return attrs def _search_with_paged_results(self, conn, filter, base, scope, attrs): @@ -429,12 +429,12 @@ def _fixup_add_list(self, attrs): raise TypeError('Expecting list of 2-tuples.') for type,values in attrs: if not isinstance(type, str): - raise TypeError('List items must be 2-tuple of (str, [str]).') + raise TypeError('List items must be 2-tuple of (str, [str|bytes]).') if not isinstance(values, list) and not isinstance(values, tuple): - raise TypeError('List items must be 2-tuple of (str, [str]).') + raise TypeError('List items must be 2-tuple of (str, [str|bytes]).') for val in values: - if not isinstance(val, str): - raise TypeError('List items must be 2-tuple of (str, [str]).') + if not isinstance(val, str) and not isinstance(val, bytes): + raise TypeError('List items must be 2-tuple of (str, [str|bytes]).') return attrs def add(self, dn, attrs, server=None): @@ -474,12 +474,12 @@ def _fixup_modify_list(self, mods): for op,type,values in mods: op = self._fixup_modify_operation(op) if not isinstance(type, str): - raise TypeError('List items must be 3-tuple of (str, str, [str]).') + raise TypeError('List items must be 3-tuple of (str, str, [str|bytes]).') if not isinstance(values, list) and not isinstance(values, tuple): - raise TypeError('List items must be 3-tuple of (str, str, [str]).') + raise TypeError('List items must be 3-tuple of (str, str, [str|bytes]).') for val in values: - if not isinstance(val, str): - raise TypeError('List item must be 3-tuple of (str, str, [str]).') + if not isinstance(val, str) and not isinstance(val, bytes): + raise TypeError('List item must be 3-tuple of (str, str, [str|bytes]).') result.append((op,type,values)) return result diff --git a/setup.py b/setup.py index c38c2ac..806ff76 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='python-active-directory', - version='2.0.0', + version='2.0.1', description='An Active Directory client library for Python', long_description=open('README.rst').read(), long_description_content_type='text/x-rst',