+class LDBBackend(ProvisionBackend):
+ def __init__(self, backend_type, paths=None, setup_path=None, lp=None, credentials=None,
+ names=None, message=None):
+
+ super(LDBBackend, self).__init__(
+ backend_type=backend_type,
+ paths=paths, setup_path=setup_path,
+ lp=lp, credentials=credentials,
+ names=names,
+ message=message)
+
+ def setup(self):
+ self.credentials = None
+ self.secrets_credentials = None
+
+ # Wipe the old sam.ldb databases away
+ shutil.rmtree(self.paths.samdb + ".d", True)
+
+
+class ExistingBackend(ProvisionBackend):
+ def __init__(self, backend_type, paths=None, setup_path=None, lp=None, credentials=None,
+ names=None, message=None):
+
+ super(ExistingBackend, self).__init__(
+ backend_type=backend_type,
+ paths=paths, setup_path=setup_path,
+ lp=lp, credentials=credentials,
+ names=names,
+ message=message)
+
+ self.ldapi_uri = "ldapi://" + urllib.quote(os.path.join(paths.ldapdir, "ldapi"), safe="")
+
+ def setup(self):
+ #Check to see that this 'existing' LDAP backend in fact exists
+ ldapi_db = Ldb(self.ldapi_uri, credentials=self.credentials)
+ search_ol_rootdse = ldapi_db.search(base="", scope=SCOPE_BASE,
+ expression="(objectClass=OpenLDAProotDSE)")
+
+ # If we have got here, then we must have a valid connection to the LDAP server, with valid credentials supplied
+ # This caused them to be set into the long-term database later in the script.
+ self.secrets_credentials = self.credentials
+
+ self.ldap_backend_type = "openldap" #For now, assume existing backends at least emulate OpenLDAP
+
+