From e306a2d4dc226eb7539ff935cfc4f89aca4bef3e Mon Sep 17 00:00:00 2001
From: Akshay Adhikari <aadhikar@redhat.com>
Date: Apr 18 2018 09:52:51 +0000
Subject: Issue 49586 - Add py3 support to plugins test suite


Description: Added py3 support by explicitly changing strings to bytes.
Added code for creating a new connection to make ldap communicate on localhost.

https://pagure.io/389-ds-base/issue/49586

Reviewed by: spichugi

---

diff --git a/dirsrvtests/tests/suites/plugins/accpol_test.py b/dirsrvtests/tests/suites/plugins/accpol_test.py
index 2539bc0..b6de0e6 100644
--- a/dirsrvtests/tests/suites/plugins/accpol_test.py
+++ b/dirsrvtests/tests/suites/plugins/accpol_test.py
@@ -33,13 +33,13 @@ def accpol_global(topology_st, request):
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     try:
         topology_st.standalone.plugins.enable(name=PLUGIN_ACCT_POLICY)
-        topology_st.standalone.modify_s(ACCPOL_DN, [(ldap.MOD_REPLACE, 'nsslapd-pluginarg0', ACCP_CONF)])
-        topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'alwaysrecordlogin', 'yes')])
-        topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'stateattrname', 'lastLoginTime')])
-        topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'altstateattrname', 'createTimestamp')])
-        topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'specattrname', 'acctPolicySubentry')])
-        topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'limitattrname', 'accountInactivityLimit')])
-        topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'accountInactivityLimit', '12')])
+        topology_st.standalone.modify_s(ACCPOL_DN, [(ldap.MOD_REPLACE, 'nsslapd-pluginarg0', ensure_bytes(ACCP_CONF))])
+        topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'alwaysrecordlogin', b'yes')])
+        topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'stateattrname', b'lastLoginTime')])
+        topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'altstateattrname', b'createTimestamp')])
+        topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'specattrname', b'acctPolicySubentry')])
+        topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'limitattrname', b'accountInactivityLimit')])
+        topology_st.standalone.modify_s(ACCP_CONF, [(ldap.MOD_REPLACE, 'accountInactivityLimit', b'12')])
         topology_st.standalone.config.set('passwordexp', 'on')
         topology_st.standalone.config.set('passwordmaxage', '400')
         topology_st.standalone.config.set('passwordwarning', '1')
@@ -136,14 +136,14 @@ def userpw_reset(topology_st, suffix, subtree, userid, nousrs, bindusr, bindpw, 
         if (bindusr == "DirMgr"):
             topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
             try:
-                topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, 'userPassword', newpasw)])
+                topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, 'userPassword', ensure_bytes(newpasw))])
             except ldap.LDAPError as e:
                 log.error('Unable to reset userPassword for user-{}'.format(userdn))
                 raise e
         elif (bindusr == "RegUsr"):
             topology_st.standalone.simple_bind_s(userdn, bindpw)
             try:
-                topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, 'userPassword', newpasw)])
+                topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, 'userPassword', ensure_bytes(newpasw))])
             except ldap.LDAPError as e:
                 log.error('Unable to reset userPassword for user-{}'.format(userdn))
                 raise e
@@ -173,7 +173,7 @@ def nsact_inact(topology_st, suffix, subtree, userid, nousrs, command, expected)
             except subprocess.CalledProcessError as err:
                 output = err.output
         log.info('output: {}'.format(output))
-        assert expected in output
+        assert ensure_bytes(expected) in output
         nousrs = nousrs - 1
         time.sleep(1)
 
@@ -184,7 +184,7 @@ def modify_attr(topology_st, base_dn, attr_name, attr_val):
     log.info('Modify attribute value for a given DN')
     topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     try:
-        topology_st.standalone.modify_s(base_dn, [(ldap.MOD_REPLACE, attr_name, attr_val)])
+        topology_st.standalone.modify_s(base_dn, [(ldap.MOD_REPLACE, attr_name, ensure_bytes(attr_val))])
     except ldap.LDAPError as e:
         log.error('Failed to replace lastLoginTime attribute for user-{} {}'.format(userdn, e.message['desc']))
         assert False
@@ -217,7 +217,7 @@ def add_time_attr(topology_st, suffix, subtree, userid, nousrs, attr_name):
         usrrdn = '{}{}'.format(userid, nousrs)
         userdn = 'uid={},{},{}'.format(usrrdn, subtree, suffix)
         try:
-            topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, attr_name, new_attr_val)])
+            topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, attr_name, ensure_bytes(new_attr_val))])
         except ldap.LDAPError as e:
             log.error('Failed to add/replace {} attribute to-{}, for user-{}'.format(attr_name, new_attr_val, userdn))
             raise e
@@ -235,7 +235,7 @@ def modusr_attr(topology_st, suffix, subtree, userid, nousrs, attr_name, attr_va
         usrrdn = '{}{}'.format(userid, nousrs)
         userdn = 'uid={},{},{}'.format(usrrdn, subtree, suffix)
         try:
-            topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, attr_name, attr_value)])
+            topology_st.standalone.modify_s(userdn, [(ldap.MOD_REPLACE, attr_name, ensure_bytes(attr_value))])
         except ldap.LDAPError as e:
             log.error('Failed to add/replace {} attribute to-{}, for user-{}'.format(attr_name, attr_value, userdn))
             raise e
