netapi: add libnetapi_samr_open_builtin_domain().
authorGünther Deschner <gd@samba.org>
Mon, 2 Jun 2008 22:13:39 +0000 (00:13 +0200)
committerGünther Deschner <gd@samba.org>
Mon, 2 Jun 2008 23:27:50 +0000 (01:27 +0200)
Guenther
(This used to be commit f15a7f9ab1da88369185beda267f3e67a3b36191)

source3/lib/netapi/netapi_private.h
source3/lib/netapi/samr.c

index 69e68ab733e7e8995fdcd8a80ab5afc30a2073a2..3ce078c2b64bff456bc57dcc69aa9ba080c79c82 100644 (file)
@@ -40,4 +40,11 @@ WERROR libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
                                  struct policy_handle *connect_handle,
                                  struct policy_handle *domain_handle,
                                  struct dom_sid2 **domain_sid);
+WERROR libnetapi_samr_open_builtin_domain(TALLOC_CTX *mem_ctx,
+                                         struct rpc_pipe_client *pipe_cli,
+                                         uint32_t connect_mask,
+                                         uint32_t builtin_mask,
+                                         struct policy_handle *connect_handle,
+                                         struct policy_handle *builtin_handle);
+
 #endif
index a41de91de38dfdbfd8c66a500a9d96c044d1f625..82898902375228a3a5d7a84c6d8c02462e98fd02 100644 (file)
@@ -109,3 +109,42 @@ WERROR libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
  done:
        return werr;
 }
+
+/****************************************************************
+****************************************************************/
+
+WERROR libnetapi_samr_open_builtin_domain(TALLOC_CTX *mem_ctx,
+                                         struct rpc_pipe_client *pipe_cli,
+                                         uint32_t connect_mask,
+                                         uint32_t builtin_mask,
+                                         struct policy_handle *connect_handle,
+                                         struct policy_handle *builtin_handle)
+{
+       NTSTATUS status;
+       WERROR werr;
+
+       if (!is_valid_policy_hnd(connect_handle)) {
+               status = rpccli_try_samr_connects(pipe_cli, mem_ctx,
+                                                 connect_mask,
+                                                 connect_handle);
+               if (!NT_STATUS_IS_OK(status)) {
+                       werr = ntstatus_to_werror(status);
+                       goto done;
+               }
+       }
+
+       status = rpccli_samr_OpenDomain(pipe_cli, mem_ctx,
+                                       connect_handle,
+                                       builtin_mask,
+                                       CONST_DISCARD(DOM_SID *, &global_sid_Builtin),
+                                       builtin_handle);
+       if (!NT_STATUS_IS_OK(status)) {
+               werr = ntstatus_to_werror(status);
+               goto done;
+       }
+
+       werr = WERR_OK;
+
+ done:
+       return werr;
+}