[SCM] Samba Shared Repository - branch v3-2-test updated -
release-3-2-0pre2-697-g0216e55
Günther Deschner
gd at samba.org
Tue Apr 8 17:41:51 GMT 2008
The branch, v3-2-test has been updated
via 0216e55fa87a14fc45c320268f0511eb6638460b (commit)
via 27780e984152e38c8f80e1c67ddf13b73a2b220d (commit)
via a47642011a5d4732afa939a9162c232922a29f61 (commit)
via e8cea4db013de63ec0eb9f8c9db530688483e5b6 (commit)
via 922ff9d01668c2c2ad10decfd09c0e7b3f0d7592 (commit)
from 83b6da7c52a6f5285a9765d22d13a53fe9dc80e5 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit 0216e55fa87a14fc45c320268f0511eb6638460b
Author: Günther Deschner <gd at samba.org>
Date: Tue Apr 8 18:45:26 2008 +0200
Add DsGetDcName libnetapi example.
Guenther
commit 27780e984152e38c8f80e1c67ddf13b73a2b220d
Author: Günther Deschner <gd at samba.org>
Date: Tue Apr 8 18:43:51 2008 +0200
Add DsGetDcName call to libnetapi library.
Guenther
commit a47642011a5d4732afa939a9162c232922a29f61
Author: Günther Deschner <gd at samba.org>
Date: Tue Apr 8 14:38:10 2008 +0200
Re-run make idl.
Guenther
commit e8cea4db013de63ec0eb9f8c9db530688483e5b6
Author: Günther Deschner <gd at samba.org>
Date: Tue Apr 8 14:37:09 2008 +0200
Add DsGetDCName call to libnetapi.idl.
Guenther
commit 922ff9d01668c2c2ad10decfd09c0e7b3f0d7592
Author: Günther Deschner <gd at samba.org>
Date: Tue Apr 8 17:17:17 2008 +0200
Fix includes in libnetapi examples common.c
Guenther
-----------------------------------------------------------------------
Summary of changes:
source/lib/netapi/examples/Makefile.in | 6 +
source/lib/netapi/examples/common.c | 5 +-
.../examples/{getdc/getdc.c => dsgetdc/dsgetdc.c} | 23 +++--
source/lib/netapi/getdc.c | 76 ++++++++++++++
source/lib/netapi/libnetapi.c | 50 +++++++++
source/lib/netapi/libnetapi.h | 10 ++
source/lib/netapi/netapi.h | 42 ++++++++
source/librpc/gen_ndr/libnetapi.h | 29 ++++++
source/librpc/gen_ndr/ndr_libnetapi.c | 107 ++++++++++++++++++++
source/librpc/gen_ndr/ndr_libnetapi.h | 10 ++-
source/librpc/idl/libnetapi.idl | 22 ++++
11 files changed, 368 insertions(+), 12 deletions(-)
copy source/lib/netapi/examples/{getdc/getdc.c => dsgetdc/dsgetdc.c} (77%)
Changeset truncated at 500 lines:
diff --git a/source/lib/netapi/examples/Makefile.in b/source/lib/netapi/examples/Makefile.in
index 9020d60..b60437d 100644
--- a/source/lib/netapi/examples/Makefile.in
+++ b/source/lib/netapi/examples/Makefile.in
@@ -18,6 +18,7 @@ COMPILE_CC = $(CC) -I. $(FLAGS) $(PICFLAG) -c $< -o $@
COMPILE = $(COMPILE_CC)
PROGS = bin/getdc at EXEEXT@ \
+ bin/dsgetdc at EXEEXT@ \
bin/netdomjoin at EXEEXT@ \
bin/netdomjoin-gui at EXEEXT@ \
bin/getjoinableous at EXEEXT@
@@ -50,6 +51,7 @@ bin/.dummy:
CMDLINE_OBJ = common.o
GETDC_OBJ = getdc/getdc.o $(CMDLINE_OBJ)
+DSGETDC_OBJ = dsgetdc/dsgetdc.o $(CMDLINE_OBJ)
NETDOMJOIN_OBJ = netdomjoin/netdomjoin.o $(CMDLINE_OBJ)
NETDOMJOIN_GUI_OBJ = netdomjoin-gui/netdomjoin-gui.o
GETJOINABLEOUS_OBJ = getjoinableous/getjoinableous.o $(CMDLINE_OBJ)
@@ -58,6 +60,10 @@ bin/getdc at EXEEXT@: $(BINARY_PREREQS) $(GETDC_OBJ)
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(GETDC_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS)
+bin/dsgetdc at EXEEXT@: $(BINARY_PREREQS) $(DSGETDC_OBJ)
+ @echo Linking $@
+ @$(CC) $(FLAGS) -o $@ $(DSGETDC_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS)
+
bin/getjoinableous at EXEEXT@: $(BINARY_PREREQS) $(GETJOINABLEOUS_OBJ)
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(GETJOINABLEOUS_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS)
diff --git a/source/lib/netapi/examples/common.c b/source/lib/netapi/examples/common.c
index db9ab0a..2c3e4d7 100644
--- a/source/lib/netapi/examples/common.c
+++ b/source/lib/netapi/examples/common.c
@@ -1,7 +1,10 @@
#include <stdlib.h>
#include <string.h>
-#include <netapi.h>
+#include <sys/types.h>
+#include <inttypes.h>
+
#include <popt.h>
+#include <netapi.h>
void popt_common_callback(poptContext con,
enum poptCallbackReason reason,
diff --git a/source/lib/netapi/examples/getdc/getdc.c b/source/lib/netapi/examples/dsgetdc/dsgetdc.c
similarity index 77%
copy from source/lib/netapi/examples/getdc/getdc.c
copy to source/lib/netapi/examples/dsgetdc/dsgetdc.c
index 98bb6a1..7c0ec4d 100644
--- a/source/lib/netapi/examples/getdc/getdc.c
+++ b/source/lib/netapi/examples/dsgetdc/dsgetdc.c
@@ -1,7 +1,7 @@
/*
* Unix SMB/CIFS implementation.
- * GetDCName query
- * Copyright (C) Guenther Deschner 2007
+ * DsGetDcName query
+ * Copyright (C) Guenther Deschner 2008
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@ int main(int argc, const char **argv)
const char *hostname = NULL;
const char *domain = NULL;
- uint8_t *buffer = NULL;
+ struct DOMAIN_CONTROLLER_INFO *info = NULL;
poptContext pc;
int opt;
@@ -50,7 +50,7 @@ int main(int argc, const char **argv)
return status;
}
- pc = poptGetContext("getdc", argc, argv, long_options, 0);
+ pc = poptGetContext("dsgetdc", argc, argv, long_options, 0);
poptSetOtherOptionHelp(pc, "hostname domainname");
while((opt = poptGetNextOpt(pc)) != -1) {
@@ -68,17 +68,20 @@ int main(int argc, const char **argv)
}
domain = poptGetArg(pc);
- /* NetGetDCName */
+ /* DsGetDcName */
- status = NetGetDCName(hostname, domain, &buffer);
+ status = DsGetDcName(hostname, domain, NULL, NULL, 0, &info);
if (status != 0) {
- printf("GetDcName failed with: %s\n", libnetapi_errstr(status));
- } else {
- printf("%s\n", (char *)buffer);
+ printf("DsGetDcName failed with: %s\n",
+ libnetapi_errstr(status));
+ return status;
}
+ printf("domain %s has name: %s\n",
+ info->domain_name, info->domain_controller_name);
+
out:
- NetApiBufferFree(buffer);
+ NetApiBufferFree(info);
libnetapi_free(ctx);
poptFreeContext(pc);
diff --git a/source/lib/netapi/getdc.c b/source/lib/netapi/getdc.c
index f6a666d..9ad935e 100644
--- a/source/lib/netapi/getdc.c
+++ b/source/lib/netapi/getdc.c
@@ -133,3 +133,79 @@ WERROR NetGetAnyDCName_r(struct libnetapi_ctx *ctx,
return werr;
}
+
+/********************************************************************
+********************************************************************/
+
+WERROR DsGetDcName_l(struct libnetapi_ctx *ctx,
+ struct DsGetDcName *r)
+{
+ NTSTATUS status;
+
+ status = dsgetdcname(ctx,
+ r->in.domain_name,
+ r->in.domain_guid,
+ r->in.site_name,
+ r->in.flags,
+ (struct netr_DsRGetDCNameInfo **)r->out.dc_info);
+ if (!NT_STATUS_IS_OK(status)) {
+ libnetapi_set_error_string(ctx,
+ "failed to find DC: %s",
+ get_friendly_nt_error_msg(status));
+ }
+
+ return ntstatus_to_werror(status);
+}
+
+/********************************************************************
+********************************************************************/
+
+WERROR DsGetDcName_r(struct libnetapi_ctx *ctx,
+ struct DsGetDcName *r)
+{
+ WERROR werr;
+ NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
+ struct cli_state *cli = NULL;
+ struct rpc_pipe_client *pipe_cli = NULL;
+
+ status = cli_full_connection(&cli, NULL, r->in.server_name,
+ NULL, 0,
+ "IPC$", "IPC",
+ ctx->username,
+ ctx->workgroup,
+ ctx->password,
+ 0, Undefined, NULL);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
+ pipe_cli = cli_rpc_pipe_open_noauth(cli, PI_NETLOGON,
+ &status);
+ if (!pipe_cli) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
+ status = rpccli_netr_DsRGetDCName(pipe_cli,
+ ctx,
+ r->in.server_name,
+ r->in.domain_name,
+ r->in.domain_guid,
+ NULL,
+ r->in.flags,
+ (struct netr_DsRGetDCNameInfo **)r->out.dc_info,
+ &werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
+ done:
+ if (cli) {
+ cli_shutdown(cli);
+ }
+
+ return werr;
+}
diff --git a/source/lib/netapi/libnetapi.c b/source/lib/netapi/libnetapi.c
index 9d42b7e..ed97df2 100644
--- a/source/lib/netapi/libnetapi.c
+++ b/source/lib/netapi/libnetapi.c
@@ -391,3 +391,53 @@ NET_API_STATUS NetGetAnyDCName(const char * server_name /* [in] [unique] */,
return r.out.result;
}
+/****************************************************************
+ DsGetDcName
+****************************************************************/
+
+NET_API_STATUS DsGetDcName(const char * server_name /* [in] [unique] */,
+ const char * domain_name /* [in] [ref] */,
+ struct GUID *domain_guid /* [in] [unique] */,
+ const char * site_name /* [in] [unique] */,
+ uint32_t flags /* [in] */,
+ struct DOMAIN_CONTROLLER_INFO **dc_info /* [out] [ref] */)
+{
+ struct DsGetDcName r;
+ struct libnetapi_ctx *ctx = NULL;
+ NET_API_STATUS status;
+ WERROR werr;
+
+ status = libnetapi_getctx(&ctx);
+ if (status != 0) {
+ return status;
+ }
+
+ /* In parameters */
+ r.in.server_name = server_name;
+ r.in.domain_name = domain_name;
+ r.in.domain_guid = domain_guid;
+ r.in.site_name = site_name;
+ r.in.flags = flags;
+
+ /* Out parameters */
+ r.out.dc_info = dc_info;
+
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_IN_DEBUG(DsGetDcName, &r);
+ }
+
+ if (LIBNETAPI_LOCAL_SERVER(server_name)) {
+ werr = DsGetDcName_l(ctx, &r);
+ } else {
+ werr = DsGetDcName_r(ctx, &r);
+ }
+
+ r.out.result = W_ERROR_V(werr);
+
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_OUT_DEBUG(DsGetDcName, &r);
+ }
+
+ return r.out.result;
+}
+
diff --git a/source/lib/netapi/libnetapi.h b/source/lib/netapi/libnetapi.h
index a215c84..99c5295 100644
--- a/source/lib/netapi/libnetapi.h
+++ b/source/lib/netapi/libnetapi.h
@@ -64,4 +64,14 @@ WERROR NetGetAnyDCName_r(struct libnetapi_ctx *ctx,
struct NetGetAnyDCName *r);
WERROR NetGetAnyDCName_l(struct libnetapi_ctx *ctx,
struct NetGetAnyDCName *r);
+NET_API_STATUS DsGetDcName(const char * server_name /* [in] [unique] */,
+ const char * domain_name /* [in] [ref] */,
+ struct GUID *domain_guid /* [in] [unique] */,
+ const char * site_name /* [in] [unique] */,
+ uint32_t flags /* [in] */,
+ struct DOMAIN_CONTROLLER_INFO **dc_info /* [out] [ref] */);
+WERROR DsGetDcName_r(struct libnetapi_ctx *ctx,
+ struct DsGetDcName *r);
+WERROR DsGetDcName_l(struct libnetapi_ctx *ctx,
+ struct DsGetDcName *r);
#endif /* __LIBNETAPI_LIBNETAPI__ */
diff --git a/source/lib/netapi/netapi.h b/source/lib/netapi/netapi.h
index 87126fb..68f2372 100644
--- a/source/lib/netapi/netapi.h
+++ b/source/lib/netapi/netapi.h
@@ -31,6 +31,37 @@ typedef enum {
/****************************************************************
****************************************************************/
+#ifndef _HEADER_misc
+
+struct GUID {
+ uint32_t time_low;
+ uint16_t time_mid;
+ uint16_t time_hi_and_version;
+ uint8_t clock_seq[2];
+ uint8_t node[6];
+};
+
+#endif /* _HEADER_misc */
+
+#ifndef _HEADER_libnetapi
+
+struct DOMAIN_CONTROLLER_INFO {
+ const char * domain_controller_name;
+ const char * domain_controller_address;
+ uint32_t domain_controller_address_type;
+ struct GUID domain_guid;
+ const char * domain_name;
+ const char * dns_foreset_name;
+ uint32_t flags;
+ const char * dc_site_name;
+ const char * client_site_name;
+};
+
+#endif /* _HEADER_libnetapi */
+
+/****************************************************************
+****************************************************************/
+
struct libnetapi_ctx {
char *debuglevel;
char *error_string;
@@ -134,4 +165,15 @@ NET_API_STATUS NetGetAnyDCName(const char * server_name /* [in] */,
const char * domain_name /* [in] */,
uint8_t **buffer /* [out] [ref] */);
+
+/****************************************************************
+ DsGetDcName
+****************************************************************/
+
+NET_API_STATUS DsGetDcName(const char * server_name /* [in] [unique] */,
+ const char * domain_name /* [in] [ref] */,
+ struct GUID *domain_guid /* [in] [unique] */,
+ const char * site_name /* [in] [unique] */,
+ uint32_t flags /* [in] */,
+ struct DOMAIN_CONTROLLER_INFO **dc_info /* [out] [ref] */);
#endif
diff --git a/source/librpc/gen_ndr/libnetapi.h b/source/librpc/gen_ndr/libnetapi.h
index 8247e9e..88fe43a 100644
--- a/source/librpc/gen_ndr/libnetapi.h
+++ b/source/librpc/gen_ndr/libnetapi.h
@@ -17,6 +17,18 @@ enum NET_API_STATUS
#endif
;
+struct DOMAIN_CONTROLLER_INFO {
+ const char * domain_controller_name;
+ const char * domain_controller_address;
+ uint32_t domain_controller_address_type;
+ struct GUID domain_guid;
+ const char * domain_name;
+ const char * dns_forest_name;
+ uint32_t flags;
+ const char * dc_site_name;
+ const char * client_site_name;
+};
+
struct NetJoinDomain {
struct {
@@ -137,4 +149,21 @@ struct NetGetAnyDCName {
};
+
+struct DsGetDcName {
+ struct {
+ const char * server_name;/* [unique] */
+ const char * domain_name;/* [ref] */
+ struct GUID *domain_guid;/* [unique] */
+ const char * site_name;/* [unique] */
+ uint32_t flags;
+ } in;
+
+ struct {
+ struct DOMAIN_CONTROLLER_INFO **dc_info;/* [ref] */
+ enum NET_API_STATUS result;
+ } out;
+
+};
+
#endif /* _HEADER_libnetapi */
diff --git a/source/librpc/gen_ndr/ndr_libnetapi.c b/source/librpc/gen_ndr/ndr_libnetapi.c
index 5dc3c3d..cca10e8 100644
--- a/source/librpc/gen_ndr/ndr_libnetapi.c
+++ b/source/librpc/gen_ndr/ndr_libnetapi.c
@@ -27,6 +27,60 @@ _PUBLIC_ void ndr_print_NET_API_STATUS(struct ndr_print *ndr, const char *name,
ndr_print_enum(ndr, name, "ENUM", val, r);
}
+_PUBLIC_ enum ndr_err_code ndr_push_DOMAIN_CONTROLLER_INFO(struct ndr_push *ndr, int ndr_flags, const struct DOMAIN_CONTROLLER_INFO *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain_controller_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain_controller_address));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->domain_controller_address_type));
+ NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_guid));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->domain_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->dns_forest_name));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->flags));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->dc_site_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->client_site_name));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_DOMAIN_CONTROLLER_INFO(struct ndr_pull *ndr, int ndr_flags, struct DOMAIN_CONTROLLER_INFO *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain_controller_name));
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain_controller_address));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->domain_controller_address_type));
+ NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_guid));
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->domain_name));
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->dns_forest_name));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->flags));
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->dc_site_name));
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->client_site_name));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_DOMAIN_CONTROLLER_INFO(struct ndr_print *ndr, const char *name, const struct DOMAIN_CONTROLLER_INFO *r)
+{
+ ndr_print_struct(ndr, name, "DOMAIN_CONTROLLER_INFO");
+ ndr->depth++;
+ ndr_print_string(ndr, "domain_controller_name", r->domain_controller_name);
+ ndr_print_string(ndr, "domain_controller_address", r->domain_controller_address);
+ ndr_print_uint32(ndr, "domain_controller_address_type", r->domain_controller_address_type);
+ ndr_print_GUID(ndr, "domain_guid", &r->domain_guid);
+ ndr_print_string(ndr, "domain_name", r->domain_name);
+ ndr_print_string(ndr, "dns_forest_name", r->dns_forest_name);
+ ndr_print_uint32(ndr, "flags", r->flags);
+ ndr_print_string(ndr, "dc_site_name", r->dc_site_name);
+ ndr_print_string(ndr, "client_site_name", r->client_site_name);
+ ndr->depth--;
+}
+
_PUBLIC_ void ndr_print_NetJoinDomain(struct ndr_print *ndr, const char *name, int flags, const struct NetJoinDomain *r)
{
ndr_print_struct(ndr, name, "NetJoinDomain");
@@ -375,3 +429,56 @@ _PUBLIC_ void ndr_print_NetGetAnyDCName(struct ndr_print *ndr, const char *name,
ndr->depth--;
}
+_PUBLIC_ void ndr_print_DsGetDcName(struct ndr_print *ndr, const char *name, int flags, const struct DsGetDcName *r)
+{
+ ndr_print_struct(ndr, name, "DsGetDcName");
+ ndr->depth++;
+ if (flags & NDR_SET_VALUES) {
+ ndr->flags |= LIBNDR_PRINT_SET_VALUES;
+ }
+ if (flags & NDR_IN) {
+ ndr_print_struct(ndr, "in", "DsGetDcName");
+ ndr->depth++;
+ ndr_print_ptr(ndr, "server_name", r->in.server_name);
+ ndr->depth++;
+ if (r->in.server_name) {
+ ndr_print_string(ndr, "server_name", r->in.server_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "domain_name", r->in.domain_name);
+ ndr->depth++;
+ ndr_print_string(ndr, "domain_name", r->in.domain_name);
+ ndr->depth--;
+ ndr_print_ptr(ndr, "domain_guid", r->in.domain_guid);
+ ndr->depth++;
+ if (r->in.domain_guid) {
+ ndr_print_GUID(ndr, "domain_guid", r->in.domain_guid);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "site_name", r->in.site_name);
+ ndr->depth++;
+ if (r->in.site_name) {
+ ndr_print_string(ndr, "site_name", r->in.site_name);
+ }
+ ndr->depth--;
+ ndr_print_uint32(ndr, "flags", r->in.flags);
+ ndr->depth--;
+ }
+ if (flags & NDR_OUT) {
+ ndr_print_struct(ndr, "out", "DsGetDcName");
+ ndr->depth++;
+ ndr_print_ptr(ndr, "dc_info", r->out.dc_info);
+ ndr->depth++;
+ ndr_print_ptr(ndr, "dc_info", *r->out.dc_info);
+ ndr->depth++;
+ if (*r->out.dc_info) {
+ ndr_print_DOMAIN_CONTROLLER_INFO(ndr, "dc_info", *r->out.dc_info);
+ }
+ ndr->depth--;
+ ndr->depth--;
+ ndr_print_NET_API_STATUS(ndr, "result", r->out.result);
+ ndr->depth--;
+ }
+ ndr->depth--;
+}
+
diff --git a/source/librpc/gen_ndr/ndr_libnetapi.h b/source/librpc/gen_ndr/ndr_libnetapi.h
index 890c7d0..eff4f6d 100644
--- a/source/librpc/gen_ndr/ndr_libnetapi.h
+++ b/source/librpc/gen_ndr/ndr_libnetapi.h
@@ -22,10 +22,15 @@
--
Samba Shared Repository
More information about the samba-cvs
mailing list