summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-07-17 19:43:34 +0200
committerGünther Deschner <gd@samba.org>2008-07-18 16:52:26 +0200
commit6fa58fdc07743e5db71d9f27b67d14d8103aa2e9 (patch)
tree2dcaa3da8bb2e58f85d24b95e8ae4ae10c80fa60 /source3/lib
parent4704864338b62a57afb86986ed2d4a0ce0a97020 (diff)
downloadsamba-6fa58fdc07743e5db71d9f27b67d14d8103aa2e9.tar.gz
samba-6fa58fdc07743e5db71d9f27b67d14d8103aa2e9.tar.bz2
samba-6fa58fdc07743e5db71d9f27b67d14d8103aa2e9.zip
netapi: use private samr structure in libnetapi_samr_open_domain().
Guenther (This used to be commit 3c63ebfc00cda0334802bff1883ebbc3138a70f1)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/netapi/netapi_private.h2
-rw-r--r--source3/lib/netapi/samr.c48
2 files changed, 48 insertions, 2 deletions
diff --git a/source3/lib/netapi/netapi_private.h b/source3/lib/netapi/netapi_private.h
index db4eb6f0a3..246672a349 100644
--- a/source3/lib/netapi/netapi_private.h
+++ b/source3/lib/netapi/netapi_private.h
@@ -51,7 +51,7 @@ WERROR libnetapi_open_pipe(struct libnetapi_ctx *ctx,
struct cli_state *cli,
int pipe_idx,
struct rpc_pipe_client **pipe_cli);
-WERROR libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
+WERROR libnetapi_samr_open_domain(struct libnetapi_ctx *mem_ctx,
struct rpc_pipe_client *pipe_cli,
uint32_t connect_mask,
uint32_t domain_mask,
diff --git a/source3/lib/netapi/samr.c b/source3/lib/netapi/samr.c
index bd90067a6d..e83b8eba9c 100644
--- a/source3/lib/netapi/samr.c
+++ b/source3/lib/netapi/samr.c
@@ -18,11 +18,13 @@
*/
#include "includes.h"
+#include "lib/netapi/netapi.h"
+#include "lib/netapi/netapi_private.h"
/****************************************************************
****************************************************************/
-WERROR libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
+WERROR libnetapi_samr_open_domain(struct libnetapi_ctx *mem_ctx,
struct rpc_pipe_client *pipe_cli,
uint32_t connect_mask,
uint32_t domain_mask,
@@ -32,6 +34,7 @@ WERROR libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
{
NTSTATUS status;
WERROR werr;
+ struct libnetapi_private_ctx *priv;
uint32_t resume_handle = 0;
uint32_t num_entries = 0;
struct samr_SamArray *sam = NULL;
@@ -40,6 +43,38 @@ WERROR libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
bool domain_found = true;
int i;
+ priv = talloc_get_type_abort(mem_ctx->private_data,
+ struct libnetapi_private_ctx);
+
+ if (is_valid_policy_hnd(&priv->samr.connect_handle)) {
+ if ((priv->samr.connect_mask & connect_mask) == connect_mask) {
+ *connect_handle = priv->samr.connect_handle;
+ } else {
+ libnetapi_samr_close_connect_handle(mem_ctx,
+ &priv->samr.connect_handle);
+ }
+ }
+
+ if (is_valid_policy_hnd(&priv->samr.domain_handle)) {
+ if ((priv->samr.domain_mask & domain_mask) == domain_mask) {
+ *domain_handle = priv->samr.domain_handle;
+ } else {
+ libnetapi_samr_close_domain_handle(mem_ctx,
+ &priv->samr.domain_handle);
+ }
+ }
+
+ if (priv->samr.domain_sid) {
+ *domain_sid = priv->samr.domain_sid;
+ }
+
+ if (is_valid_policy_hnd(&priv->samr.connect_handle) &&
+ ((priv->samr.connect_mask & connect_mask) == connect_mask) &&
+ is_valid_policy_hnd(&priv->samr.domain_handle) &&
+ (priv->samr.domain_mask & domain_mask) == domain_mask) {
+ return WERR_OK;
+ }
+
if (!is_valid_policy_hnd(connect_handle)) {
status = rpccli_try_samr_connects(pipe_cli, mem_ctx,
connect_mask,
@@ -99,6 +134,17 @@ WERROR libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
goto done;
}
+ priv->samr.cli = pipe_cli;
+
+ priv->samr.domain_name = domain_name;
+ priv->samr.domain_sid = *domain_sid;
+
+ priv->samr.connect_mask = connect_mask;
+ priv->samr.connect_handle = *connect_handle;
+
+ priv->samr.domain_mask = domain_mask;
+ priv->samr.domain_handle = *domain_handle;
+
werr = WERR_OK;
done: