s4:dsdb - Fixed attribute dereferencing for FDS
[samba.git] / source4 / scripting / python / samba / provision.py
index f6236ccb7dcec92e56d242db449503a2d59f43a5..74d8562c9b36bcddd72bcf48ec4666a930c27744 100644 (file)
@@ -434,54 +434,56 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
     """Guess configuration settings to use."""
 
     if hostname is None:
-        hostname = socket.gethostname().split(".")[0].lower()
+        hostname = socket.gethostname().split(".")[0]
 
-    netbiosname = hostname.upper()
+    netbiosname = lp.get("netbios name")
+    if netbiosname is None:
+        netbiosname = hostname
+    assert netbiosname is not None
+    netbiosname = netbiosname.upper()
     if not valid_netbios_name(netbiosname):
         raise InvalidNetbiosName(netbiosname)
 
-    hostname = hostname.lower()
-
     if dnsdomain is None:
-        dnsdomain = lp.get("realm").lower()
+        dnsdomain = lp.get("realm")
+    assert dnsdomain is not None
+    dnsdomain = dnsdomain.lower()
 
     if serverrole is None:
         serverrole = lp.get("server role")
+    assert serverrole is not None
+    serverrole = serverrole.lower()
 
-    assert dnsdomain is not None
     realm = dnsdomain.upper()
 
     if lp.get("realm").upper() != realm:
-        raise Exception("realm '%s' in %s must match chosen realm '%s'" %
-                        (lp.get("realm"), lp.configfile, realm))
-    
+        raise ProvisioningError("guess_names: Realm '%s' in smb.conf must match chosen realm '%s'!", lp.get("realm").upper(), realm)
+
     if serverrole == "domain controller":
         if domain is None:
             domain = lp.get("workgroup")
+        assert domain is not None
+        domain = domain.upper()
+
+        if lp.get("workgroup").upper() != domain:
+            raise ProvisioningError("guess_names: Workgroup '%s' in smb.conf must match chosen domain '%s'!", lp.get("workgroup").upper(), domain)
+
         if domaindn is None:
             domaindn = "DC=" + dnsdomain.replace(".", ",DC=")
-        if lp.get("workgroup").upper() != domain.upper():
-            raise Exception("workgroup '%s' in smb.conf must match chosen domain '%s'",
-                        lp.get("workgroup"), domain)
     else:
         domain = netbiosname
         if domaindn is None:
             domaindn = "DC=" + netbiosname
         
-    assert domain is not None
-    domain = domain.upper()
-
     if not valid_netbios_name(domain):
         raise InvalidNetbiosName(domain)
         
-    if netbiosname.upper() == realm:
-        raise Exception("realm %s must not be equal to netbios domain name %s", realm, netbiosname)
-        
     if hostname.upper() == realm:
-        raise Exception("realm %s must not be equal to hostname %s", realm, hostname)
-        
-    if domain.upper() == realm:
-        raise Exception("realm %s must not be equal to domain name %s", realm, domain)
+        raise ProvisioningError("guess_names: Realm '%s' must not be equal to hostname '%s'!", realm, hostname)
+    if netbiosname == realm:
+        raise ProvisioningError("guess_names: Realm '%s' must not be equal to netbios hostname '%s'!", realm, netbiosname)
+    if domain == realm:
+        raise ProvisioningError("guess_names: Realm '%s' must not be equal to short domain name '%s'!", realm, domain)
 
     if rootdn is None:
        rootdn = domaindn
@@ -520,7 +522,8 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
     """
     assert smbconf is not None
     if hostname is None:
-        hostname = socket.gethostname().split(".")[0].lower()
+        hostname = socket.gethostname().split(".")[0]
+    netbiosname = hostname.upper()
 
     if serverrole is None:
         serverrole = "standalone"
@@ -534,7 +537,10 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
         smbconfsuffix = "standalone"
 
     assert domain is not None
+    domain = domain.upper()
+
     assert realm is not None
+    realm = realm.upper()
 
     default_lp = param.LoadParm()
     #Load non-existant file
@@ -555,7 +561,7 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
 
     setup_file(setup_path("provision.smb.conf.%s" % smbconfsuffix), 
                smbconf, {
-            "HOSTNAME": hostname,
+            "NETBIOS_NAME": netbiosname,
             "DOMAIN": domain,
             "REALM": realm,
             "SERVERROLE": serverrole,
@@ -672,8 +678,9 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
                     "linked_attributes",
                     "extended_dn_out_ldb"]
     modules_list2 = ["show_deleted",
+                     "schema_load",
                      "new_partition",
-                    "partition"]
+                     "partition"]
     ldap_backend_line = "# No LDAP backend"
     if ldap_backend is not None:
         ldap_backend_line = "ldapBackend: %s" % ldap_backend.ldapi_uri
@@ -681,11 +688,11 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
         if ldap_backend.ldap_backend_type == "fedora-ds":
             backend_modules = ["nsuniqueid", "paged_searches"]
             # We can handle linked attributes here, as we don't have directory-side subtree operations
-            tdb_modules_list = ["extended_dn_out_dereference"]
+            tdb_modules_list = ["extended_dn_out_fds"]
         elif ldap_backend.ldap_backend_type == "openldap":
             backend_modules = ["entryuuid", "paged_searches"]
             # OpenLDAP handles subtree renames, so we don't want to do any of these things
-            tdb_modules_list = ["extended_dn_out_dereference"]
+            tdb_modules_list = ["extended_dn_out_openldap"]
 
     elif serverrole == "domain controller":
         tdb_modules_list.insert(0, "repl_meta_data")
@@ -706,7 +713,7 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
                 "SCHEMADN_MOD2": ",objectguid",
                 "CONFIGDN": ldb.Dn(schema.ldb, names.configdn).get_casefold(),
                 "DOMAINDN": ldb.Dn(schema.ldb, names.domaindn).get_casefold(),
-                "SCHEMADN_MOD": "schema_fsmo",
+                "SCHEMADN_MOD": "schema_data",
                 "CONFIGDN_MOD": "naming_fsmo",
                 "DOMAINDN_MOD": "pdc_fsmo",
                 "MODULES_LIST": ",".join(modules_list),
@@ -1265,10 +1272,10 @@ def provision(setup_dir, message, session_info,
     lp = param.LoadParm()
     lp.load(smbconf)
 
-    names = guess_names(lp=lp, hostname=hostname, domain=domain, 
-                        dnsdomain=realm, serverrole=serverrole, sitename=sitename,
-                        rootdn=rootdn, domaindn=domaindn, configdn=configdn, schemadn=schemadn,
-                        serverdn=serverdn)
+    names = guess_names(lp=lp, hostname=hostname, domain=domain,
+                        dnsdomain=realm, serverrole=serverrole,
+                        domaindn=domaindn, configdn=configdn, schemadn=schemadn,
+                        serverdn=serverdn, sitename=sitename)
 
     paths = provision_paths_from_lp(lp, names.dnsdomain)