Test LDAP Session.

Create ``LDAPServerProperties`` instance.
::

    >>> from bda.ldap import BASE, ONELEVEL, SUBTREE
    >>> from bda.ldap import LDAPProps, LDAPSession
    >>> props = LDAPProps("127.0.0.1",
    ...                   12345,
    ...                   "cn=Manager,dc=my-domain,dc=com",
    ...                   "secret",
    ...                   False)

Create the session with ``LDAPServerProperties`` as argument.

    >>> session = LDAPSession(props)
    >>> session.checkServerProperties()
    (True, 'OK')

There's no search base DN set yet.
:: 

    >>> session.baseDN
    u''
    
Set a baseDN and perform LDAP search.
::
  
    >>> session.baseDN = 'dc=my-domain,dc=com'
    >>> from bda.ldap import SUBTREE
    >>> res = session.search('(objectClass=*)', SUBTREE)
    >>> len(res)
    5

Add an entry.
::

    >>> entry = {
    ...     'cn':'foo',
    ...     'sn':'bar',
    ...     'objectclass':('person', 'top'),
    ... }
    >>> dn = 'cn=foo,ou=customer1,ou=customers,dc=my-domain,dc=com'
    >>> session.add(dn, entry)
    >>> res = session.search('(objectClass=*)', SUBTREE)
    >>> len(res)
    6

Modify this entry and check the result.
::

    >>> res = session.search('(cn=foo)', SUBTREE)
    >>> res
    [(u'cn=foo,ou=customer1,ou=customers,dc=my-domain,dc=com', 
    {u'objectClass': [u'person', u'top'], u'cn': [u'foo'], u'sn': [u'bar']})]

    >>> from ldap import MOD_REPLACE
    >>> session.modify(res[0][0], [(MOD_REPLACE, 'sn', 'baz')])
    >>> res = session.search('(cn=foo)', SUBTREE)
    >>> res
    [(u'cn=foo,ou=customer1,ou=customers,dc=my-domain,dc=com', 
    {u'objectClass': [u'person', u'top'], u'cn': [u'foo'], u'sn': [u'baz']})]

Query only specific attributes.
::

    >>> res = session.search('(cn=foo)', SUBTREE, attrlist=('sn',))
    >>> res
    [(u'cn=foo,ou=customer1,ou=customers,dc=my-domain,dc=com', {u'sn': [u'baz']})]

And only the attributes without the values.
::

    >>> res = session.search('(cn=foo)', SUBTREE, attrlist=('sn',), attrsonly=True)
    >>> res
    [(u'cn=foo,ou=customer1,ou=customers,dc=my-domain,dc=com', {u'sn': []})]

Delete this entry and check the result.
::

    >>> session.delete(res[0][0])
    >>> session.search('(cn=foo)', SUBTREE)
    []

Unbind from Server.
::

    >>> session.unbind()
