svn commit: samba r3914 - in branches/SAMBA_4_0/source: librpc/idl
rpc_server/netlogon torture/rpc
metze at samba.org
metze at samba.org
Mon Nov 22 17:14:57 GMT 2004
Author: metze
Date: 2004-11-22 17:14:57 +0000 (Mon, 22 Nov 2004)
New Revision: 3914
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=3914
Log:
add idl, torture test and simple server for netr_DrsGetDCNameEx2()
metze
Modified:
branches/SAMBA_4_0/source/librpc/idl/netlogon.idl
branches/SAMBA_4_0/source/rpc_server/netlogon/dcerpc_netlogon.c
branches/SAMBA_4_0/source/torture/rpc/netlogon.c
Changeset:
Modified: branches/SAMBA_4_0/source/librpc/idl/netlogon.idl
===================================================================
--- branches/SAMBA_4_0/source/librpc/idl/netlogon.idl 2004-11-22 17:08:25 UTC (rev 3913)
+++ branches/SAMBA_4_0/source/librpc/idl/netlogon.idl 2004-11-22 17:14:57 UTC (rev 3914)
@@ -1007,8 +1007,29 @@
/****************/
/* Function 0x22 */
- WERROR netr_DSRGETDCNAMEEX2();
+ typedef struct {
+ unistr *dc_unc;
+ unistr *dc_address;
+ int32 dc_address_type;
+ GUID domain_guid;
+ unistr *domain_name;
+ unistr *forest_name;
+ uint32 dc_flags;
+ unistr *dc_site_name;
+ unistr *client_site_name;
+ } netr_DrsGetDCNameEx2Info;
+ WERROR netr_DrsGetDCNameEx2(
+ [in] unistr *server_unc,
+ [in] unistr *client_account,
+ [in] uint32 mask,
+ [in] unistr *domain_name,
+ [in] GUID *domain_guid,
+ [in] unistr *site_name,
+ [in] uint32 flags,
+ [out] netr_DrsGetDCNameEx2Info *info
+ );
+
/****************/
/* Function 0x23 */
WERROR netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN();
Modified: branches/SAMBA_4_0/source/rpc_server/netlogon/dcerpc_netlogon.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/netlogon/dcerpc_netlogon.c 2004-11-22 17:08:25 UTC (rev 3913)
+++ branches/SAMBA_4_0/source/rpc_server/netlogon/dcerpc_netlogon.c 2004-11-22 17:14:57 UTC (rev 3914)
@@ -1045,12 +1045,49 @@
/*
- netr_DSRGETDCNAMEEX2
+ netr_DrsGetDCNameEx2
*/
-static WERROR netr_DSRGETDCNAMEEX2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct netr_DSRGETDCNAMEEX2 *r)
+static WERROR netr_DrsGetDCNameEx2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct netr_DrsGetDCNameEx2 *r)
{
- DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+ const char * const attrs[] = { "dnsDomain", "objectGUID", NULL };
+ void *sam_ctx;
+ struct ldb_message **res;
+ int ret;
+
+ ZERO_STRUCT(r->out);
+
+ sam_ctx = samdb_connect(mem_ctx);
+ if (sam_ctx == NULL) {
+ return WERR_DS_SERVICE_UNAVAILABLE;
+ }
+
+ ret = samdb_search(sam_ctx, mem_ctx, NULL, &res, attrs,
+ "(&(objectClass=domainDNS)(dnsDomain=%s))",
+ r->in.domain_name);
+ if (ret != 1) {
+ return WERR_NO_SUCH_DOMAIN;
+ }
+
+ r->out.info = talloc_p(mem_ctx, struct netr_DrsGetDCNameEx2Info);
+ if (!r->out.info) {
+ return WERR_NOMEM;
+ }
+
+ /* TODO: - return real IP address
+ * - check all r->in.* parameters (server_unc is ignored by w2k3!)
+ */
+ r->out.info->dc_unc = talloc_asprintf(mem_ctx, "\\\\%s.%s", lp_netbios_name(),lp_realm());
+ r->out.info->dc_address = talloc_strdup(mem_ctx, "\\\\0.0.0.0");
+ r->out.info->dc_address_type = 1;
+ r->out.info->domain_guid = samdb_result_guid(res[0], "objectGUID");
+ r->out.info->domain_name = samdb_result_string(res[0], "dnsDomain", NULL);
+ r->out.info->forest_name = samdb_result_string(res[0], "dnsDomain", NULL);
+ r->out.info->dc_flags = 0xE00001FD;
+ r->out.info->dc_site_name = talloc_strdup(mem_ctx, "Default-First-Site-Name");
+ r->out.info->client_site_name = talloc_strdup(mem_ctx, "Default-First-Site-Name");
+
+ return WERR_OK;
}
Modified: branches/SAMBA_4_0/source/torture/rpc/netlogon.c
===================================================================
--- branches/SAMBA_4_0/source/torture/rpc/netlogon.c 2004-11-22 17:08:25 UTC (rev 3913)
+++ branches/SAMBA_4_0/source/torture/rpc/netlogon.c 2004-11-22 17:14:57 UTC (rev 3914)
@@ -887,7 +887,47 @@
return True;
}
+/*
+ try a netlogon netr_DrsGetDCNameEx2
+*/
+static BOOL test_netr_DrsGetDCNameEx2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+{
+ NTSTATUS status;
+ struct netr_DrsGetDCNameEx2 r;
+ BOOL ret = True;
+ r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p));
+ r.in.client_account = NULL;
+ r.in.mask = 0x00000000;
+ r.in.domain_name = talloc_asprintf(mem_ctx, "%s", lp_realm());
+ r.in.domain_guid = NULL;
+ r.in.site_name = NULL;
+ r.in.flags = 0x40000000;
+
+ printf("Testing netr_DrsGetDCNameEx2 without client account\n");
+
+ status = dcerpc_netr_DrsGetDCNameEx2(p, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
+ printf("netr_DrsGetDCNameEx2 - %s/%s\n",
+ nt_errstr(status), win_errstr(r.out.result));
+ ret = False;
+ }
+
+ printf("Testing netr_DrsGetDCNameEx2 with client acount\n");
+ r.in.client_account = TEST_MACHINE_NAME"$";
+ r.in.mask = 0x00002000;
+ r.in.flags = 0x80000000;
+
+ status = dcerpc_netr_DrsGetDCNameEx2(p, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
+ printf("netr_DrsGetDCNameEx2 - %s/%s\n",
+ nt_errstr(status), win_errstr(r.out.result));
+ ret = False;
+ }
+
+ return ret;
+}
+
static BOOL test_GetDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
@@ -1122,6 +1162,10 @@
ret = False;
}
+ if (!test_netr_DrsGetDCNameEx2(p, mem_ctx)) {
+ ret = False;
+ }
+
talloc_destroy(mem_ctx);
torture_rpc_close(p);
More information about the samba-cvs
mailing list