diff --git a/dirsrvtests/tests/suites/plugins/attr_uniqueness_test.py b/dirsrvtests/tests/suites/plugins/attr_uniqueness_test.py
index 7b80667..f9905f9 100644
--- a/dirsrvtests/tests/suites/plugins/attr_uniqueness_test.py
+++ b/dirsrvtests/tests/suites/plugins/attr_uniqueness_test.py
@@ -24,7 +24,7 @@ def test_attr_uniqueness_init(topology_st):
     Enable dynamic plugins - makes things easier
     '''
     try:
-        topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', 'on')])
+        topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', b'on')])
     except ldap.LDAPError as e:
         log.fatal('Failed to enable dynamic plugin!' + e.message['desc'])
         assert False
@@ -40,7 +40,7 @@ def test_attr_uniqueness(topology_st):
     #
     try:
         topology_st.standalone.modify_s('cn=' + PLUGIN_ATTR_UNIQUENESS + ',cn=plugins,cn=config',
-                                        [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', 'uid')])
+                                        [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', b'uid')])
 
     except ldap.LDAPError as e:
         log.fatal('test_attr_uniqueness: Failed to configure plugin for "uid": error ' + e.message['desc'])
@@ -78,7 +78,7 @@ def test_attr_uniqueness(topology_st):
     #
     try:
         topology_st.standalone.modify_s('cn=' + PLUGIN_ATTR_UNIQUENESS + ',cn=plugins,cn=config',
-                                        [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', 'mail')])
+                                        [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', b'mail')])
 
     except ldap.LDAPError as e:
         log.fatal('test_attr_uniqueness: Failed to configure plugin for "mail": error ' + e.message['desc'])
@@ -105,9 +105,9 @@ def test_attr_uniqueness(topology_st):
     #
     try:
         topology_st.standalone.modify_s('cn=' + PLUGIN_ATTR_UNIQUENESS + ',cn=plugins,cn=config',
-                                        [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', 'mail'),
+                                        [(ldap.MOD_REPLACE, 'uniqueness-attribute-name', b'mail'),
                                          (ldap.MOD_ADD, 'uniqueness-attribute-name',
-                                          'mailAlternateAddress')])
+                                          b'mailAlternateAddress')])
     except ldap.LDAPError as e:
         log.error('test_attr_uniqueness: Failed to reconfigure plugin for "mail mailAlternateAddress": error ' +
                   e.message['desc'])
diff --git a/dirsrvtests/tests/suites/plugins/dna_test.py b/dirsrvtests/tests/suites/plugins/dna_test.py
index e084cdd..370867e 100644
--- a/dirsrvtests/tests/suites/plugins/dna_test.py
+++ b/dirsrvtests/tests/suites/plugins/dna_test.py
@@ -58,8 +58,8 @@ def test_basic(topology_st):
         })))
     except ldap.ALREADY_EXISTS:
         try:
-            topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'dnaNextValue', '1'),
-                                                        (ldap.MOD_REPLACE, 'dnaMagicRegen', '-1')])
+            topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'dnaNextValue', b'1'),
+                                                        (ldap.MOD_REPLACE, 'dnaMagicRegen', b'-1')])
         except ldap.LDAPError as e:
             log.fatal('test_dna: Failed to set the DNA plugin: error ' + e.message['desc'])
             assert False
@@ -96,7 +96,7 @@ def test_basic(topology_st):
 
     # Test the magic regen value
     try:
-        topology_st.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'uidNumber', '-1')])
+        topology_st.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'uidNumber', b'-1')])
     except ldap.LDAPError as e:
         log.fatal('test_dna: Failed to set the magic reg value: error ' + e.message['desc'])
         assert False
@@ -116,7 +116,7 @@ def test_basic(topology_st):
     ################################################################################
 
     try:
-        topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'dnaMagicRegen', '-2')])
+        topology_st.standalone.modify_s(CONFIG_DN, [(ldap.MOD_REPLACE, 'dnaMagicRegen', b'-2')])
     except ldap.LDAPError as e:
         log.fatal('test_dna: Failed to set the magic reg value to -2: error ' + e.message['desc'])
         assert False
@@ -127,7 +127,7 @@ def test_basic(topology_st):
 
     # Test the magic regen value
     try:
-        topology_st.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'uidNumber', '-2')])
+        topology_st.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'uidNumber', b'-2')])
     except ldap.LDAPError as e:
         log.fatal('test_dna: Failed to set the magic reg value: error ' + e.message['desc'])
         assert False
diff --git a/dirsrvtests/tests/suites/plugins/memberof_test.py b/dirsrvtests/tests/suites/plugins/memberof_test.py
index 4958a3c..882f557 100644
--- a/dirsrvtests/tests/suites/plugins/memberof_test.py
+++ b/dirsrvtests/tests/suites/plugins/memberof_test.py
@@ -37,84 +37,82 @@ def _set_memberofgroupattr_add(topology_st, values):
     topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN,
                                     [(ldap.MOD_ADD,
                                       PLUGIN_MEMBEROF_GRP_ATTR,
-                                      values)])
+                                      ensure_bytes(values))])
 
 
 def _get_user_rdn(ext):
-    return "uid=%s_%s" % (USER_RDN, ext)
-
+    return ensure_bytes("uid=%s_%s" % (USER_RDN, ext))
 
 def _get_user_dn(ext):
-    return "%s,%s" % (_get_user_rdn(ext), USERS_CONTAINER)
+    return ensure_bytes("%s,%s" % (ensure_str(_get_user_rdn(ext)), USERS_CONTAINER))
 
 
 def _get_group_rdn(ext):
-    return "cn=%s_%s" % (GROUP_RDN, ext)
+    return ensure_bytes("cn=%s_%s" % (GROUP_RDN, ext))
 
 
 def _get_group_dn(ext):
-    return "%s,%s" % (_get_group_rdn(ext), GROUPS_CONTAINER)
+    return ensure_bytes("%s,%s" % (ensure_str(_get_group_rdn(ext)), GROUPS_CONTAINER))
 
 
 def _create_user(topology_st, ext):
-    user_dn = _get_user_dn(ext)
+    user_dn = ensure_str(_get_user_dn(ext))
     topology_st.standalone.add_s(Entry((user_dn, {
         'objectclass': 'top extensibleObject'.split(),
-        'uid': _get_user_rdn(ext)
+        'uid': ensure_str(_get_user_rdn(ext))
     })))
     log.info("Create user %s" % user_dn)
-    return user_dn
+    return ensure_bytes(user_dn)
 
 
 def _delete_user(topology_st, ext):
-    user_dn = _get_user_dn(ext)
+    user_dn = ensure_str(_get_user_dn(ext))
     topology_st.standalone.delete_s(user_dn)
     log.info("Delete user %s" % user_dn)
 
 
 def _create_group(topology_st, ext):
-    group_dn = _get_group_dn(ext)
+    group_dn = ensure_str(_get_group_dn(ext))
     topology_st.standalone.add_s(Entry((group_dn, {
         'objectclass': 'top groupOfNames groupOfUniqueNames extensibleObject'.split(),
-        'ou': _get_group_rdn(ext)
+        'ou': ensure_str(_get_group_rdn(ext))
     })))
     log.info("Create group %s" % group_dn)
-    return group_dn
+    return ensure_bytes(group_dn)
 
 
 def _delete_group(topology_st, ext):
-    group_dn = _get_group_dn(ext)
+    group_dn = ensure_str(_get_group_dn(ext))
     topology_st.standalone.delete_s(group_dn)
     log.info("Delete group %s" % group_dn)
 
 
 def _check_memberattr(topology_st, entry, memberattr, value):
     log.info("Check %s.%s = %s" % (entry, memberattr, value))
-    entry = topology_st.standalone.getEntry(entry, ldap.SCOPE_BASE, '(objectclass=*)', [memberattr])
-    assert entry
-    if not entry.hasAttr(memberattr):
+    entry = topology_st.standalone.getEntry(ensure_str(entry), ldap.SCOPE_BASE, '(objectclass=*)', [memberattr])
+    if not entry.hasAttr(ensure_str(memberattr)):
         return False
 
     found = False
-    for val in entry.getValues(memberattr):
-        log.info("%s: %s" % (memberattr, val))
-        if value.lower() == val.lower():
+    for val in entry.getValues(ensure_str(memberattr)):
+        log.info("%s: %s" % (memberattr, ensure_str(val)))
+        if ensure_str(value.lower()) == ensure_str(val.lower()):
             found = True
             break
     return found
 
 
+
 def _check_memberof(topology_st, member, group):
     log.info("Lookup memberof from %s" % member)
-    entry = topology_st.standalone.getEntry(member, ldap.SCOPE_BASE, '(objectclass=*)', ['memberof'])
-    assert entry
+    entry = topology_st.standalone.getEntry(ensure_str(member), ldap.SCOPE_BASE, '(objectclass=*)', ['memberof'])
     if not entry.hasAttr('memberof'):
         return False
 
     found = False
     for val in entry.getValues('memberof'):
-        log.info("memberof: %s" % val)
-        if group.lower() == val.lower():
+        log.info("memberof: %s" % ensure_str(val))
+        if ensure_str(group.lower()) == ensure_str(val.lower()):
             found = True
             log.info("--> membership verified")
             break
@@ -128,7 +126,21 @@ def text_memberof_683241_01(topology_st):
     topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN,
                                     [(ldap.MOD_REPLACE,
                                       PLUGIN_TYPE,
-                                      'betxnpostoperation')])
+                                      b'betxnpostoperation')])
+    topology_st.standalone.restart()
+    ent = topology_st.standalone.getEntry(MEMBEROF_PLUGIN_DN, ldap.SCOPE_BASE, "(objectclass=*)", [PLUGIN_TYPE])
+    assert ent.hasAttr(PLUGIN_TYPE)
+    assert ent.getValue(PLUGIN_TYPE) == 'betxnpostoperation'
+
+
+def text_memberof_683241_01(topology_st):
+    """
+    Test Modify the memberof plugin to use the new type
+    """
+    topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN,
+                                    [(ldap.MOD_REPLACE,
+                                      PLUGIN_TYPE,
+                                      b'betxnpostoperation')])
     topology_st.standalone.restart()
     ent = topology_st.standalone.getEntry(MEMBEROF_PLUGIN_DN, ldap.SCOPE_BASE, "(objectclass=*)", [PLUGIN_TYPE])
     assert ent.hasAttr(PLUGIN_TYPE)
@@ -143,8 +155,8 @@ def test_memberof_MultiGrpAttr_001(topology_st):
     ent = topology_st.standalone.getEntry(MEMBEROF_PLUGIN_DN, ldap.SCOPE_BASE, "(objectclass=*)",
                                           [PLUGIN_MEMBEROF_GRP_ATTR])
     assert ent.hasAttr(PLUGIN_MEMBEROF_GRP_ATTR)
-    assert 'member'.lower() in [x.lower() for x in ent.getValues(PLUGIN_MEMBEROF_GRP_ATTR)]
-    assert 'uniqueMember'.lower() in [x.lower() for x in ent.getValues(PLUGIN_MEMBEROF_GRP_ATTR)]
+    assert b'member'.lower() in [x.lower() for x in ent.getValues(PLUGIN_MEMBEROF_GRP_ATTR)]
+    assert b'uniqueMember'.lower() in [x.lower() for x in ent.getValues(PLUGIN_MEMBEROF_GRP_ATTR)]
 
 
 def test_memberof_MultiGrpAttr_003(topology_st):
@@ -156,7 +168,7 @@ def test_memberof_MultiGrpAttr_003(topology_st):
     topology_st.standalone.restart()
     ent = topology_st.standalone.getEntry(MEMBEROF_PLUGIN_DN, ldap.SCOPE_BASE, "(objectclass=*)", [PLUGIN_ENABLED])
     assert ent.hasAttr(PLUGIN_ENABLED)
-    assert ent.getValue(PLUGIN_ENABLED).lower() == 'on'
+    assert ent.getValue(PLUGIN_ENABLED).lower() == b'on'
 
 
 def test_memberof_MultiGrpAttr_004(topology_st):
@@ -172,11 +184,11 @@ def test_memberof_MultiGrpAttr_004(topology_st):
     mods = [(ldap.MOD_ADD, 'member', memofenh1), (ldap.MOD_ADD, 'uniqueMember', memofenh2)]
     log.info("Update %s is memberof %s (member)" % (memofenh1, memofegrp1))
     log.info("Update %s is memberof %s (uniqueMember)" % (memofenh2, memofegrp1))
-    topology_st.standalone.modify_s(memofegrp1, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp1), mods)
 
     log.info("Update %s is memberof %s (member)" % (memofenh1, memofegrp2))
     log.info("Update %s is memberof %s (uniqueMember)" % (memofenh2, memofegrp2))
-    topology_st.standalone.modify_s(memofegrp2, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp2), mods)
 
     # assert enh1 is member of grp1 and grp2
     assert _check_memberof(topology_st, member=memofenh1, group=memofegrp1)
@@ -196,10 +208,9 @@ def test_memberof_MultiGrpAttr_005(topology_st):
 
     memofegrp1 = _get_group_dn('memofegrp1')
     memofegrp2 = _get_group_dn('memofegrp2')
-
     log.info("Update %s is no longer memberof %s (member)" % (memofenh1, memofegrp1))
     mods = [(ldap.MOD_DELETE, 'member', memofenh1)]
-    topology_st.standalone.modify_s(memofegrp1, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp1), mods)
 
     # assert enh1 is NOT member of grp1 and  is member of grp2
     assert not _check_memberof(topology_st, member=memofenh1, group=memofegrp1)
@@ -222,7 +233,7 @@ def test_memberof_MultiGrpAttr_006(topology_st):
 
     log.info("Update %s is no longer memberof %s (uniqueMember)" % (memofenh1, memofegrp1))
     mods = [(ldap.MOD_DELETE, 'uniqueMember', memofenh2)]
-    topology_st.standalone.modify_s(memofegrp2, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp2), mods)
 
     # assert enh1 is NOT member of grp1 and  is member of grp2
     assert not _check_memberof(topology_st, member=memofenh1, group=memofegrp1)
@@ -245,11 +256,11 @@ def test_memberof_MultiGrpAttr_007(topology_st):
 
     log.info("Update %s is no longer memberof %s (uniqueMember)" % (memofenh2, memofegrp1))
     mods = [(ldap.MOD_DELETE, 'uniqueMember', memofenh2)]
-    topology_st.standalone.modify_s(memofegrp1, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp1), mods)
 
     log.info("Update %s is no longer memberof %s (member)" % (memofenh1, memofegrp2))
     mods = [(ldap.MOD_DELETE, 'member', memofenh1)]
-    topology_st.standalone.modify_s(memofegrp2, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp2), mods)
 
     # assert enh1 is NOT member of grp1 and  is member of grp2
     assert not _check_memberof(topology_st, member=memofenh1, group=memofegrp1)
@@ -272,11 +283,11 @@ def test_memberof_MultiGrpAttr_008(topology_st):
 
     mods = [(ldap.MOD_ADD, 'member', memofenh1)]
     log.info("Update %s is memberof %s (member)" % (memofenh1, memofegrp1))
-    topology_st.standalone.modify_s(memofegrp1, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp1), mods)
 
     mods = [(ldap.MOD_ADD, 'uniqueMember', memofenh2)]
     log.info("Update %s is memberof %s (uniqueMember)" % (memofenh2, memofegrp2))
-    topology_st.standalone.modify_s(memofegrp2, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp2), mods)
 
     # assert enh1 is member of grp1 and  is NOT member of grp2
     assert _check_memberof(topology_st, member=memofenh1, group=memofegrp1)
@@ -290,7 +301,7 @@ def test_memberof_MultiGrpAttr_008(topology_st):
     topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN,
                                     [(ldap.MOD_DELETE,
                                       PLUGIN_MEMBEROF_GRP_ATTR,
-                                      ['uniqueMember'])])
+                                      [b'uniqueMember'])])
     topology_st.standalone.restart()
 
     log.info("Assert that this change of configuration did change the already set values")
@@ -336,7 +347,7 @@ def test_memberof_MultiGrpAttr_010(topology_st):
     mods = [(ldap.MOD_ADD, 'member', memofenh1)]
     log.info("Try %s is memberof %s (member)" % (memofenh1, memofegrp1))
     try:
-        topology_st.standalone.modify_s(memofegrp1, mods)
+        topology_st.standalone.modify_s(ensure_str(memofegrp1), mods)
         log.error(
             "Should not be allowed to add %s member of %s (because it was already member)" % (memofenh1, memofegrp1))
         assert False
@@ -376,7 +387,7 @@ def test_memberof_MultiGrpAttr_011(topology_st):
     mods = [(ldap.MOD_ADD, 'uniqueMember', memofenh2)]
     log.info("Try %s is memberof %s (member)" % (memofenh2, memofegrp2))
     try:
-        topology_st.standalone.modify_s(memofegrp2, mods)
+        topology_st.standalone.modify_s(ensure_str(memofegrp2), mods)
         log.error(
             "Should not be allowed to add %s member of %s (because it was already member)" % (memofenh2, memofegrp2))
         assert False
@@ -473,7 +484,7 @@ def test_memberof_MultiGrpAttr_014(topology_st):
     mods = [(ldap.MOD_ADD, 'member', memofenh1), (ldap.MOD_ADD, 'uniqueMember', memofenh1)]
     log.info("Update %s is memberof %s (member)" % (memofenh1, memofegrp3))
     log.info("Update %s is memberof %s (uniqueMember)" % (memofenh1, memofegrp3))
-    topology_st.standalone.modify_s(memofegrp3, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp3), mods)
 
     # assert enh1 is member of
     #       - grp1 (member)
@@ -485,11 +496,11 @@ def test_memberof_MultiGrpAttr_014(topology_st):
 
     mods = [(ldap.MOD_DELETE, 'member', memofenh1)]
     log.info("Update %s is not memberof %s (member)" % (memofenh1, memofegrp3))
-    topology_st.standalone.modify_s(memofegrp3, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp3), mods)
 
     mods = [(ldap.MOD_ADD, 'member', memofenh2)]
     log.info("Update %s is memberof %s (member)" % (memofenh2, memofegrp3))
-    topology_st.standalone.modify_s(memofegrp3, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp3), mods)
 
     # assert enh1 is member of
     #       - grp1 (member)
@@ -507,13 +518,13 @@ def test_memberof_MultiGrpAttr_014(topology_st):
     assert _check_memberof(topology_st, member=memofenh2, group=memofegrp2)
     assert _check_memberof(topology_st, member=memofenh2, group=memofegrp3)
 
-    ent = topology_st.standalone.getEntry(memofegrp3, ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember'])
+    ent = topology_st.standalone.getEntry(ensure_str(memofegrp3), ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember'])
     assert ent.hasAttr('member')
-    assert memofenh1 not in ent.getValues('member')
-    assert memofenh2 in ent.getValues('member')
+    assert ensure_bytes(memofenh1) not in ent.getValues('member')
+    assert ensure_bytes(memofenh2) in ent.getValues('member')
     assert ent.hasAttr('uniqueMember')
-    assert memofenh1 in ent.getValues('uniqueMember')
-    assert memofenh2 not in ent.getValues('uniqueMember')
+    assert ensure_bytes(memofenh1) in ent.getValues('uniqueMember')
+    assert ensure_bytes(memofenh2) not in ent.getValues('uniqueMember')
 
     log.info("Checking final status")
     # assert enh1 is member of
@@ -593,15 +604,15 @@ def test_memberof_MultiGrpAttr_015(topology_st):
     mods = [(ldap.MOD_ADD, 'member', dummy1), (ldap.MOD_ADD, 'uniqueMember', dummy2)]
     log.info("Update %s is memberof %s (member)" % (dummy1, memofegrp015))
     log.info("Update %s is memberof %s (uniqueMember)" % (dummy2, memofegrp015))
-    topology_st.standalone.modify_s(memofegrp015, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp015), mods)
 
-    ent = topology_st.standalone.getEntry(memofegrp015, ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember'])
+    ent = topology_st.standalone.getEntry(ensure_str(memofegrp015), ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember'])
     assert ent.hasAttr('member')
-    assert dummy1 in ent.getValues('member')
-    assert dummy2 not in ent.getValues('member')
+    assert ensure_bytes(dummy1) in ent.getValues('member')
+    assert ensure_bytes(dummy2) not in ent.getValues('member')
     assert ent.hasAttr('uniqueMember')
-    assert dummy1 not in ent.getValues('uniqueMember')
-    assert dummy2 in ent.getValues('uniqueMember')
+    assert ensure_bytes(dummy1) not in ent.getValues('uniqueMember')
+    assert ensure_bytes(dummy2) in ent.getValues('uniqueMember')
 
     # assert enh1 is member of
     #       - grp1 (member)
@@ -690,7 +701,7 @@ def test_memberof_MultiGrpAttr_016(topology_st):
     mods = [(ldap.MOD_ADD, 'member', memofenh1), (ldap.MOD_ADD, 'uniqueMember', memofenh1)]
     log.info("Update %s is memberof %s (member)" % (memofenh1, memofegrp016))
     log.info("Update %s is memberof %s (uniqueMember)" % (memofenh1, memofegrp016))
-    topology_st.standalone.modify_s(memofegrp016, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp016), mods)
 
     # assert enh1 is member of
     #       - grp1 (member)
@@ -718,23 +729,23 @@ def test_memberof_MultiGrpAttr_016(topology_st):
 
     mods = [(ldap.MOD_ADD, 'member', dummy1), ]
     log.info("Update %s is memberof %s (member)" % (dummy1, memofegrp016))
-    topology_st.standalone.modify_s(memofegrp016, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp016), mods)
 
-    ent = topology_st.standalone.getEntry(memofegrp016, ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember'])
+    ent = topology_st.standalone.getEntry(ensure_str(memofegrp016), ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember'])
     assert ent.hasAttr('member')
-    assert dummy1 in ent.getValues('member')
+    assert ensure_bytes(dummy1) in ent.getValues('member')
     assert ent.hasAttr('uniqueMember')
-    assert dummy1 not in ent.getValues('uniqueMember')
+    assert ensure_bytes(dummy1) not in ent.getValues('uniqueMember')
 
     mods = [(ldap.MOD_ADD, 'uniqueMember', dummy1), ]
     log.info("Update %s is memberof %s (uniqueMember)" % (dummy1, memofegrp016))
-    topology_st.standalone.modify_s(memofegrp016, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp016), mods)
 
-    ent = topology_st.standalone.getEntry(memofegrp016, ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember'])
+    ent = topology_st.standalone.getEntry(ensure_str(memofegrp016), ldap.SCOPE_BASE, "(objectclass=*)", ['member', 'uniqueMember'])
     assert ent.hasAttr('member')
-    assert dummy1 in ent.getValues('member')
+    assert ensure_bytes(dummy1) in ent.getValues('member')
     assert ent.hasAttr('uniqueMember')
-    assert dummy1 in ent.getValues('uniqueMember')
+    assert ensure_bytes(dummy1) in ent.getValues('uniqueMember')
 
     # assert enh1 is member of
     #       - grp1 (member)
@@ -799,7 +810,7 @@ def test_memberof_MultiGrpAttr_017(topology_st):
             - not grp017
 
         user1 is member of
-            - not grp1 
+            - not grp1
             - not grp2
             - not grp3
             - not grp015
@@ -889,7 +900,7 @@ def test_memberof_MultiGrpAttr_017(topology_st):
     log.info("Update %s is memberof %s (member)" % (memofuser1, memofegrp017))
     log.info("Update %s is memberof %s (uniqueMember)" % (memofuser2, memofegrp017))
     log.info("Update %s is memberof %s (memberuid)" % (memofuser3, memofegrp017))
-    topology_st.standalone.modify_s(memofegrp017, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp017), mods)
 
     # assert enh1 is member of
     #       - grp1 (member)
@@ -922,7 +933,7 @@ def test_memberof_MultiGrpAttr_017(topology_st):
     # assert user1 is member of
     #       - not grp1
     #       - not grp2
-    #       - not grp3 
+    #       - not grp3
     #       - not grp15
     #       - not grp16
     #       - grp17 (member)
@@ -936,7 +947,7 @@ def test_memberof_MultiGrpAttr_017(topology_st):
     # assert user2 is member of
     #       - not grp1
     #       - not grp2
-    #       - not grp3 
+    #       - not grp3
     #       - not grp15
     #       - not grp16
     #       - grp17 (uniqueMember)
@@ -950,7 +961,7 @@ def test_memberof_MultiGrpAttr_017(topology_st):
     # assert user3 is member of
     #       - not grp1
     #       - not grp2
-    #       - not grp3 
+    #       - not grp3
     #       - not grp15
     #       - not grp16
     #       - NOT grp17 (memberuid)
@@ -985,7 +996,7 @@ def test_memberof_MultiGrpAttr_018(topology_st):
             - not grp017
 
         user1 is member of
-            - not grp1 
+            - not grp1
             - not grp2
             - not grp3
             - not grp015
@@ -1070,7 +1081,7 @@ def test_memberof_MultiGrpAttr_018(topology_st):
     # assert user1 is member of
     #       - not grp1
     #       - not grp2
-    #       - not grp3 
+    #       - not grp3
     #       - not grp15
     #       - not grp16
     #       - grp17 (member)
@@ -1084,7 +1095,7 @@ def test_memberof_MultiGrpAttr_018(topology_st):
     # assert user2 is member of
     #       - not grp1
     #       - not grp2
-    #       - not grp3 
+    #       - not grp3
     #       - not grp15
     #       - not grp16
     #       - grp17 (uniqueMember)
@@ -1098,7 +1109,7 @@ def test_memberof_MultiGrpAttr_018(topology_st):
     # assert user3 is member of
     #       - not grp1
     #       - not grp2
-    #       - not grp3 
+    #       - not grp3
     #       - not grp15
     #       - not grp16
     #       - NOT grp17 (memberuid)
@@ -1118,12 +1129,12 @@ def test_memberof_MultiGrpAttr_018(topology_st):
     log.info("Update %s is memberof %s (member)" % (memofuser1, memofegrp017))
     log.info("Update %s is memberof %s (uniqueMember)" % (memofuser1, memofegrp017))
     log.info("Update %s is memberof %s (memberuid)" % (memofuser1, memofegrp017))
-    topology_st.standalone.modify_s(memofegrp018, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp018), mods)
 
     # assert user1 is member of
     #       - not grp1
     #       - not grp2
-    #       - not grp3 
+    #       - not grp3
     #       - not grp15
     #       - not grp16
     #       - grp17 (member)
@@ -1139,12 +1150,12 @@ def test_memberof_MultiGrpAttr_018(topology_st):
     mods = [(ldap.MOD_DELETE, 'member', memofuser1), (ldap.MOD_DELETE, 'uniqueMember', memofuser1)]
     log.info("Update %s is no longer memberof %s (member)" % (memofuser1, memofegrp018))
     log.info("Update %s is no longer memberof %s (uniqueMember)" % (memofuser1, memofegrp018))
-    topology_st.standalone.modify_s(memofegrp018, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp018), mods)
 
     # assert user1 is member of
     #       - not grp1
     #       - not grp2
-    #       - not grp3 
+    #       - not grp3
     #       - not grp15
     #       - not grp16
     #       - grp17 (member)
@@ -1158,10 +1169,10 @@ def test_memberof_MultiGrpAttr_018(topology_st):
     assert not _check_memberof(topology_st, member=memofuser1, group=memofegrp018)
 
     # DEL user1, user2, user3, grp17
-    topology_st.standalone.delete_s(memofuser1)
-    topology_st.standalone.delete_s(memofuser2)
-    topology_st.standalone.delete_s(memofuser3)
-    topology_st.standalone.delete_s(memofegrp017)
+    topology_st.standalone.delete_s(ensure_str(memofuser1))
+    topology_st.standalone.delete_s(ensure_str(memofuser2))
+    topology_st.standalone.delete_s(ensure_str(memofuser3))
+    topology_st.standalone.delete_s(ensure_str(memofegrp017))
 
     # assert enh1 is member of
     #       - grp1 (member)
@@ -1198,7 +1209,7 @@ def test_memberof_MultiGrpAttr_019(topology_st):
     Add user3 to grp19_3
     Add grp19_2 and grp_19_3 to grp19_1
 
-    At the beginning:        
+    At the beginning:
         enh1 is member of
             - grp1 (member)
             - not grp2
@@ -1278,26 +1289,26 @@ def test_memberof_MultiGrpAttr_019(topology_st):
     # Create a group grp019_2 with user2 member
     memofegrp019_2 = _create_group(topology_st, 'memofegrp019_2')
     mods = [(ldap.MOD_ADD, 'member', memofuser2)]
-    topology_st.standalone.modify_s(memofegrp019_2, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp019_2), mods)
 
     # Create a group grp019_3 with user3 member
     memofegrp019_3 = _create_group(topology_st, 'memofegrp019_3')
     mods = [(ldap.MOD_ADD, 'member', memofuser3)]
-    topology_st.standalone.modify_s(memofegrp019_3, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp019_3), mods)
 
-    mods = [(ldap.MOD_ADD, 'objectClass', 'inetUser')]
-    topology_st.standalone.modify_s(memofegrp019_2, mods)
-    topology_st.standalone.modify_s(memofegrp019_3, mods)
+    mods = [(ldap.MOD_ADD, 'objectClass', b'inetUser')]
+    topology_st.standalone.modify_s(ensure_str(memofegrp019_2), mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp019_3), mods)
 
     # Create a group grp019_1 with memofegrp019_2, memofegrp019_3 member
     memofegrp019_1 = _create_group(topology_st, 'memofegrp019_1')
     mods = [(ldap.MOD_ADD, 'member', memofegrp019_2), (ldap.MOD_ADD, 'member', memofegrp019_3)]
-    topology_st.standalone.modify_s(memofegrp019_1, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp019_1), mods)
 
     # assert memofegrp019_1 is member of
     #       - not grp1
-    #       - not grp2 
-    #       - not grp3 
+    #       - not grp2
+    #       - not grp3
     #       - not grp15
     #       - not grp16
     #       - not grp018
@@ -1395,11 +1406,11 @@ def test_memberof_MultiGrpAttr_019(topology_st):
     assert _check_memberof(topology_st, member=memofuser3, group=memofegrp019_3)
 
     # DEL user2, user3, grp19*
-    topology_st.standalone.delete_s(memofuser2)
-    topology_st.standalone.delete_s(memofuser3)
-    topology_st.standalone.delete_s(memofegrp019_1)
-    topology_st.standalone.delete_s(memofegrp019_2)
-    topology_st.standalone.delete_s(memofegrp019_3)
+    topology_st.standalone.delete_s(ensure_str(memofuser2))
+    topology_st.standalone.delete_s(ensure_str(memofuser3))
+    topology_st.standalone.delete_s(ensure_str(memofegrp019_1))
+    topology_st.standalone.delete_s(ensure_str(memofegrp019_2))
+    topology_st.standalone.delete_s(ensure_str(memofegrp019_3))
 
     # assert enh1 is member of
     #       - grp1 (member)
@@ -1437,7 +1448,7 @@ def test_memberof_MultiGrpAttr_020(topology_st):
     Add grp[1-4] member of grp5
     Check user1 is member of grp[1-5]
 
-    At the beginning:        
+    At the beginning:
         enh1 is member of
             - grp1 (member)
             - not grp2
@@ -1505,20 +1516,20 @@ def test_memberof_MultiGrpAttr_020(topology_st):
     memofegrp020_3 = _create_group(topology_st, 'memofegrp020_3')
     memofegrp020_4 = _create_group(topology_st, 'memofegrp020_4')
     memofegrp020_5 = _create_group(topology_st, 'memofegrp020_5')
-    mods = [(ldap.MOD_ADD, 'objectClass', 'inetUser')]
+    mods = [(ldap.MOD_ADD, 'objectClass', b'inetUser')]
     for grp in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4, memofegrp020_5]:
-        topology_st.standalone.modify_s(grp, mods)
+        topology_st.standalone.modify_s(ensure_str(grp), mods)
 
     # add user1 to grp[1-4] (uniqueMember)
     mods = [(ldap.MOD_ADD, 'uniqueMember', memofuser1)]
     for grp in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4]:
-        topology_st.standalone.modify_s(grp, mods)
+        topology_st.standalone.modify_s(ensure_str(grp), mods)
 
     # create grp5 with grp[1-4] as member
     mods = []
     for grp in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4]:
         mods.append((ldap.MOD_ADD, 'member', grp))
-    topology_st.standalone.modify_s(memofegrp020_5, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp020_5), mods)
 
     assert _check_memberof(topology_st, member=memofuser1, group=memofegrp020_1)
     assert _check_memberof(topology_st, member=memofuser1, group=memofegrp020_2)
@@ -1527,9 +1538,9 @@ def test_memberof_MultiGrpAttr_020(topology_st):
     assert _check_memberof(topology_st, member=memofuser1, group=memofegrp020_5)
 
     # DEL user1, grp20*
-    topology_st.standalone.delete_s(memofuser1)
+    topology_st.standalone.delete_s(ensure_str(memofuser1))
     for grp in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4, memofegrp020_5]:
-        topology_st.standalone.delete_s(grp)
+        topology_st.standalone.delete_s(ensure_str(grp))
 
 
 def test_memberof_MultiGrpAttr_021(topology_st):
@@ -1542,7 +1553,7 @@ def test_memberof_MultiGrpAttr_021(topology_st):
     Check that user1 is member of Grp1 and Grp5
     check that user* are members of Grp5
 
-    At the beginning:        
+    At the beginning:
         enh1 is member of
             - grp1 (member)
             - not grp2
@@ -1578,7 +1589,7 @@ def test_memberof_MultiGrpAttr_021(topology_st):
            - not grp018
            - not grp20*
 
-        user1 is member of grp20_5 
+        user1 is member of grp20_5
         userX is uniquemember of grp20_X
         grp[1-4] are member of grp20_5
 
@@ -1638,15 +1649,15 @@ def test_memberof_MultiGrpAttr_021(topology_st):
               (memofegrp020_2, memofuser2),
               (memofegrp020_3, memofuser3),
               (memofegrp020_4, memofuser4)]:
-        mods = [(ldap.MOD_ADD, 'objectClass', 'inetUser'), (ldap.MOD_ADD, 'uniqueMember', x[1])]
-        topology_st.standalone.modify_s(x[0], mods)
+        mods = [(ldap.MOD_ADD, 'objectClass', b'inetUser'), (ldap.MOD_ADD, 'uniqueMember', x[1])]
+        topology_st.standalone.modify_s(ensure_str(x[0]), mods)
 
     # create grp5 with grp[1-4] as member + user1
     memofegrp020_5 = _create_group(topology_st, 'memofegrp020_5')
     mods = [(ldap.MOD_ADD, 'member', memofuser1)]
     for grp in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4]:
         mods.append((ldap.MOD_ADD, 'member', grp))
-    topology_st.standalone.modify_s(memofegrp020_5, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp020_5), mods)
 
     # assert user[1-4] are member of grp20_5
     for user in [memofuser1, memofuser2, memofuser3, memofuser4]:
@@ -1722,7 +1733,7 @@ def test_memberof_MultiGrpAttr_022(topology_st):
     add Grp5 as uniquemember of GrpX (this create a loop)
 
 
-    At the beginning:        
+    At the beginning:
         enh1 is member of
            - grp1 (member)
            - not grp2
@@ -1741,7 +1752,7 @@ def test_memberof_MultiGrpAttr_022(topology_st):
            - not grp20*
 
 
-        user1 is member of grp20_5 
+        user1 is member of grp20_5
         userX is uniquemember of grp20_X
         grp[1-4] are member of grp20_5
 
@@ -1866,7 +1877,7 @@ def test_memberof_MultiGrpAttr_022(topology_st):
               (memofegrp020_3, memofuser3),
               (memofegrp020_4, memofuser4)]:
         mods = [(ldap.MOD_ADD, 'member', x[1])]
-        topology_st.standalone.modify_s(x[0], mods)
+        topology_st.standalone.modify_s(ensure_str(x[0]), mods)
 
     # check that user[1-4] are 'member' and 'uniqueMember' of the grp20_[1-4]
     for x in [(memofegrp020_1, memofuser1),
@@ -1876,11 +1887,11 @@ def test_memberof_MultiGrpAttr_022(topology_st):
         assert _check_memberattr(topology_st, x[0], 'uniqueMember', x[1])
         assert _check_memberattr(topology_st, x[0], 'member', x[1])
 
-    # add Grp[1-4] (uniqueMember) to grp5 
+    # add Grp[1-4] (uniqueMember) to grp5
     # it creates a membership loop !!!
     mods = [(ldap.MOD_ADD, 'uniqueMember', memofegrp020_5)]
     for grp in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4]:
-        topology_st.standalone.modify_s(grp, mods)
+        topology_st.standalone.modify_s(ensure_str(grp), mods)
 
     time.sleep(5)
     # assert user[1-4] are member of grp20_[1-4]
@@ -1957,14 +1968,14 @@ def verify_post_023(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3,
           /----member ---> G1 ---uniqueMember -------\
          /                                            V
     G5 ------------------------>member ----------  --->U1
-         | 
+         |
          |----member ---> G2 ---member/uniqueMember -> U2
          |<--uniquemember-/
          |
          |----member ---> G3 ---member/uniqueMember -> U3
-         |<--uniquemember-/                              
+         |<--uniquemember-/
          |----member ---> G4 ---member/uniqueMember -> U4
-         |<--uniquemember-/  
+         |<--uniquemember-/
     """
     for x in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4]:
         assert _check_memberattr(topology_st, memofegrp020_5, 'member', x)
@@ -2003,7 +2014,7 @@ def test_memberof_MultiGrpAttr_023(topology_st):
 
 
 
-    At the beginning:        
+    At the beginning:
        enh1 is member of
            - grp1 (member)
            - not grp2
@@ -2029,14 +2040,14 @@ def test_memberof_MultiGrpAttr_023(topology_st):
           /----member ---> G1 ---member/uniqueMember -\
          /<--uniquemember-                            V
     G5 ------------------------>member ----------  --->U1
-         | 
+         |
          |----member ---> G2 ---member/uniqueMember -> U2
          |<--uniquemember-/
          |
          |----member ---> G3 ---member/uniqueMember -> U3
-         |<--uniquemember-/                              
+         |<--uniquemember-/
          |----member ---> G4 ---member/uniqueMember -> U4
-         |<--uniquemember-/                               
+         |<--uniquemember-/
 
 
 
@@ -2045,14 +2056,14 @@ def test_memberof_MultiGrpAttr_023(topology_st):
           /----member ---> G1 ---uniqueMember -------\
          /                                            V
     G5 ------------------------>member ----------  --->U1
-         | 
+         |
          |----member ---> G2 ---member/uniqueMember -> U2
          |<--uniquemember-/
          |
          |----member ---> G3 ---member/uniqueMember -> U3
-         |<--uniquemember-/                              
+         |<--uniquemember-/
          |----member ---> G4 ---member/uniqueMember -> U4
-         |<--uniquemember-/  
+         |<--uniquemember-/
 
     """
     memofenh1 = _get_user_dn('memofenh1')
@@ -2161,10 +2172,10 @@ def test_memberof_MultiGrpAttr_023(topology_st):
 
     # DEL user1 as 'member' of grp20_1
     mods = [(ldap.MOD_DELETE, 'member', memofuser1)]
-    topology_st.standalone.modify_s(memofegrp020_1, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp020_1), mods)
 
     mods = [(ldap.MOD_DELETE, 'uniqueMember', memofegrp020_5)]
-    topology_st.standalone.modify_s(memofegrp020_1, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp020_1), mods)
 
     """
           /----member ---> G1 ---uniqueMember -------\
@@ -2189,14 +2200,14 @@ def verify_post_024(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3,
           /----member ---> G1 ---member/uniqueMember -\
          /                                             V
     G5 ------------------------>member ----------  --->U1
-         | 
+         |
          |----member ---> G2 ---member/uniqueMember -> U2
          |<--uniquemember-/
          |
          |----member ---> G3 ---member/uniqueMember -> U3
-         |<--uniquemember-/                              
+         |<--uniquemember-/
          |----member ---> G4 ---member/uniqueMember -> U4
-         |<--uniquemember-/  
+         |<--uniquemember-/
     """
     for x in [memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4]:
         assert _check_memberattr(topology_st, memofegrp020_5, 'member', x)
@@ -2231,33 +2242,33 @@ def verify_post_024(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3,
 
 def test_memberof_MultiGrpAttr_024(topology_st):
     """
-    At the beginning:        
+    At the beginning:
 
 
           /----member ---> G1 ---uniqueMember -------\
          /                                            V
     G5 ------------------------>member ----------  --->U1
-         | 
+         |
          |----member ---> G2 ---member/uniqueMember -> U2
          |<--uniquemember-/
          |
          |----member ---> G3 ---member/uniqueMember -> U3
-         |<--uniquemember-/                              
+         |<--uniquemember-/
          |----member ---> G4 ---member/uniqueMember -> U4
-         |<--uniquemember-/  
+         |<--uniquemember-/
 
     At the end:
           /----member ---> G1 ---member/uniqueMember -\
          /                                             V
     G5 ------------------------>member ----------  --->U1
-         | 
+         |
          |----member ---> G2 ---member/uniqueMember -> U2
          |<--uniquemember-/
          |
          |----member ---> G3 ---member/uniqueMember -> U3
-         |<--uniquemember-/                              
+         |<--uniquemember-/
          |----member ---> G4 ---member/uniqueMember -> U4
-         |<--uniquemember-/  
+         |<--uniquemember-/
     """
 
     memofuser1 = _get_user_dn('memofuser1')
@@ -2275,7 +2286,7 @@ def test_memberof_MultiGrpAttr_024(topology_st):
 
     # ADD user1 as 'member' of grp20_1
     mods = [(ldap.MOD_ADD, 'member', memofuser1)]
-    topology_st.standalone.modify_s(memofegrp020_1, mods)
+    topology_st.standalone.modify_s(ensure_str(memofegrp020_1), mods)
     verify_post_024(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4, memofegrp020_5,
                     memofuser1, memofuser2, memofuser3, memofuser4)
 
@@ -2283,12 +2294,12 @@ def test_memberof_MultiGrpAttr_024(topology_st):
 def verify_post_025(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3, memofegrp020_4, memofegrp020_5,
                     memofuser1, memofuser2, memofuser3, memofuser4):
     """
-          /----member ---> G1 
-         /                                             
+          /----member ---> G1
+         /
     G5 ------------------------>member ----------  --->U1
-         | 
+         |
          |----member ---> G2
-         |----member ---> G3                            
+         |----member ---> G3
          |----member ---> G4
 
     """
@@ -2318,27 +2329,27 @@ def verify_post_025(topology_st, memofegrp020_1, memofegrp020_2, memofegrp020_3,
 
 def test_memberof_MultiGrpAttr_025(topology_st):
     """
-    At the beginning:        
+    At the beginning:
 
 
           /----member ---> G1 ---member/uniqueMember -\
          /                                             V
     G5 ------------------------>member ----------  --->U1
-         | 
+         |
          |----member ---> G2 ---member/uniqueMember -> U2
          |<--uniquemember-/
          |
          |----member ---> G3 ---member/uniqueMember -> U3
-         |<--uniquemember-/                              
+         |<--uniquemember-/
          |----member ---> G4 ---member/uniqueMember -> U4
-         |<--uniquemember-/  
+         |<--uniquemember-/
     At the end:
-          /----member ---> G1 
-         /                                             
+          /----member ---> G1
+         /
     G5 ------------------------>member ----------  --->U1
-         | 
+         |
          |----member ---> G2
-         |----member ---> G3                            
+         |----member ---> G3
          |----member ---> G4
 
     """
@@ -2366,7 +2377,7 @@ def test_memberof_MultiGrpAttr_025(topology_st):
               (memofegrp020_4, memofuser4)]:
         mods = [(ldap.MOD_DELETE, 'member', x[1]),
                 (ldap.MOD_DELETE, 'uniqueMember', x[1])]
-        topology_st.standalone.modify_s(x[0], mods)
+        topology_st.standalone.modify_s(ensure_str(x[0]), mods)
     """
           /----member ---> G1 
          /                                             
@@ -2383,7 +2394,7 @@ def test_memberof_MultiGrpAttr_025(topology_st):
 
     for x in [memofegrp020_2, memofegrp020_3, memofegrp020_4]:
         mods = [(ldap.MOD_DELETE, 'uniqueMember', memofegrp020_5)]
-        topology_st.standalone.modify_s(x, mods)
+        topology_st.standalone.modify_s(ensure_str(x), mods)
     """
           /----member ---> G1 
          /                                             
@@ -2409,7 +2420,7 @@ def test_memberof_auto_add_oc(topology_st):
         topology_st.standalone.modify_s(DN_CONFIG,
                                         [(ldap.MOD_REPLACE,
                                           'nsslapd-dynamic-plugins',
-                                          'on')])
+                                          b'on')])
     except ldap.LDAPError as e:
         ldap.error('Failed to enable dynamic plugins! ' + e.message['desc'])
         assert False
@@ -2459,7 +2470,7 @@ def test_memberof_auto_add_oc(topology_st):
         topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN,
                                         [(ldap.MOD_REPLACE,
                                           'memberofAutoAddOC',
-                                          'invalid123')])
+                                          b'invalid123')])
         log.fatal('Incorrectly added invalid objectclass!')
         assert False
     except ldap.UNWILLING_TO_PERFORM:
@@ -2475,7 +2486,7 @@ def test_memberof_auto_add_oc(topology_st):
         topology_st.standalone.modify_s(MEMBEROF_PLUGIN_DN,
                                         [(ldap.MOD_REPLACE,
                                           'memberofAutoAddOC',
-                                          'inetuser')])
+                                          b'inetuser')])
     except ldap.LDAPError as e:
         log.fatal('Failed to configure memberOf plugin: error ' + e.message['desc'])
         assert False
@@ -2528,7 +2539,7 @@ def test_memberof_auto_add_oc(topology_st):
         topology_st.standalone.modify_s(GROUP_DN,
                                         [(ldap.MOD_ADD,
                                           'member',
-                                          USER2_DN)])
+                                          ensure_bytes(USER2_DN))])
     except ldap.LDAPError as e:
         log.fatal('Failed to add user2 to group: error ' + e.message['desc'])
         assert False
diff --git a/dirsrvtests/tests/suites/plugins/rootdn_plugin_test.py b/dirsrvtests/tests/suites/plugins/rootdn_plugin_test.py
index af5c4c4..4892255 100644
--- a/dirsrvtests/tests/suites/plugins/rootdn_plugin_test.py
+++ b/dirsrvtests/tests/suites/plugins/rootdn_plugin_test.py
@@ -8,13 +8,14 @@
 #
 import logging
 import socket
-
+import ldap
 import pytest
+from lib389.utils import *
 from lib389.tasks import *
 from lib389.tools import DirSrvTools
 from lib389.topologies import topology_st
 
-from lib389._constants import PLUGIN_ROOTDN_ACCESS, DN_CONFIG, DEFAULT_SUFFIX, DN_DM, PASSWORD
+from lib389._constants import PLUGIN_ROOTDN_ACCESS, DN_CONFIG, DEFAULT_SUFFIX, DN_DM, PASSWORD, LOCALHOST_IP
 
 logging.getLogger(__name__).setLevel(logging.DEBUG)
 log = logging.getLogger(__name__)
@@ -47,10 +48,10 @@ def test_rootdn_init(topology_st):
     ACI = ('(target ="ldap:///cn=config")(targetattr = "*")(version 3.0' +
            ';acl "all access";allow (all)(userdn="ldap:///anyone");)')
     try:
-        topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_ADD, 'aci', ACI)])
+        topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_ADD, 'aci', ensure_bytes(ACI))])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_init: Failed to add aci to config: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_init: Failed to add aci to config: error {}'
+                  .format(e))
         assert False
 
     #
@@ -61,17 +62,17 @@ def test_rootdn_init(topology_st):
                                                        'uid': 'user1',
                                                        'userpassword': PASSWORD})))
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_init: Failed to add test user ' + USER1_DN + ': error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_init: Failed to add test user ' + USER1_DN + ': error {}'
+                  .format(e))
         assert False
 
     #
     # Enable dynamic plugins
     #
     try:
-        topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', 'on')])
+        topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', b'on')])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_init: Failed to set dynamic plugins: error ' + e.message['desc'])
+        log.fatal('test_rootdn_init: Failed to set dynamic plugins: error {}'.format(e))
         assert False
 
     #
@@ -99,11 +100,11 @@ def test_rootdn_access_specific_time(topology_st):
         close_time = '1800'
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-open-time', open_time),
-                                                    (ldap.MOD_ADD, 'rootdn-close-time', close_time)])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-open-time', ensure_bytes(open_time)),
+                                                    (ldap.MOD_ADD, 'rootdn-close-time', ensure_bytes(close_time))])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_specific_time: Failed to set (blocking) open/close times: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_specific_time: Failed to set (blocking) open/close times: error {}'
+                  .format(e))
         assert False
 
     #
@@ -129,36 +130,36 @@ def test_rootdn_access_specific_time(topology_st):
         assert False
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', '0000'),
-                                                    (ldap.MOD_REPLACE, 'rootdn-close-time', '2359')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'0000'),
+                                                    (ldap.MOD_REPLACE, 'rootdn-close-time', b'2359')])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_specific_time: Failed to set (open) open/close times: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_specific_time: Failed to set (open) open/close times: error {}'
+                  .format(e))
         assert False
 
     try:
         topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_specific_time: Root DN bind failed unexpectedly failed: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_specific_time: Root DN bind failed unexpectedly failed: error {}'
+                  .format(e))
         assert False
 
     #
     # Cleanup - undo the changes we made so the next test has a clean slate
     #
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-open-time', None),
-                                                    (ldap.MOD_DELETE, 'rootdn-close-time', None)])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-open-time', ensure_bytes(None)),
+                                                    (ldap.MOD_DELETE, 'rootdn-close-time', ensure_bytes(None))])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_specific_time: Failed to delete open and close time: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_specific_time: Failed to delete open and close time: error {}'
+                  .format(e))
         assert False
 
     try:
         topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_specific_time: Root DN bind failed unexpectedly failed: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_specific_time: Root DN bind failed unexpectedly failed: error {}'
+                  .format(e))
         assert False
 
     log.info('test_rootdn_access_specific_time: PASSED')
@@ -194,10 +195,10 @@ def test_rootdn_access_day_of_week(topology_st):
     #
     try:
         topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed',
-                                                     deny_days)])
+                                                     ensure_bytes(deny_days))])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_day_of_week: Failed to set the deny days: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_day_of_week: Failed to set the deny days: error {}'
+                  .format(e))
         assert False
 
     #
@@ -224,34 +225,34 @@ def test_rootdn_access_day_of_week(topology_st):
 
     try:
         topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed',
-                                                     allow_days)])
+                                                     ensure_bytes(allow_days))])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_day_of_week: Failed to set the deny days: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_day_of_week: Failed to set the deny days: error {}'
+                  .format(e))
         assert False
 
     try:
         topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_day_of_week: Root DN bind failed unexpectedly failed: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_day_of_week: Root DN bind failed unexpectedly failed: error {}'
+                  .format(e))
         assert False
 
     #
     # Cleanup - undo the changes we made so the next test has a clean slate
     #
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-days-allowed', None)])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-days-allowed', ensure_bytes(None))])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_day_of_week: Failed to set rootDN plugin config: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_day_of_week: Failed to set rootDN plugin config: error {}'
+                  .format(e))
         assert False
 
     try:
         topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_day_of_week: Root DN bind failed unexpectedly failed: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_day_of_week: Root DN bind failed unexpectedly failed: error {}'
+                  .format(e))
         assert False
 
     log.info('test_rootdn_access_day_of_week: PASSED')
@@ -259,32 +260,32 @@ def test_rootdn_access_day_of_week(topology_st):
 
 def test_rootdn_access_denied_ip(topology_st):
     '''
