Skip to content
Browse files

test search of binary attribute

  • Loading branch information...
1 parent ee14d87 commit 39a86509048b69e8afb9ff01325c8c6e7e5c8d5c @jensens jensens committed Apr 5, 2012
Showing with 35 additions and 15 deletions.
  1. +9 −11 README.rst
  2. +26 −4 src/node/ext/ldap/_node.rst
View
20 README.rst
@@ -773,21 +773,19 @@ Remove roles::
Character Encoding
------------------
-LDAP (v3 at least, `RFC 2251`_) uses utf8 string encoding. ``LDAPSession`` and
-``LDAPNode`` do the encoding for you. Consider it a bug, if you receive
-anything else than unicode from ``LDAPSession`` or ``LDAPNode``. The
-``LDAPConnector`` and ``LDAPCommunicator`` are encoding-neutral, they do no
-decoding or encoding.
+LDAP (v3 at least, `RFC 2251`_) uses utf8 string encoding only.
+``LDAPNode`` does the encoding for you. Consider it a bug, if you receive
+anything else than unicode from ``LDAPNode``, except attributes configured as
+binary. The ``LDAPSession``, ``LDAPConnector`` and ``LDAPCommunicator`` are
+encoding-neutral, they do no decoding or encoding.
Unicode strings you pass to nodes or sessions are automatically encoded as uft8
-for LDAP. If you feed them ordinary strings they are decoded as utf8 and
-reencoded as utf8 to make sure they are utf8 or compatible, e.g. ascii.
-
-If decoding as utf8 fails, the value is assumed to be binary and left
-unaltered. This is not the final behavior since schema parsing is missing.
+for LDAP, except if configured binary. If you feed them ordinary strings they are
+decoded as utf8 and reencoded as utf8 to make sure they are utf8 or compatible,
+e.g. ascii.
If you have an LDAP server that does not use utf8, monkey-patch
-``node.ext.ldap._node.CHARACTER_ENCODING``.
+``node.ext.ldap._node.CHARACTER_ENCODING``.
Caching Support
View
30 src/node/ext/ldap/_node.rst
@@ -123,6 +123,9 @@ Customer has not been changed::
>>> customers.changed
False
+Binary Data
+-----------
+
Access existing binary data::
>>> binnode = root['ou=customers']['uid=binary']
@@ -145,7 +148,7 @@ Change binary data::
>>> binnode = customers['uid=binary']
>>> binnode.attrs['jpegPhoto'] == jpegdata
True
-
+
Create New Node
---------------
@@ -799,6 +802,10 @@ Invalidate changed child fails::
...
RuntimeError: Invalid tree state. Try to invalidate changed child node 'ou=customer2'.
+
+Search
+------
+
Test search function::
>>> from node.ext.ldap.scope import ONELEVEL, SUBTREE
@@ -987,6 +994,22 @@ Test relation filter::
u'ou=customer2',
u'ou=n\xe4sty\\, customer']
+
+Search with binary in attrlist::
+
+ >>> node = LDAPNode('dc=my-domain,dc=com', props)
+ >>> node.search_scope = SUBTREE
+ >>> node.search(attrlist=['jpegPhoto'])
+ [(u'dc=my-domain', {}), (u'ou=customers', {}),
+ (u'ou=customer1', {}), (u'ou=customer2', {}),
+ (u'ou=n\xe4sty\\, customer', {}),
+ (u'ou=demo', {}),
+ (u'uid=binary', {u'jpegPhoto': ['\xff\xd8\xff\xe0\x00\x10JFIF...']}),
+ (u'ou=customer3', {}), (u'cn=customer99', {})]
+
+Secondary Keys
+--------------
+
Secondary keys and child DN's.
Note: Setting the DN as seckey only seem to work because it is returned by LDAP
@@ -1093,9 +1116,8 @@ Note -> if seckey attr is missing on LDAP entry, entry is skipped::
>>> print tmp._seckeys
None
-###########################
-Experimental features below
-###########################
+Experimental features
+---------------------
Using some other attribute as key, instead of the RDN. Let's first add two
person's the way we know it::

0 comments on commit 39a8650

Please sign in to comment.
Something went wrong with that request. Please try again.