Remove default SASL mappings if any to avoid conflicts with IPA SASL mappings

This commit is contained in:
Simo Sorce
2007-11-19 19:34:10 -05:00
parent c6532b621d
commit 44f9f13e17
+19
View File
@@ -35,6 +35,11 @@ import time
import service
from ipa.ipautil import *
import ldap
from ldap import LDAPError
from ldap import ldapobject
from pyasn1.type import univ
import pyasn1.codec.ber.encoder
import struct
@@ -155,6 +160,20 @@ class KrbInstance(service.Service):
def __configure_ldap(self):
self.step("adding kerberos configuration to the directory")
# we need to remove any existing SASL mappings in the directory as otherwise they
# they may conflict. There is no way to define the order they are used in atm.
try:
lo = ldapobject.SimpleLDAPObject("ldap://127.0.0.1/")
lo.bind("cn=Directory Manager", self.admin_password)
msgid = lo.search("cn=mapping,cn=sasl,cn=config", ldap.SCOPE_ONELEVEL, "(objectclass=nsSaslMapping)")
res = lo.result(msgid)
for r in res[1]:
mid = lo.delete(r[0])
delres = lo.result(mid)
lo.unbind()
except LDAPError, e:
logging.critical("Error during SASL mapping removal: %s" % str(e))
#TODO: test that the ldif is ok with any random charcter we may use in the password
kerberos_txt = template_file(SHARE_DIR + "kerberos.ldif", self.sub_dict)
kerberos_fd = write_tmp_file(kerberos_txt)