[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-2376-g4b3617b

Günther Deschner gd at samba.org
Fri May 9 16:11:29 GMT 2008


The branch, v3-3-test has been updated
       via  4b3617bf505a835a6d4bb9b80c4ad837a2082dea (commit)
       via  5b0eda98f3d127399770f7a037ad3277dbe23393 (commit)
       via  5a216d2340bb06a8866718d1b4b07265006bd900 (commit)
       via  a56d7999a445f7157f85e5636f5b2c5e471a98e2 (commit)
       via  5e91bd1d2bfe458c6f8b3696f99e0f75e43cbae8 (commit)
       via  7889516a384c155a9045aad4409c041fddd0d98d (commit)
       via  2c0a96f1e5fc065fdbeb5671cfa693009321dde8 (commit)
       via  82cbb3269b2e764c9c2a2fbcbe9c29feae07fb62 (commit)
       via  dbf96120d8b33e592bfd3e9df1777f1670e218be (commit)
       via  eb7fee6e2a00326c03aa013058247e06279a4930 (commit)
       via  56be9c98d24e64bf855439df21766d30f448f407 (commit)
       via  c67b6dc0ca866781043e443177d550e23b83ae36 (commit)
       via  4b56c294e8ba045c84cab538b3d286e433d292ed (commit)
       via  847f258632f6d49a3fd45f466c5d3d8c6222ff85 (commit)
       via  d13fe66f3d9ba152e3e8197ee6682e175163a6cd (commit)
       via  f48b2e844b673e99c84cb24f3c3718352ab93ce5 (commit)
       via  fe904ee77a7fec1674e9db660978c40c17897f77 (commit)
       via  bc0d7a90dcc7bf702b24feb16abf4634ff178671 (commit)
       via  1009123b8600e6ccebe180f4a2f87c217638fef8 (commit)
       via  a3e5b073f0474543ca74b40775ce1d7f80719c96 (commit)
       via  9db2e50a20caabaf90ce03203a066ddd7820d33a (commit)
       via  3c05c56d4c0aac8106684cda3152c65299c63075 (commit)
       via  6f9d5e1cc94bc90685b54c04622b8f3357bd2f69 (commit)
       via  95fb01d8702342265f8837a368dc42f4a4d394d5 (commit)
       via  1809ea22c31ee28e109f49701f91534177027165 (commit)
      from  687275cd532f8f8ad710acd222a0c76625da53c6 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test


- Log -----------------------------------------------------------------
commit 4b3617bf505a835a6d4bb9b80c4ad837a2082dea
Author: Günther Deschner <gd at samba.org>
Date:   Fri May 9 17:56:04 2008 +0200

    dsgetdcname: add reminder that we need to support ipv6 here once we know how.
    
    Guenther

commit 5b0eda98f3d127399770f7a037ad3277dbe23393
Author: Günther Deschner <gd at samba.org>
Date:   Fri May 9 17:41:50 2008 +0200

    dsgetdcname: make use of nbt_cldap_netlogon_15.
    
    Guenther

commit 5a216d2340bb06a8866718d1b4b07265006bd900
Author: Günther Deschner <gd at samba.org>
Date:   Fri May 9 17:40:29 2008 +0200

    re-run make idl.
    
    Guenther

commit a56d7999a445f7157f85e5636f5b2c5e471a98e2
Author: Günther Deschner <gd at samba.org>
Date:   Fri May 9 17:39:53 2008 +0200

    IDL: Fix nbt_cldap_netlogon union, removing the default member.
    
    Guenther

commit 5e91bd1d2bfe458c6f8b3696f99e0f75e43cbae8
Author: Günther Deschner <gd at samba.org>
Date:   Fri May 9 17:24:38 2008 +0200

    IDL: Add nbt_cldap_netlogon_15.
    
    Guenther

commit 7889516a384c155a9045aad4409c041fddd0d98d
Author: Günther Deschner <gd at samba.org>
Date:   Thu May 8 18:32:22 2008 +0200

    dsgetdcname: use existing messaging_context if possible.
    
    Guenther

commit 2c0a96f1e5fc065fdbeb5671cfa693009321dde8
Author: Günther Deschner <gd at samba.org>
Date:   Thu May 8 14:24:46 2008 +0200

    dsgetdcname: the forest name should never be empty.
    
    Guenther

commit 82cbb3269b2e764c9c2a2fbcbe9c29feae07fb62
Author: Günther Deschner <gd at samba.org>
Date:   Thu May 8 14:23:20 2008 +0200

    Use strip_hostname after dsgetdcname/getdcname calls.
    
    Guenther

commit dbf96120d8b33e592bfd3e9df1777f1670e218be
Author: Günther Deschner <gd at samba.org>
Date:   Thu May 8 14:16:50 2008 +0200

    util: add strip_hostname() to strip of leading '\\'.
    
    Guenther

commit eb7fee6e2a00326c03aa013058247e06279a4930
Author: Günther Deschner <gd at samba.org>
Date:   Thu May 8 12:16:04 2008 +0200

    dsgetdcname: add map_dc_and_domain_names() for consolidating returned names.
    
    Guenther

commit 56be9c98d24e64bf855439df21766d30f448f407
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 21:31:59 2008 +0200

    cldap: move out cldap object to fix the build.
    
    Guenther

commit c67b6dc0ca866781043e443177d550e23b83ae36
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 21:25:05 2008 +0200

    dsgetdcname: fix gencache store for dsgetdcname().
    
    While storing always a type 29 reply structure in gencache, we are now able to
    deliver correct data according to return flags such as DS_RETURN_FLAT_NAME and
    DS_RETURN_DNS_NAME out of the cached data from gencache.
    
    Guenther

commit 4b56c294e8ba045c84cab538b3d286e433d292ed
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 21:08:20 2008 +0200

    dsgetdcname: pure cosmetics.
    
    Guenther

commit 847f258632f6d49a3fd45f466c5d3d8c6222ff85
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 21:06:23 2008 +0200

    dsgetdcname: simply call ourself with DS_FORCE_REDISCOVERY after cache expiry.
    
    Guenther

commit d13fe66f3d9ba152e3e8197ee6682e175163a6cd
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 21:04:10 2008 +0200

    dsgetdcname: be more paranoid about the existance of an ip_address.
    
    Guenther

commit f48b2e844b673e99c84cb24f3c3718352ab93ce5
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 21:02:50 2008 +0200

    dsgetdcname: remove invalid assumption in discover_dc_dns().
    
    Guenther

commit fe904ee77a7fec1674e9db660978c40c17897f77
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 18:57:43 2008 +0200

    dsgetdcname: mailslot replies are identical to the cldap ones, use cldap everywhere.
    
    Guenther

commit bc0d7a90dcc7bf702b24feb16abf4634ff178671
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 18:55:45 2008 +0200

    dsgetdcname: wait a little longer for mailslot replies.
    
    Guenther

commit 1009123b8600e6ccebe180f4a2f87c217638fef8
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 18:39:24 2008 +0200

    dsgetdcname: map additional flags to nt_version.
    
    Guenther

commit a3e5b073f0474543ca74b40775ce1d7f80719c96
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 18:38:37 2008 +0200

    dsgetdcname: use make_dc_info_from_cldap_reply() for cldap replies.
    
    Guenther

commit 9db2e50a20caabaf90ce03203a066ddd7820d33a
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 18:36:03 2008 +0200

    dsgetdcname: add make_dc_info_from_cldap_reply().
    
    Guenther

commit 3c05c56d4c0aac8106684cda3152c65299c63075
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 16:49:39 2008 +0200

    dsgetdcname: add get_cldap_reply_server_flags().
    
    Guenther

commit 6f9d5e1cc94bc90685b54c04622b8f3357bd2f69
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 15:49:09 2008 +0200

    cldap: let ads_cldap_netlogon() return all possible cldap replies.
    
    Guenther

commit 95fb01d8702342265f8837a368dc42f4a4d394d5
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 15:21:41 2008 +0200

    dsgetdcname: add pull_mailslot_cldap_reply().
    
    Guenther

commit 1809ea22c31ee28e109f49701f91534177027165
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 7 14:38:35 2008 +0200

    dsgetdcname: add map_ds_flags_to_nt_version.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 source/Makefile.in                  |    7 +-
 source/lib/netapi/getdc.c           |    1 +
 source/lib/netapi/joindomain.c      |   23 +-
 source/lib/util.c                   |   19 +
 source/libads/cldap.c               |  153 +++++++-
 source/libads/ldap.c                |    2 +-
 source/libnet/libnet_join.c         |   12 +-
 source/librpc/gen_ndr/libnet_join.h |    2 +
 source/librpc/gen_ndr/nbt.h         |   22 +-
 source/librpc/gen_ndr/ndr_nbt.c     |  365 +++++++++++++++++-
 source/librpc/gen_ndr/ndr_nbt.h     |    3 +
 source/librpc/idl/libnet_join.idl   |    2 +
 source/librpc/idl/nbt.idl           |   36 ++-
 source/libsmb/clidgram.c            |   62 ++-
 source/libsmb/dsgetdcname.c         |  760 +++++++++++++++++++++++++++--------
 source/rpc_server/srv_wkssvc_nt.c   |    2 +
 source/utils/net_ads.c              |    4 +-
 source/utils/net_lookup.c           |    2 +-
 source/winbindd/winbindd_cm.c       |    9 +-
 source/winbindd/winbindd_locator.c  |   10 +-
 20 files changed, 1257 insertions(+), 239 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/Makefile.in b/source/Makefile.in
index 3ad6315..7e316ee 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -393,7 +393,7 @@ LIBADS_OBJ = libads/ldap.o libads/ldap_printer.o \
 	     libads/krb5_setpw.o libads/ldap_user.o \
 	     libads/ads_struct.o libads/kerberos_keytab.o \
              libads/disp_sec.o libads/ads_utils.o libads/ldap_utils.o \
-	     libads/cldap.o libads/ldap_schema.o libads/util.o libads/ndr.o
+	     libads/ldap_schema.o libads/util.o libads/ndr.o
 
 LIBADS_SERVER_OBJ = libads/kerberos_verify.o libads/authdata.o \
 		    librpc/ndr/ndr_krb5pac.o \
@@ -428,6 +428,8 @@ LIBSMB_OBJ0 = \
 LIBSAMBA_OBJ = $(LIBSMB_OBJ0) \
 	       $(LIBSMB_ERR_OBJ)
 
+CLDAP_OBJ = libads/cldap.o
+
 LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
 	     libsmb/clikrb5.o libsmb/clispnego.o libsmb/asn1.o \
 	     libsmb/clirap.o libsmb/clierror.o libsmb/climessage.o \
@@ -439,7 +441,8 @@ LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
 	     libsmb/smb_seal.o libsmb/async_smb.o \
 	     $(LIBSAMBA_OBJ) \
 	     $(LIBNMB_OBJ) \
-	     $(LIBNBT_OBJ)
+	     $(LIBNBT_OBJ) \
+	     $(CLDAP_OBJ)
 
 RPC_CLIENT_OBJ1 = rpc_client/cli_netlogon.o
 
diff --git a/source/lib/netapi/getdc.c b/source/lib/netapi/getdc.c
index 38aaf0e..c1d021b 100644
--- a/source/lib/netapi/getdc.c
+++ b/source/lib/netapi/getdc.c
@@ -118,6 +118,7 @@ WERROR DsGetDcName_l(struct libnetapi_ctx *ctx,
 	NTSTATUS status;
 
 	status = dsgetdcname(ctx,
+			     NULL,
 			     r->in.domain_name,
 			     r->in.domain_guid,
 			     r->in.site_name,
diff --git a/source/lib/netapi/joindomain.c b/source/lib/netapi/joindomain.c
index 74ed8f2..66f7cfb 100644
--- a/source/lib/netapi/joindomain.c
+++ b/source/lib/netapi/joindomain.c
@@ -47,18 +47,20 @@ WERROR NetJoinDomain_l(struct libnetapi_ctx *mem_ctx,
 	if (r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) {
 		NTSTATUS status;
 		struct netr_DsRGetDCNameInfo *info = NULL;
+		const char *dc = NULL;
 		uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
 				 DS_WRITABLE_REQUIRED |
 				 DS_RETURN_DNS_NAME;
-		status = dsgetdcname(mem_ctx, r->in.domain,
+		status = dsgetdcname(mem_ctx, NULL, r->in.domain,
 				     NULL, NULL, flags, &info);
 		if (!NT_STATUS_IS_OK(status)) {
 			libnetapi_set_error_string(mem_ctx,
 				"%s", get_friendly_nt_error_msg(status));
 			return ntstatus_to_werror(status);
 		}
-		j->in.dc_name = talloc_strdup(mem_ctx,
-					      info->dc_unc);
+
+		dc = strip_hostname(info->dc_unc);
+		j->in.dc_name = talloc_strdup(mem_ctx, dc);
 		W_ERROR_HAVE_NO_MEMORY(j->in.dc_name);
 	}
 
@@ -174,10 +176,11 @@ WERROR NetUnjoinDomain_l(struct libnetapi_ctx *mem_ctx,
 	} else {
 		NTSTATUS status;
 		struct netr_DsRGetDCNameInfo *info = NULL;
+		const char *dc = NULL;
 		uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
 				 DS_WRITABLE_REQUIRED |
 				 DS_RETURN_DNS_NAME;
-		status = dsgetdcname(mem_ctx, domain,
+		status = dsgetdcname(mem_ctx, NULL, domain,
 				     NULL, NULL, flags, &info);
 		if (!NT_STATUS_IS_OK(status)) {
 			libnetapi_set_error_string(mem_ctx,
@@ -186,8 +189,9 @@ WERROR NetUnjoinDomain_l(struct libnetapi_ctx *mem_ctx,
 				get_friendly_nt_error_msg(status));
 			return ntstatus_to_werror(status);
 		}
-		u->in.dc_name = talloc_strdup(mem_ctx,
-					      info->dc_unc);
+
+		dc = strip_hostname(info->dc_unc);
+		u->in.dc_name = talloc_strdup(mem_ctx, dc);
 		W_ERROR_HAVE_NO_MEMORY(u->in.dc_name);
 
 		u->in.domain_name = domain;
@@ -352,10 +356,11 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx,
 	ADS_STATUS ads_status;
 	ADS_STRUCT *ads = NULL;
 	struct netr_DsRGetDCNameInfo *info = NULL;
+	const char *dc = NULL;
 	uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
 			 DS_RETURN_DNS_NAME;
 
-	status = dsgetdcname(ctx, r->in.domain,
+	status = dsgetdcname(ctx, NULL, r->in.domain,
 			     NULL, NULL, flags, &info);
 	if (!NT_STATUS_IS_OK(status)) {
 		libnetapi_set_error_string(ctx, "%s",
@@ -363,7 +368,9 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx,
 		return ntstatus_to_werror(status);
 	}
 
-	ads = ads_init(r->in.domain, r->in.domain, info->dc_unc);
+	dc = strip_hostname(info->dc_unc);
+
+	ads = ads_init(r->in.domain, r->in.domain, dc);
 	if (!ads) {
 		return WERR_GENERAL_FAILURE;
 	}
diff --git a/source/lib/util.c b/source/lib/util.c
index a137d7c..a6b436c 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -3453,3 +3453,22 @@ bool is_valid_policy_hnd(const POLICY_HND *hnd)
 	return (memcmp(&tmp, hnd, sizeof(tmp)) != 0);
 }
 
+/****************************************************************
+ strip off leading '\\' from a hostname
+****************************************************************/
+
+const char *strip_hostname(const char *s)
+{
+	if (!s) {
+		return NULL;
+	}
+
+	if (strlen_m(s) < 3) {
+		return s;
+	}
+
+	if (s[0] == '\\') s++;
+	if (s[0] == '\\') s++;
+
+	return s;
+}
diff --git a/source/libads/cldap.c b/source/libads/cldap.c
index 8b23ff9..efe13cc 100644
--- a/source/libads/cldap.c
+++ b/source/libads/cldap.c
@@ -3,6 +3,7 @@
    net ads cldap functions 
    Copyright (C) 2001 Andrew Tridgell (tridge at samba.org)
    Copyright (C) 2003 Jim McDonough (jmcd at us.ibm.com)
+   Copyright (C) 2008 Guenther Deschner (gd at samba.org)
 
    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
@@ -118,7 +119,8 @@ static void gotalarm_sig(void)
 */
 static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx,
 			       int sock,
-			       struct nbt_cldap_netlogon_5 *reply)
+			       uint32_t *nt_version,
+			       union nbt_cldap_netlogon **reply)
 {
 	int ret;
 	ASN1_DATA data;
@@ -129,8 +131,7 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx,
 	int i1;
 	/* half the time of a regular ldap timeout, not less than 3 seconds. */
 	unsigned int al_secs = MAX(3,lp_ldap_timeout()/2);
-	union nbt_cldap_netlogon p;
-	enum ndr_err_code ndr_err;
+	union nbt_cldap_netlogon *r = NULL;
 
 	blob = data_blob(NULL, 8192);
 	if (blob.data == NULL) {
@@ -184,16 +185,23 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx,
 		return -1;
 	}
 
-	ndr_err = ndr_pull_union_blob_all(&os3, mem_ctx, &p, 5,
-		       (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon);
-	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+	r = TALLOC_ZERO_P(mem_ctx, union nbt_cldap_netlogon);
+	if (!r) {
+		errno = ENOMEM;
+		data_blob_free(&os1);
+		data_blob_free(&os2);
+		data_blob_free(&os3);
+		data_blob_free(&blob);
 		return -1;
 	}
 
-	*reply = p.logon5;
-
-	if (DEBUGLEVEL >= 10) {
-		NDR_PRINT_UNION_DEBUG(nbt_cldap_netlogon, 5, &p);
+	if (!pull_mailslot_cldap_reply(mem_ctx, &os3, r, nt_version)) {
+		data_blob_free(&os1);
+		data_blob_free(&os2);
+		data_blob_free(&os3);
+		data_blob_free(&blob);
+		TALLOC_FREE(r);
+		return -1;
 	}
 
 	data_blob_free(&os1);
@@ -203,6 +211,12 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx,
 	
 	asn1_free(&data);
 
+	if (reply) {
+		*reply = r;
+	} else {
+		TALLOC_FREE(r);
+	}
+
 	return 0;
 }
 
@@ -213,11 +227,11 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx,
 bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx,
 			const char *server,
 			const char *realm,
-			struct nbt_cldap_netlogon_5 *reply)
+			uint32_t *nt_version,
+			union nbt_cldap_netlogon **reply)
 {
 	int sock;
 	int ret;
-	uint32_t nt_version = NETLOGON_VERSION_5 | NETLOGON_VERSION_5EX;
 
 	sock = open_udp_socket(server, LDAP_PORT );
 	if (sock == -1) {
@@ -226,12 +240,12 @@ bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx,
 		return False;
 	}
 
-	ret = send_cldap_netlogon(sock, realm, global_myname(), nt_version);
+	ret = send_cldap_netlogon(sock, realm, global_myname(), *nt_version);
 	if (ret != 0) {
 		close(sock);
 		return False;
 	}
-	ret = recv_cldap_netlogon(mem_ctx, sock, reply);
+	ret = recv_cldap_netlogon(mem_ctx, sock, nt_version, reply);
 	close(sock);
 
 	if (ret == -1) {
@@ -240,3 +254,114 @@ bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx,
 
 	return True;
 }
+
+/*******************************************************************
+  do a cldap netlogon query.  Always 389/udp
+*******************************************************************/
+
+bool ads_cldap_netlogon_5(TALLOC_CTX *mem_ctx,
+			  const char *server,
+			  const char *realm,
+			  struct nbt_cldap_netlogon_5 *reply5)
+{
+	uint32_t nt_version = NETLOGON_VERSION_5 | NETLOGON_VERSION_5EX;
+	union nbt_cldap_netlogon *reply = NULL;
+	bool ret;
+
+	ret = ads_cldap_netlogon(mem_ctx, server, realm, &nt_version, &reply);
+	if (!ret) {
+		return false;
+	}
+
+	if (nt_version != (NETLOGON_VERSION_5 | NETLOGON_VERSION_5EX)) {
+		return false;
+	}
+
+	*reply5 = reply->logon5;
+
+	return true;
+}
+
+/****************************************************************
+****************************************************************/
+
+bool pull_mailslot_cldap_reply(TALLOC_CTX *mem_ctx,
+			       const DATA_BLOB *blob,
+			       union nbt_cldap_netlogon *r,
+			       uint32_t *nt_version)
+{
+	enum ndr_err_code ndr_err;
+	uint32_t nt_version_query = ((*nt_version) & 0x0000001f);
+	uint16_t command = 0;
+
+	ndr_err = ndr_pull_struct_blob(blob, mem_ctx, &command,
+			(ndr_pull_flags_fn_t)ndr_pull_uint16);
+	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+		return false;
+	}
+
+	switch (command) {
+		case 0x13: /* 19 */
+		case 0x15: /* 21 */
+		case 0x17: /* 23 */
+			 break;
+		default:
+			DEBUG(1,("got unexpected command: %d (0x%08x)\n",
+				command, command));
+			return false;
+	}
+
+	ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query,
+		       (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon);
+	if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+		goto done;
+	}
+
+	/* when the caller requested just those nt_version bits that the server
+	 * was able to reply to, we are fine and all done. otherwise we need to
+	 * assume downgraded replies which are painfully parsed here - gd */
+
+	if (nt_version_query & NETLOGON_VERSION_WITH_CLOSEST_SITE) {
+		nt_version_query &= ~NETLOGON_VERSION_WITH_CLOSEST_SITE;
+	}
+	ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query,
+		       (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon);
+	if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+		goto done;
+	}
+	if (nt_version_query & NETLOGON_VERSION_5EX_WITH_IP) {
+		nt_version_query &= ~NETLOGON_VERSION_5EX_WITH_IP;
+	}
+	ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query,
+		       (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon);
+	if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+		goto done;
+	}
+	if (nt_version_query & NETLOGON_VERSION_5EX) {
+		nt_version_query &= ~NETLOGON_VERSION_5EX;
+	}
+	ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query,
+		       (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon);
+	if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+		goto done;
+	}
+	if (nt_version_query & NETLOGON_VERSION_5) {
+		nt_version_query &= ~NETLOGON_VERSION_5;
+	}
+	ndr_err = ndr_pull_union_blob_all(blob, mem_ctx, r, nt_version_query,
+		       (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon);
+	if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+		goto done;
+	}
+
+	return false;
+
+ done:
+	if (DEBUGLEVEL >= 10) {
+		NDR_PRINT_UNION_DEBUG(nbt_cldap_netlogon, nt_version_query, r);
+	}
+
+	*nt_version = nt_version_query;
+
+	return true;
+}
diff --git a/source/libads/ldap.c b/source/libads/ldap.c
index 9321302..24eb114 100644
--- a/source/libads/ldap.c
+++ b/source/libads/ldap.c
@@ -199,7 +199,7 @@ bool ads_try_connect(ADS_STRUCT *ads, const char *server )
 
 	ZERO_STRUCT( cldap_reply );
 
-	if ( !ads_cldap_netlogon(mem_ctx, srv, ads->server.realm, &cldap_reply ) ) {
+	if ( !ads_cldap_netlogon_5(mem_ctx, srv, ads->server.realm, &cldap_reply ) ) {
 		DEBUG(3,("ads_try_connect: CLDAP request %s failed.\n", srv));
 		ret = false;
 		goto out;
diff --git a/source/libnet/libnet_join.c b/source/libnet/libnet_join.c
index 7e348e2..36700b2 100644
--- a/source/libnet/libnet_join.c
+++ b/source/libnet/libnet_join.c
@@ -1620,7 +1620,9 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx,
 
 	if (!r->in.dc_name) {
 		struct netr_DsRGetDCNameInfo *info;
+		const char *dc;
 		status = dsgetdcname(mem_ctx,
+				     r->in.msg_ctx,
 				     r->in.domain_name,
 				     NULL,
 				     NULL,
@@ -1636,8 +1638,8 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx,
 			return WERR_DOMAIN_CONTROLLER_NOT_FOUND;
 		}
 
-		r->in.dc_name = talloc_strdup(mem_ctx,
-					      info->dc_unc);
+		dc = strip_hostname(info->dc_unc);
+		r->in.dc_name = talloc_strdup(mem_ctx, dc);
 		W_ERROR_HAVE_NO_MEMORY(r->in.dc_name);
 	}
 
@@ -1775,7 +1777,9 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx,
 
 	if (!r->in.dc_name) {
 		struct netr_DsRGetDCNameInfo *info;
+		const char *dc;
 		status = dsgetdcname(mem_ctx,
+				     r->in.msg_ctx,
 				     r->in.domain_name,
 				     NULL,
 				     NULL,
@@ -1791,8 +1795,8 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx,
 			return WERR_DOMAIN_CONTROLLER_NOT_FOUND;
 		}
 
-		r->in.dc_name = talloc_strdup(mem_ctx,
-					      info->dc_unc);
+		dc = strip_hostname(info->dc_unc);
+		r->in.dc_name = talloc_strdup(mem_ctx, dc);
 		W_ERROR_HAVE_NO_MEMORY(r->in.dc_name);
 	}
 
diff --git a/source/librpc/gen_ndr/libnet_join.h b/source/librpc/gen_ndr/libnet_join.h
index 0415f03..e5ec438 100644
--- a/source/librpc/gen_ndr/libnet_join.h
+++ b/source/librpc/gen_ndr/libnet_join.h
@@ -28,6 +28,7 @@ struct libnet_JoinCtx {
 		struct ads_struct *ads;/* [ref] */
 		uint8_t debug;
 		enum netr_SchannelType secure_channel_type;
+		struct messaging_context *msg_ctx;/* [noprint,ref] */
 	} in;
 
 	struct {
@@ -59,6 +60,7 @@ struct libnet_UnjoinCtx {
 		struct dom_sid *domain_sid;/* [ref] */
 		struct ads_struct *ads;/* [ref] */
 		uint8_t debug;
+		struct messaging_context *msg_ctx;/* [noprint,ref] */
 	} in;
 
 	struct {
diff --git a/source/librpc/gen_ndr/nbt.h b/source/librpc/gen_ndr/nbt.h
index bf0c467..b77b7c3 100644
--- a/source/librpc/gen_ndr/nbt.h
+++ b/source/librpc/gen_ndr/nbt.h
@@ -598,6 +598,25 @@ struct nbt_cldap_netlogon_13 {
 	uint16_t lm20_token;
 };
 
+struct nbt_cldap_netlogon_15 {
+	enum nbt_netlogon_command type;
+	uint16_t sbz;
+	uint32_t server_type;
+	struct GUID domain_uuid;
+	const char * forest;
+	const char * dns_domain;
+	const char * pdc_dns_name;
+	const char * domain;
+	const char * pdc_name;
+	const char * user_name;
+	const char * server_site;
+	const char * client_site;
+	const char * next_closest_site;
+	uint32_t nt_version;/* [value(15)] */
+	uint16_t lmnt_token;
+	uint16_t lm20_token;
+}/* [public] */;
+
 struct nbt_cldap_netlogon_29 {
 	enum nbt_netlogon_command type;
 	uint16_t sbz;
@@ -624,7 +643,8 @@ union nbt_cldap_netlogon {
 	struct nbt_cldap_netlogon_3 logon3;/* [case(2)] */
 	struct nbt_cldap_netlogon_5 logon5;/* [case(4)] */
 	struct nbt_cldap_netlogon_13 logon13;/* [case(8)] */
-	struct nbt_cldap_netlogon_29 logon29;/* [default] */
+	struct nbt_cldap_netlogon_15 logon15;/* [case(20)] */
+	struct nbt_cldap_netlogon_29 logon29;/* [case(29)] */
 }/* [public,nodiscriminant,flag(LIBNDR_FLAG_NOALIGN)] */;
 
 enum nbt_ntlogon_command
diff --git a/source/librpc/gen_ndr/ndr_nbt.c b/source/librpc/gen_ndr/ndr_nbt.c
index d39d926..aa67d41 100644
--- a/source/librpc/gen_ndr/ndr_nbt.c
+++ b/source/librpc/gen_ndr/ndr_nbt.c
@@ -2821,6 +2821,81 @@ _PUBLIC_ void ndr_print_nbt_cldap_netlogon_13(struct ndr_print *ndr, const char
 	ndr->depth--;
 }
 
+_PUBLIC_ enum ndr_err_code ndr_push_nbt_cldap_netlogon_15(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_15 *r)
+{
+	if (ndr_flags & NDR_SCALARS) {
+		NDR_CHECK(ndr_push_align(ndr, 4));
+		NDR_CHECK(ndr_push_nbt_netlogon_command(ndr, NDR_SCALARS, r->type));


-- 
Samba Shared Repository


More information about the samba-cvs mailing list