-    Test denied IP feature - we can just test denying 127.0.01
+    Test denied IP feature - we can just test denying 127.0.0.1
     '''
 
     log.info('Running test_rootdn_access_denied_ip...')
-
     try:
         topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE,
                                                      'rootdn-deny-ip',
-                                                     '127.0.0.1'),
+                                                     b'127.0.0.1'),
                                                     (ldap.MOD_ADD,
                                                      'rootdn-deny-ip',
-                                                     '::1')])
+                                                     b'::1')])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_denied_ip: Failed to set rootDN plugin config: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_denied_ip: Failed to set rootDN plugin config: error {}'
+                  .format(e))
         assert False
 
     #
     # Bind as Root DN - should fail
     #
     try:
-        topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
+        conn = ldap.initialize('ldap://{}:{}'.format(LOCALHOST_IP, topology_st.standalone.port))
+        topology_st.standalone.restart()
+        conn.simple_bind_s(DN_DM, PASSWORD)
         succeeded = True
     except ldap.LDAPError as e:
         succeeded = False
-
     if succeeded:
         log.fatal('test_rootdn_access_denied_ip: Root DN was incorrectly able to bind')
         assert False
@@ -299,17 +300,17 @@ def test_rootdn_access_denied_ip(topology_st):
         assert False
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-ip', '255.255.255.255')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-ip', b'255.255.255.255')])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_denied_ip: Failed to set rootDN plugin config: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_denied_ip: Failed to set rootDN plugin config: error {}'
+                  .format(e))
         assert False
 
     try:
         topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_denied_ip: Root DN bind failed unexpectedly failed: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_denied_ip: Root DN bind failed unexpectedly failed: error {}'
+                  .format(e))
         assert False
 
     #
@@ -318,15 +319,15 @@ def test_rootdn_access_denied_ip(topology_st):
     try:
         topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-deny-ip', None)])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_denied_ip: Failed to set rootDN plugin config: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_denied_ip: Failed to set rootDN plugin config: error {}'
+                  .format(e))
         assert False
 
     try:
         topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_denied_ip: Root DN bind failed unexpectedly failed: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_denied_ip: Root DN bind failed unexpectedly failed: error {}'
+                  .format(e))
         assert False
 
     log.info('test_rootdn_access_denied_ip: PASSED')
@@ -343,14 +344,14 @@ def test_rootdn_access_denied_host(topology_st):
     try:
         topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD,
                                                      'rootdn-deny-host',
-                                                     hostname)])
+                                                     ensure_bytes(hostname))])
         if localhost != hostname:
             topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD,
                                                          'rootdn-deny-host',
-                                                         localhost)])
+                                                         ensure_bytes(localhost))])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_denied_host: Failed to set deny host: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_denied_host: Failed to set deny host: error {}'
+                  .format(e))
         assert False
 
     #
@@ -376,17 +377,17 @@ def test_rootdn_access_denied_host(topology_st):
         assert False
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-host', 'i.dont.exist.com')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-host', b'i.dont.exist.com')])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_denied_host: Failed to set rootDN plugin config: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_denied_host: Failed to set rootDN plugin config: error {}'
+                  .format(e))
         assert False
 
     try:
         topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_denied_host: Root DN bind failed unexpectedly failed: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_denied_host: Root DN bind failed unexpectedly failed: error {}'
+                  .format(e))
         assert False
 
     #
@@ -395,15 +396,15 @@ def test_rootdn_access_denied_host(topology_st):
     try:
         topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-deny-host', None)])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_denied_host: Failed to set rootDN plugin config: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_denied_host: Failed to set rootDN plugin config: error {}'
+                  .format(e))
         assert False
 
     try:
         topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_denied_host: Root DN bind failed unexpectedly failed: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_denied_host: Root DN bind failed unexpectedly failed: error {}'
+                  .format(e))
         assert False
 
     log.info('test_rootdn_access_denied_host: PASSED')
@@ -420,10 +421,12 @@ def test_rootdn_access_allowed_ip(topology_st):
     # Set allowed host to an unknown host - blocks the Root DN
     #
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-ip', '255.255.255.255')])
+        conn = ldap.initialize('ldap://{}:{}'.format(LOCALHOST_IP, topology_st.standalone.port))
+        topology_st.standalone.restart()
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-ip', b'255.255.255.255')])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_allowed_ip: Failed to set allowed host: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_allowed_ip: Failed to set allowed host: error {}'
+                  .format(e))
         assert False
 
     #
@@ -449,18 +452,20 @@ def test_rootdn_access_allowed_ip(topology_st):
         assert False
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-ip', '127.0.0.1'),
-                                                    (ldap.MOD_ADD, 'rootdn-allow-ip', '::1')])
+        #ipv4 = socket.gethostbyname(socket.gethostname())
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-ip', b'127.0.0.1'),
+                                                    (ldap.MOD_ADD, 'rootdn-allow-ip', b'::1')])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_allowed_ip: Failed to set allowed host: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_allowed_ip: Failed to set allowed host: error {}'
+                  .format(e))
         assert False
 
     try:
-        topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
+        #topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
+        conn.simple_bind_s(DN_DM, PASSWORD)
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_allowed_ip: Root DN bind failed unexpectedly failed: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_allowed_ip: Root DN bind failed unexpectedly failed: error {}'
+                  .format(e))
         assert False
 
     #
@@ -469,15 +474,15 @@ def test_rootdn_access_allowed_ip(topology_st):
     try:
         topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-allow-ip', None)])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_allowed_ip: Failed to delete(rootdn-allow-ip): error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_allowed_ip: Failed to delete(rootdn-allow-ip): error {}'
+                  .format(e))
         assert False
 
     try:
         topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_allowed_ip: Root DN bind failed unexpectedly failed: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_allowed_ip: Root DN bind failed unexpectedly failed: error {}'
+                  .format(e))
         assert False
 
     log.info('test_rootdn_access_allowed_ip: PASSED')
@@ -494,10 +499,10 @@ def test_rootdn_access_allowed_host(topology_st):
     # Set allowed host to an unknown host - blocks the Root DN
     #
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-host', 'i.dont.exist.com')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-host', b'i.dont.exist.com')])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_allowed_host: Failed to set allowed host: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_allowed_host: Failed to set allowed host: error {}'
+                  .format(e))
         assert False
 
     #
@@ -530,21 +535,21 @@ def test_rootdn_access_allowed_host(topology_st):
                                                      None)])
         topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD,
                                                      'rootdn-allow-host',
-                                                     localhost)])
+                                                     ensure_bytes(localhost))])
         if hostname != localhost:
             topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD,
                                                          'rootdn-allow-host',
-                                                         hostname)])
+                                                         ensure_bytes(hostname))])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_allowed_host: Failed to set allowed host: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_allowed_host: Failed to set allowed host: error {}'
+                  .format(e))
         assert False
 
     try:
         topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_allowed_host: Root DN bind failed unexpectedly failed: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_allowed_host: Root DN bind failed unexpectedly failed: error {}'
+                  .format(e))
         assert False
 
     #
@@ -553,15 +558,15 @@ def test_rootdn_access_allowed_host(topology_st):
     try:
         topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_DELETE, 'rootdn-allow-host', None)])
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_allowed_host: Failed to delete(rootdn-allow-host): error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_allowed_host: Failed to delete(rootdn-allow-host): error {}'
+                  .format(e))
         assert False
 
     try:
         topology_st.standalone.simple_bind_s(DN_DM, PASSWORD)
     except ldap.LDAPError as e:
-        log.fatal('test_rootdn_access_allowed_host: Root DN bind failed unexpectedly failed: error ' +
-                  e.message['desc'])
+        log.fatal('test_rootdn_access_allowed_host: Root DN bind failed unexpectedly failed: error {}'
+                  .format(e))
         assert False
 
     log.info('test_rootdn_access_allowed_host: PASSED')
@@ -583,39 +588,39 @@ def test_rootdn_config_validate(topology_st):
     # Test rootdn-open-time
     #
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', '0000')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'0000')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to just add "rootdn-open-time" ')
         assert False
     except ldap.LDAPError:
         pass
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-open-time', '0000'),
-                                                    (ldap.MOD_ADD, 'rootdn-open-time', '0001')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-open-time', b'0000'),
+                                                    (ldap.MOD_ADD, 'rootdn-open-time', b'0001')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add multiple "rootdn-open-time"')
         assert False
     except ldap.LDAPError:
         pass
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', '-1'),
-                                                    (ldap.MOD_REPLACE, 'rootdn-close-time', '0000')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'-1'),
+                                                    (ldap.MOD_REPLACE, 'rootdn-close-time', b'0000')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-open-time: -1"')
         assert False
     except ldap.LDAPError:
         pass
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', '2400'),
-                                                    (ldap.MOD_REPLACE, 'rootdn-close-time', '0000')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'2400'),
+                                                    (ldap.MOD_REPLACE, 'rootdn-close-time', b'0000')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-open-time: 2400"')
         assert False
     except ldap.LDAPError:
         pass
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', 'aaaaa'),
-                                                    (ldap.MOD_REPLACE, 'rootdn-close-time', '0000')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'aaaaa'),
+                                                    (ldap.MOD_REPLACE, 'rootdn-close-time', b'0000')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-open-time: aaaaa"')
         assert False
     except ldap.LDAPError:
@@ -625,39 +630,39 @@ def test_rootdn_config_validate(topology_st):
     # Test rootdn-close-time
     #
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-close-time', '0000')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-close-time', b'0000')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add just "rootdn-close-time"')
         assert False
     except ldap.LDAPError:
         pass
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-close-time', '0000'),
-                                                    (ldap.MOD_ADD, 'rootdn-close-time', '0001')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-close-time', b'0000'),
+                                                    (ldap.MOD_ADD, 'rootdn-close-time', b'0001')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add multiple "rootdn-open-time"')
         assert False
     except ldap.LDAPError:
         pass
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', '0000'),
-                                                    (ldap.MOD_REPLACE, 'rootdn-close-time', '-1')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'0000'),
+                                                    (ldap.MOD_REPLACE, 'rootdn-close-time', b'-1')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-close-time: -1"')
         assert False
     except ldap.LDAPError:
         pass
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', '0000'),
-                                                    (ldap.MOD_REPLACE, 'rootdn-close-time', '2400')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'0000'),
+                                                    (ldap.MOD_REPLACE, 'rootdn-close-time', b'2400')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-close-time: 2400"')
         assert False
     except ldap.LDAPError:
         pass
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', '0000'),
-                                                    (ldap.MOD_REPLACE, 'rootdn-close-time', 'aaaaa')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-open-time', b'0000'),
+                                                    (ldap.MOD_REPLACE, 'rootdn-close-time', b'aaaaa')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-close-time: aaaaa"')
         assert False
     except ldap.LDAPError:
@@ -667,36 +672,36 @@ def test_rootdn_config_validate(topology_st):
     # Test days allowed
     #
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-days-allowed', 'Mon'),
-                                                    (ldap.MOD_ADD, 'rootdn-days-allowed', 'Tue')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_ADD, 'rootdn-days-allowed', b'Mon'),
+                                                    (ldap.MOD_ADD, 'rootdn-days-allowed', b'Tue')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add two "rootdn-days-allowed"')
         assert False
     except ldap.LDAPError:
         pass
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', 'Mon1')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', b'Mon1')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-days-allowed: Mon1"')
         assert False
     except ldap.LDAPError:
         pass
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', 'Tue, Mon1')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', b'Tue, Mon1')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-days-allowed: Tue, Mon1"')
         assert False
     except ldap.LDAPError:
         pass
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', 'm111m')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', b'm111m')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-days-allowed: 111"')
         assert False
     except ldap.LDAPError:
         pass
 
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', 'Gur')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-days-allowed', b'Gur')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-days-allowed: Gur"')
         assert False
     except ldap.LDAPError:
@@ -706,7 +711,7 @@ def test_rootdn_config_validate(topology_st):
     # Test allow ips
     #
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-ip', '12.12.Z.12')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-ip', b'12.12.Z.12')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-allow-ip: 12.12.Z.12"')
         assert False
     except ldap.LDAPError:
@@ -716,7 +721,7 @@ def test_rootdn_config_validate(topology_st):
     # Test deny ips
     #
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-ip', '12.12.Z.12')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-ip', b'12.12.Z.12')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-deny-ip: 12.12.Z.12"')
         assert False
     except ldap.LDAPError:
@@ -726,7 +731,7 @@ def test_rootdn_config_validate(topology_st):
     # Test allow hosts
     #
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-host', 'host._.com')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-allow-host', b'host._.com')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-allow-host: host._.com"')
         assert False
     except ldap.LDAPError:
@@ -736,7 +741,7 @@ def test_rootdn_config_validate(topology_st):
     # Test deny hosts
     #
     try:
-        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-host', 'host.####.com')])
+        topology_st.standalone.modify_s(PLUGIN_DN, [(ldap.MOD_REPLACE, 'rootdn-deny-host', b'host.####.com')])
         log.fatal('test_rootdn_config_validate: Incorrectly allowed to add invalid "rootdn-deny-host: host.####.com"')
         assert False
     except ldap.LDAPError:
diff --git a/src/lib389/lib389/_constants.py b/src/lib389/lib389/_constants.py
index 71cf359..f416c3e 100644
--- a/src/lib389/lib389/_constants.py
+++ b/src/lib389/lib389/_constants.py
@@ -88,6 +88,7 @@ DIRSRV_STATE_ONLINE = 5
 
 # So uh  .... localhost.localdomain doesn't always exist. Stop. Using. It.
 # LOCALHOST = "localhost.localdomain"
+LOCALHOST_IP = "127.0.0.1"
 LOCALHOST = "localhost"
 LOCALHOST_SHORT = "localhost"
 DEFAULT_PORT = 389

