s4-rpc_server/backupkey: Use samdb_system_container_dn() in get_lsa_secret()
authorAndrew Bartlett <abartlet@samba.org>
Thu, 27 Jul 2023 05:11:39 +0000 (17:11 +1200)
committerStefan Metzmacher <metze@samba.org>
Mon, 31 Jul 2023 06:18:33 +0000 (06:18 +0000)
This is now exactly the same actions, but just uses common code to do it.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=9959

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source4/rpc_server/backupkey/dcesrv_backupkey.c

index 5faffdc022cd9143b1ef5323626a24df287970e6..7c4b9de1febb304c3e76901c9a865901fa0d9e8c 100644 (file)
@@ -196,17 +196,12 @@ static NTSTATUS get_lsa_secret(TALLOC_CTX *mem_ctx,
                return NT_STATUS_NO_MEMORY;
        }
 
-       system_dn = ldb_dn_copy(tmp_mem, ldb_get_default_basedn(ldb));
+       system_dn = samdb_system_container_dn(ldb, tmp_mem);
        if (system_dn == NULL) {
                talloc_free(tmp_mem);
                return NT_STATUS_NO_MEMORY;
        }
 
-       if (!ldb_dn_add_child_fmt(system_dn, "CN=System")) {
-               talloc_free(tmp_mem);
-               return NT_STATUS_NO_MEMORY;
-       }
-
        ret = ldb_search(ldb, mem_ctx, &res, system_dn, LDB_SCOPE_SUBTREE, attrs,
                           "(&(cn=%s Secret)(objectclass=secret))",
                           ldb_binary_encode_string(tmp_mem, name));