s3-nbt: use the new generated nbt.
authorGünther Deschner <gd@samba.org>
Tue, 23 Sep 2008 20:21:52 +0000 (22:21 +0200)
committerGünther Deschner <gd@samba.org>
Wed, 24 Sep 2008 01:34:23 +0000 (03:34 +0200)
Guenther

source3/Makefile.in
source3/include/includes.h
source3/include/proto.h
source3/libads/cldap.c
source3/libads/ldap.c
source3/libsmb/clidgram.c
source3/libsmb/dsgetdcname.c
source3/utils/net_ads.c

index 97095fcadddd2c3da4852fc1a0fb9786af409cfe..333c5f300195d07b35d67304ad55c0a9ea3a641d 100644 (file)
@@ -377,6 +377,8 @@ LIBADS_SERVER_OBJ = libads/kerberos_verify.o libads/authdata.o \
 SECRETS_OBJ = passdb/secrets.o passdb/machine_sid.o
 
 LIBNBT_OBJ = ../libcli/nbt/nbtname.o \
+            ../libcli/netlogon.o \
+            ../libcli/ndr_netlogon.o \
             librpc/gen_ndr/ndr_nbt.o \
             librpc/gen_ndr/ndr_svcctl.o
 
index ccdc6d3fd3c19ecc17947340b8e6b707026b95fd..fbf5ca6cd03e27b8868cc9aba39eda185db4833c 100644 (file)
@@ -703,6 +703,7 @@ typedef char fstring[FSTRING_LEN];
 #include "librpc/gen_ndr/notify.h"
 #include "librpc/gen_ndr/xattr.h"
 #include "librpc/gen_ndr/messaging.h"
+#include "librpc/gen_ndr/ndr_nbt.h"
 #include "librpc/rpc/dcerpc.h"
 #include "nt_printing.h"
 #include "idmap.h"
index 6eac9d112980d545055d34165a8e35289bb1623a..4a51835f3df4e111f7c8fb5ae85fcf5748443597 100644 (file)
@@ -1927,20 +1927,15 @@ NTSTATUS kerberos_return_info3_from_pac(TALLOC_CTX *mem_ctx,
                                        struct netr_SamInfo3 **info3);
 
 /* The following definitions come from libads/cldap.c  */
-
 bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx,
                        const char *server,
                        const char *realm,
-                       uint32_t *nt_version,
-                       union nbt_cldap_netlogon **reply);
+                       uint32_t nt_version,
+                       struct netlogon_samlogon_response **reply);
 bool ads_cldap_netlogon_5(TALLOC_CTX *mem_ctx,
                          const char *server,
                          const char *realm,
-                         struct nbt_cldap_netlogon_5 *reply5);
-bool pull_mailslot_cldap_reply(TALLOC_CTX *mem_ctx,
-                              const DATA_BLOB *blob,
-                              union nbt_cldap_netlogon *r,
-                              uint32_t *nt_version);
+                         struct NETLOGON_SAM_LOGON_RESPONSE_EX *reply5);
 
 /* The following definitions come from libads/disp_sec.c  */
 
@@ -2854,93 +2849,6 @@ _PUBLIC_ enum ndr_err_code ndr_push_samr_RejectReason(struct ndr_push *ndr, int
 _PUBLIC_ enum ndr_err_code ndr_pull_samr_RejectReason(struct ndr_pull *ndr, int ndr_flags, enum samr_RejectReason *r);
 _PUBLIC_ void ndr_print_samr_RejectReason(struct ndr_print *ndr, const char *name, enum samr_RejectReason r);
 
-/* The following definitions come from librpc/gen_ndr/ndr_nbt.c  */
-
-_PUBLIC_ void ndr_print_nbt_operation(struct ndr_print *ndr, const char *name, uint16_t r);
-_PUBLIC_ void ndr_print_nbt_name_type(struct ndr_print *ndr, const char *name, enum nbt_name_type r);
-_PUBLIC_ void ndr_print_nbt_name(struct ndr_print *ndr, const char *name, const struct nbt_name *r);
-_PUBLIC_ void ndr_print_nbt_qclass(struct ndr_print *ndr, const char *name, enum nbt_qclass r);
-_PUBLIC_ void ndr_print_nbt_qtype(struct ndr_print *ndr, const char *name, enum nbt_qtype r);
-_PUBLIC_ void ndr_print_nbt_name_question(struct ndr_print *ndr, const char *name, const struct nbt_name_question *r);
-_PUBLIC_ void ndr_print_nb_flags(struct ndr_print *ndr, const char *name, uint16_t r);
-_PUBLIC_ void ndr_print_nbt_rdata_address(struct ndr_print *ndr, const char *name, const struct nbt_rdata_address *r);
-_PUBLIC_ void ndr_print_nbt_rdata_netbios(struct ndr_print *ndr, const char *name, const struct nbt_rdata_netbios *r);
-_PUBLIC_ void ndr_print_nbt_statistics(struct ndr_print *ndr, const char *name, const struct nbt_statistics *r);
-_PUBLIC_ void ndr_print_nbt_status_name(struct ndr_print *ndr, const char *name, const struct nbt_status_name *r);
-_PUBLIC_ void ndr_print_nbt_rdata_status(struct ndr_print *ndr, const char *name, const struct nbt_rdata_status *r);
-_PUBLIC_ void ndr_print_nbt_rdata_data(struct ndr_print *ndr, const char *name, const struct nbt_rdata_data *r);
-_PUBLIC_ void ndr_print_nbt_rdata(struct ndr_print *ndr, const char *name, const union nbt_rdata *r);
-_PUBLIC_ void ndr_print_nbt_res_rec(struct ndr_print *ndr, const char *name, const struct nbt_res_rec *r);
-_PUBLIC_ enum ndr_err_code ndr_push_nbt_name_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_name_packet *r);
-_PUBLIC_ enum ndr_err_code ndr_pull_nbt_name_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_name_packet *r);
-_PUBLIC_ void ndr_print_nbt_name_packet(struct ndr_print *ndr, const char *name, const struct nbt_name_packet *r);
-_PUBLIC_ void ndr_print_dgram_msg_type(struct ndr_print *ndr, const char *name, enum dgram_msg_type r);
-_PUBLIC_ void ndr_print_dgram_flags(struct ndr_print *ndr, const char *name, uint8_t r);
-_PUBLIC_ void ndr_print_smb_command(struct ndr_print *ndr, const char *name, enum smb_command r);
-_PUBLIC_ void ndr_print_smb_trans_body(struct ndr_print *ndr, const char *name, const struct smb_trans_body *r);
-_PUBLIC_ void ndr_print_smb_body(struct ndr_print *ndr, const char *name, const union smb_body *r);
-_PUBLIC_ enum ndr_err_code ndr_push_dgram_smb_packet(struct ndr_push *ndr, int ndr_flags, const struct dgram_smb_packet *r);
-_PUBLIC_ enum ndr_err_code ndr_pull_dgram_smb_packet(struct ndr_pull *ndr, int ndr_flags, struct dgram_smb_packet *r);
-_PUBLIC_ void ndr_print_dgram_smb_packet(struct ndr_print *ndr, const char *name, const struct dgram_smb_packet *r);
-_PUBLIC_ void ndr_print_dgram_message_body(struct ndr_print *ndr, const char *name, const union dgram_message_body *r);
-_PUBLIC_ void ndr_print_dgram_message(struct ndr_print *ndr, const char *name, const struct dgram_message *r);
-_PUBLIC_ void ndr_print_dgram_err_code(struct ndr_print *ndr, const char *name, enum dgram_err_code r);
-_PUBLIC_ void ndr_print_dgram_data(struct ndr_print *ndr, const char *name, const union dgram_data *r);
-_PUBLIC_ enum ndr_err_code ndr_push_nbt_dgram_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_dgram_packet *r);
-_PUBLIC_ enum ndr_err_code ndr_pull_nbt_dgram_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_dgram_packet *r);
-_PUBLIC_ void ndr_print_nbt_dgram_packet(struct ndr_print *ndr, const char *name, const struct nbt_dgram_packet *r);
-_PUBLIC_ void ndr_print_nbt_netlogon_command(struct ndr_print *ndr, const char *name, enum nbt_netlogon_command r);
-_PUBLIC_ void ndr_print_nbt_netlogon_version(struct ndr_print *ndr, const char *name, uint32_t r);
-_PUBLIC_ void ndr_print_nbt_netlogon_query_for_pdc(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_query_for_pdc *r);
-_PUBLIC_ void ndr_print_nbt_netlogon_query_for_pdc2(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_query_for_pdc2 *r);
-_PUBLIC_ void ndr_print_nbt_netlogon_response_from_pdc(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_response_from_pdc *r);
-_PUBLIC_ void ndr_print_nbt_server_type(struct ndr_print *ndr, const char *name, uint32_t r);
-_PUBLIC_ void ndr_print_nbt_dc_sock_addr(struct ndr_print *ndr, const char *name, const struct nbt_dc_sock_addr *r);
-_PUBLIC_ void ndr_print_nbt_netlogon_response_from_pdc2(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_response_from_pdc2 *r);
-_PUBLIC_ void ndr_print_nbt_db_change(struct ndr_print *ndr, const char *name, const struct nbt_db_change *r);
-_PUBLIC_ void ndr_print_nbt_netlogon_announce_uas(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_announce_uas *r);
-_PUBLIC_ void ndr_print_nbt_netlogon_request(struct ndr_print *ndr, const char *name, const union nbt_netlogon_request *r);
-_PUBLIC_ enum ndr_err_code ndr_push_nbt_netlogon_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_netlogon_packet *r);
-_PUBLIC_ enum ndr_err_code ndr_pull_nbt_netlogon_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_netlogon_packet *r);
-_PUBLIC_ void ndr_print_nbt_netlogon_packet(struct ndr_print *ndr, const char *name, const struct nbt_netlogon_packet *r);
-_PUBLIC_ void ndr_print_nbt_cldap_netlogon_1(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_1 *r);
-_PUBLIC_ void ndr_print_nbt_cldap_netlogon_3(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_3 *r);
-_PUBLIC_ enum ndr_err_code ndr_push_nbt_cldap_netlogon_5(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_5 *r);
-_PUBLIC_ enum ndr_err_code ndr_pull_nbt_cldap_netlogon_5(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_5 *r);
-_PUBLIC_ void ndr_print_nbt_cldap_netlogon_5(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_5 *r);
-_PUBLIC_ void ndr_print_nbt_cldap_netlogon_13(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_13 *r);
-_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);
-_PUBLIC_ enum ndr_err_code ndr_pull_nbt_cldap_netlogon_15(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_15 *r);
-_PUBLIC_ void ndr_print_nbt_cldap_netlogon_15(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_15 *r);
-_PUBLIC_ enum ndr_err_code ndr_push_nbt_cldap_netlogon_29(struct ndr_push *ndr, int ndr_flags, const struct nbt_cldap_netlogon_29 *r);
-_PUBLIC_ enum ndr_err_code ndr_pull_nbt_cldap_netlogon_29(struct ndr_pull *ndr, int ndr_flags, struct nbt_cldap_netlogon_29 *r);
-_PUBLIC_ void ndr_print_nbt_cldap_netlogon_29(struct ndr_print *ndr, const char *name, const struct nbt_cldap_netlogon_29 *r);
-_PUBLIC_ enum ndr_err_code ndr_push_nbt_cldap_netlogon(struct ndr_push *ndr, int ndr_flags, const union nbt_cldap_netlogon *r);
-_PUBLIC_ enum ndr_err_code ndr_pull_nbt_cldap_netlogon(struct ndr_pull *ndr, int ndr_flags, union nbt_cldap_netlogon *r);
-_PUBLIC_ void ndr_print_nbt_cldap_netlogon(struct ndr_print *ndr, const char *name, const union nbt_cldap_netlogon *r);
-_PUBLIC_ void ndr_print_nbt_ntlogon_command(struct ndr_print *ndr, const char *name, enum nbt_ntlogon_command r);
-_PUBLIC_ void ndr_print_nbt_ntlogon_sam_logon(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_sam_logon *r);
-_PUBLIC_ void ndr_print_nbt_ntlogon_sam_logon_reply(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_sam_logon_reply *r);
-_PUBLIC_ void ndr_print_nbt_ntlogon_request(struct ndr_print *ndr, const char *name, const union nbt_ntlogon_request *r);
-_PUBLIC_ enum ndr_err_code ndr_push_nbt_ntlogon_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_ntlogon_packet *r);
-_PUBLIC_ enum ndr_err_code ndr_pull_nbt_ntlogon_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_ntlogon_packet *r);
-_PUBLIC_ void ndr_print_nbt_ntlogon_packet(struct ndr_print *ndr, const char *name, const struct nbt_ntlogon_packet *r);
-_PUBLIC_ void ndr_print_nbt_browse_opcode(struct ndr_print *ndr, const char *name, enum nbt_browse_opcode r);
-_PUBLIC_ void ndr_print_nbt_browse_host_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_host_announcement *r);
-_PUBLIC_ void ndr_print_nbt_browse_announcement_request(struct ndr_print *ndr, const char *name, const struct nbt_browse_announcement_request *r);
-_PUBLIC_ void ndr_print_nbt_browse_election_request(struct ndr_print *ndr, const char *name, const struct nbt_browse_election_request *r);
-_PUBLIC_ void ndr_print_nbt_browse_backup_list_request(struct ndr_print *ndr, const char *name, const struct nbt_browse_backup_list_request *r);
-_PUBLIC_ void ndr_print_nbt_browse_backup_list_response(struct ndr_print *ndr, const char *name, const struct nbt_browse_backup_list_response *r);
-_PUBLIC_ void ndr_print_nbt_browse_become_backup(struct ndr_print *ndr, const char *name, const struct nbt_browse_become_backup *r);
-_PUBLIC_ void ndr_print_nbt_browse_domain_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_domain_announcement *r);
-_PUBLIC_ void ndr_print_nbt_browse_master_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_master_announcement *r);
-_PUBLIC_ void ndr_print_nbt_browse_reset_state(struct ndr_print *ndr, const char *name, const struct nbt_browse_reset_state *r);
-_PUBLIC_ void ndr_print_nbt_browse_local_master_announcement(struct ndr_print *ndr, const char *name, const struct nbt_browse_local_master_announcement *r);
-_PUBLIC_ void ndr_print_nbt_browse_payload(struct ndr_print *ndr, const char *name, const union nbt_browse_payload *r);
-_PUBLIC_ enum ndr_err_code ndr_push_nbt_browse_packet(struct ndr_push *ndr, int ndr_flags, const struct nbt_browse_packet *r);
-_PUBLIC_ enum ndr_err_code ndr_pull_nbt_browse_packet(struct ndr_pull *ndr, int ndr_flags, struct nbt_browse_packet *r);
-_PUBLIC_ void ndr_print_nbt_browse_packet(struct ndr_print *ndr, const char *name, const struct nbt_browse_packet *r);
-
 /* The following definitions come from librpc/gen_ndr/ndr_netlogon.c  */
 
 _PUBLIC_ void ndr_print_netr_UasInfo(struct ndr_print *ndr, const char *name, const struct netr_UasInfo *r);
@@ -4295,7 +4203,7 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx,
                            const char *domain_name,
                            uint32_t *nt_version,
                            const char **dc_name,
-                           union nbt_cldap_netlogon **reply);
+                           struct netlogon_samlogon_response **reply);
 
 /* The following definitions come from libsmb/clientgen.c  */
 
index b89d285e8cca20fba08c3a20091027188b9ad849..edabbed0e93bdda6ab91620dcc9379fa8a87fa95 100644 (file)
@@ -119,8 +119,8 @@ static void gotalarm_sig(void)
 */
 static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx,
                               int sock,
-                              uint32_t *nt_version,
-                              union nbt_cldap_netlogon **reply)
+                              uint32_t nt_version,
+                              struct netlogon_samlogon_response **reply)
 {
        int ret;
        ASN1_DATA data;
@@ -131,7 +131,8 @@ 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 *r = NULL;
+       struct netlogon_samlogon_response *r = NULL;
+       NTSTATUS status;
 
        blob = data_blob(NULL, 8192);
        if (blob.data == NULL) {
@@ -185,7 +186,7 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx,
                return -1;
        }
 
-       r = TALLOC_ZERO_P(mem_ctx, union nbt_cldap_netlogon);
+       r = TALLOC_ZERO_P(mem_ctx, struct netlogon_samlogon_response);
        if (!r) {
                errno = ENOMEM;
                data_blob_free(&os1);
@@ -195,7 +196,8 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx,
                return -1;
        }
 
-       if (!pull_mailslot_cldap_reply(mem_ctx, &os3, r, nt_version)) {
+       status = pull_netlogon_samlogon_response(&os3, mem_ctx, NULL, r);
+       if (!NT_STATUS_IS_OK(status)) {
                data_blob_free(&os1);
                data_blob_free(&os2);
                data_blob_free(&os3);
@@ -204,6 +206,8 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx,
                return -1;
        }
 
+       map_netlogon_samlogon_response(r);
+
        data_blob_free(&os1);
        data_blob_free(&os2);
        data_blob_free(&os3);
@@ -227,8 +231,8 @@ static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx,
 bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx,
                        const char *server,
                        const char *realm,
-                       uint32_t *nt_version,
-                       union nbt_cldap_netlogon **reply)
+                       uint32_t nt_version,
+                       struct netlogon_samlogon_response **reply)
 {
        int sock;
        int ret;
@@ -240,7 +244,7 @@ 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;
@@ -262,107 +266,24 @@ bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx,
 bool ads_cldap_netlogon_5(TALLOC_CTX *mem_ctx,
                          const char *server,
                          const char *realm,
-                         struct nbt_cldap_netlogon_5 *reply5)
+                         struct NETLOGON_SAM_LOGON_RESPONSE_EX *reply5)
 {
        uint32_t nt_version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX;
-       union nbt_cldap_netlogon *reply = NULL;
+       struct netlogon_samlogon_response *reply = NULL;
        bool ret;
 
-       ret = ads_cldap_netlogon(mem_ctx, server, realm, &nt_version, &reply);
+       ret = ads_cldap_netlogon(mem_ctx, server, realm, nt_version, &reply);
        if (!ret) {
                return false;
        }
 
-       if (nt_version != (NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX)) {
+       if (reply->ntver != NETLOGON_NT_VERSION_5EX) {
+               DEBUG(0,("ads_cldap_netlogon_5: nt_version mismatch: 0x%08x\n",
+                       reply->ntver));
                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, NULL, &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 */
-               case 0x19: /* 25 */
-                        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_NT_VERSION_WITH_CLOSEST_SITE) {
-               nt_version_query &= ~NETLOGON_NT_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_NT_VERSION_5EX_WITH_IP) {
-               nt_version_query &= ~NETLOGON_NT_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_NT_VERSION_5EX) {
-               nt_version_query &= ~NETLOGON_NT_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_NT_VERSION_5) {
-               nt_version_query &= ~NETLOGON_NT_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;
+       *reply5 = reply->nt5_ex;
 
        return true;
 }
index eb45e3a0dd7050fbdc7609330838218031bcf024..bfcfcf30b98ff8754f67325c09a1269e68fb6c7c 100644 (file)
@@ -176,7 +176,7 @@ bool ads_closest_dc(ADS_STRUCT *ads)
 static bool ads_try_connect(ADS_STRUCT *ads, const char *server, bool gc)
 {
        char *srv;
-       struct nbt_cldap_netlogon_5 cldap_reply;
+       struct NETLOGON_SAM_LOGON_RESPONSE_EX cldap_reply;
        TALLOC_CTX *mem_ctx = NULL;
        bool ret = false;
 
index 8ee3507a04f51b2e52431b99622ea869529ebd94..e8799bce4794602c41520a3cc8a4801fcb6ebb66 100644 (file)
@@ -136,8 +136,8 @@ bool send_getdc_request(TALLOC_CTX *mem_ctx,
        struct in_addr dc_ip;
        const char *my_acct_name = NULL;
        const char *my_mailslot = NULL;
-       struct nbt_ntlogon_packet packet;
-       struct nbt_ntlogon_sam_logon *s;
+       struct nbt_netlogon_packet packet;
+       struct NETLOGON_SAM_LOGON_REQUEST *s;
        enum ndr_err_code ndr_err;
        DATA_BLOB blob;
        struct dom_sid my_sid;
@@ -164,7 +164,7 @@ bool send_getdc_request(TALLOC_CTX *mem_ctx,
                return false;
        }
 
-       packet.command  = NTLOGON_SAM_LOGON;
+       packet.command  = LOGON_SAM_LOGON_REQUEST;
        s               = &packet.req.logon;
 
        s->request_count        = 0;
@@ -178,11 +178,11 @@ bool send_getdc_request(TALLOC_CTX *mem_ctx,
        s->lm20_token           = 0xffff;
 
        if (DEBUGLEVEL >= 10) {
-               NDR_PRINT_DEBUG(nbt_ntlogon_packet, &packet);
+               NDR_PRINT_DEBUG(nbt_netlogon_packet, &packet);
        }
 
        ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, &packet,
-                      (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet);
+                      (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                return false;
        }
@@ -199,15 +199,16 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx,
                            const char *domain_name,
                            uint32_t *nt_version,
                            const char **dc_name,
-                           union nbt_cldap_netlogon **reply)
+                           struct netlogon_samlogon_response **_r)
 {
        struct packet_struct *packet;
        const char *my_mailslot = NULL;
        struct in_addr dc_ip;
        DATA_BLOB blob;
-       union nbt_cldap_netlogon r;
+       struct netlogon_samlogon_response r;
        union dgram_message_body p;
        enum ndr_err_code ndr_err;
+       NTSTATUS status;
 
        const char *returned_dc = NULL;
        const char *returned_domain = NULL;
@@ -266,66 +267,20 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx,
 
        blob = p.smb.body.trans.data;
 
-       if (!pull_mailslot_cldap_reply(mem_ctx, &blob,
-                                      &r, nt_version))
-       {
+       ZERO_STRUCT(r);
+
+       status = pull_netlogon_samlogon_response(&blob, mem_ctx, NULL, &r);
+       if (!NT_STATUS_IS_OK(status)) {
                return false;
        }
 
-       switch (*nt_version) {
-               case 1:
-               case 16:
-               case 17:
-
-                       returned_domain = r.logon1.domain_name;
-                       returned_dc = r.logon1.pdc_name;
-                       break;
-               case 2:
-               case 3:
-               case 18:
-               case 19:
-                       returned_domain = r.logon3.domain_name;
-                       returned_dc = r.logon3.pdc_name;
-                       break;
-               case 4:
-               case 5:
-               case 6:
-               case 7:
-                       returned_domain = r.logon5.domain;
-                       returned_dc = r.logon5.pdc_name;
-                       break;
-               case 8:
-               case 9:
-               case 10:
-               case 11:
-               case 12:
-               case 13:
-               case 14:
-               case 15:
-                       returned_domain = r.logon13.domain;
-                       returned_dc = r.logon13.pdc_name;
-                       break;
-               case 20:
-               case 21:
-               case 22:
-               case 23:
-               case 24:
-               case 25:
-               case 26:
-               case 27:
-               case 28:
-                       returned_domain = r.logon15.domain;
-                       returned_dc = r.logon15.pdc_name;
-                       break;
-               case 29:
-               case 30:
-               case 31:
-                       returned_domain = r.logon29.domain;
-                       returned_dc = r.logon29.pdc_name;
-                       break;
-               default:
-                       return false;
-       }
+       map_netlogon_samlogon_response(&r);
+
+       /* do we still need this ? */
+       *nt_version = r.ntver;
+
+       returned_domain = r.nt5_ex.domain;
+       returned_dc = r.nt5_ex.pdc_name;
 
        if (!strequal(returned_domain, domain_name)) {
                DEBUG(3, ("GetDC: Expected domain %s, got %s\n",
@@ -341,10 +296,10 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx,
        if (**dc_name == '\\')  *dc_name += 1;
        if (**dc_name == '\\')  *dc_name += 1;
 
-       if (reply) {
-               *reply = (union nbt_cldap_netlogon *)talloc_memdup(
-                       mem_ctx, &r, sizeof(union nbt_cldap_netlogon));
-               if (!*reply) {
+       if (_r) {
+               *_r = (struct netlogon_samlogon_response *)talloc_memdup(
+                       mem_ctx, &r, sizeof(struct netlogon_samlogon_response));
+               if (!*_r) {
                        return false;
                }
        }
index 4cc587c58d347038a64c0222011b3c17b8613950..a543e073bc351f18722ca221178cb8dce3441845 100644 (file)
@@ -35,8 +35,7 @@ struct ip_service_name {
 static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
                                              uint32_t flags,
                                              struct sockaddr_storage *ss,
-                                             uint32_t nt_version,
-                                             union nbt_cldap_netlogon *r,
+                                             struct netlogon_samlogon_response *r,
                                              struct netr_DsRGetDCNameInfo **info);
 
 /****************************************************************
@@ -186,173 +185,46 @@ static NTSTATUS dsgetdcname_cache_store(TALLOC_CTX *mem_ctx,
 /****************************************************************
 ****************************************************************/
 
-#define SET_STRING(x) \
-       talloc_strdup(mem_ctx, x); \
-       NT_STATUS_HAVE_NO_MEMORY(x);
-
-static NTSTATUS map_logon29_from_cldap_reply(TALLOC_CTX *mem_ctx,
-                                            uint32_t flags,
-                                            struct sockaddr_storage *ss,
-                                            uint32_t nt_version,
-                                            union nbt_cldap_netlogon *r,
-                                            struct nbt_cldap_netlogon_29 *p)
-{
-       char addr[INET6_ADDRSTRLEN];
-
-       ZERO_STRUCTP(p);
-
-       print_sockaddr(addr, sizeof(addr), ss);
-
-       /* FIXME */
-       p->dc_sock_addr_size = 0x10; /* the w32 winsock addr size */
-       p->dc_sock_addr.family = 2; /* AF_INET */
-       p->dc_sock_addr.pdc_ip = talloc_strdup(mem_ctx, addr);
-
-       switch (nt_version & 0x0000001f) {
-               case 0:
-                       return NT_STATUS_INVALID_PARAMETER;
-               case 1:
-               case 16:
-               case 17:
-                       p->pdc_name     = SET_STRING(r->logon1.pdc_name);
-                       p->domain       = SET_STRING(r->logon1.domain_name);
-
-                       if (flags & DS_PDC_REQUIRED) {
-                               p->server_type = NBT_SERVER_WRITABLE |
-                                                NBT_SERVER_PDC;
-                       }
-                       break;
-               case 2:
-               case 3:
-               case 18:
-               case 19:
-                       p->pdc_name     = SET_STRING(r->logon3.pdc_name);
-                       p->domain       = SET_STRING(r->logon3.domain_name);
-                       p->pdc_dns_name = SET_STRING(r->logon3.pdc_dns_name);
-                       p->dns_domain   = SET_STRING(r->logon3.dns_domain);
-                       p->server_type  = r->logon3.server_type;
-                       p->forest       = SET_STRING(r->logon3.forest);
-                       p->domain_uuid  = r->logon3.domain_uuid;
-
-                       break;
-               case 4:
-               case 5:
-               case 6:
-               case 7:
-                       p->pdc_name     = SET_STRING(r->logon5.pdc_name);
-                       p->domain       = SET_STRING(r->logon5.domain);
-                       p->pdc_dns_name = SET_STRING(r->logon5.pdc_dns_name);
-                       p->dns_domain   = SET_STRING(r->logon5.dns_domain);
-                       p->server_type  = r->logon5.server_type;
-                       p->forest       = SET_STRING(r->logon5.forest);
-                       p->domain_uuid  = r->logon5.domain_uuid;
-                       p->server_site  = SET_STRING(r->logon5.server_site);
-                       p->client_site  = SET_STRING(r->logon5.client_site);
-
-                       break;
-               case 8:
-               case 9:
-               case 10:
-               case 11:
-               case 12:
-               case 13:
-               case 14:
-               case 15:
-                       p->pdc_name     = SET_STRING(r->logon13.pdc_name);
-                       p->domain       = SET_STRING(r->logon13.domain);
-                       p->pdc_dns_name = SET_STRING(r->logon13.pdc_dns_name);
-                       p->dns_domain   = SET_STRING(r->logon13.dns_domain);
-                       p->server_type  = r->logon13.server_type;
-                       p->forest       = SET_STRING(r->logon13.forest);
-                       p->domain_uuid  = r->logon13.domain_uuid;
-                       p->server_site  = SET_STRING(r->logon13.server_site);
-                       p->client_site  = SET_STRING(r->logon13.client_site);
-
-                       break;
-               case 20:
-               case 21:
-               case 22:
-               case 23:
-               case 24:
-               case 25:
-               case 26:
-               case 27:
-               case 28:
-                       p->pdc_name     = SET_STRING(r->logon15.pdc_name);
-                       p->domain       = SET_STRING(r->logon15.domain);
-                       p->pdc_dns_name = SET_STRING(r->logon15.pdc_dns_name);
-                       p->dns_domain   = SET_STRING(r->logon15.dns_domain);
-                       p->server_type  = r->logon15.server_type;
-                       p->forest       = SET_STRING(r->logon15.forest);
-                       p->domain_uuid  = r->logon15.domain_uuid;
-                       p->server_site  = SET_STRING(r->logon15.server_site);
-                       p->client_site  = SET_STRING(r->logon15.client_site);
-
-                       break;
-               case 29:
-               case 30:
-               case 31:
-                       p->pdc_name     = SET_STRING(r->logon29.pdc_name);
-                       p->domain       = SET_STRING(r->logon29.domain);
-                       p->pdc_dns_name = SET_STRING(r->logon29.pdc_dns_name);
-                       p->dns_domain   = SET_STRING(r->logon29.dns_domain);
-                       p->server_type  = r->logon29.server_type;
-                       p->forest       = SET_STRING(r->logon29.forest);
-                       p->domain_uuid  = r->logon29.domain_uuid;
-                       p->server_site  = SET_STRING(r->logon29.server_site);
-                       p->client_site  = SET_STRING(r->logon29.client_site);
-                       p->next_closest_site = SET_STRING(r->logon29.next_closest_site);
-
-                       break;
-               default:
-                       return NT_STATUS_INVALID_PARAMETER;
-       }
-
-       return NT_STATUS_OK;
-}
-
-/****************************************************************
-****************************************************************/
-
 static NTSTATUS store_cldap_reply(TALLOC_CTX *mem_ctx,
                                  uint32_t flags,
                                  struct sockaddr_storage *ss,
                                  uint32_t nt_version,
-                                 union nbt_cldap_netlogon *r)
+                                 struct NETLOGON_SAM_LOGON_RESPONSE_EX *r)
 {
        DATA_BLOB blob;
        enum ndr_err_code ndr_err;
        NTSTATUS status;
-       struct nbt_cldap_netlogon_29 logon29;
+       char addr[INET6_ADDRSTRLEN];
 
-       status = map_logon29_from_cldap_reply(mem_ctx, flags, ss,
-                                             nt_version, r, &logon29);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
-       }
+       print_sockaddr(addr, sizeof(addr), ss);
+
+       /* FIXME */
+       r->sockaddr_size = 0x10; /* the w32 winsock addr size */
+       r->sockaddr.sa_family = 2; /* AF_INET */
+       r->sockaddr.pdc_ip = talloc_strdup(mem_ctx, addr);
 
-       ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, &logon29,
-                      (ndr_push_flags_fn_t)ndr_push_nbt_cldap_netlogon_29);
+       ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, r,
+                      (ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                return ndr_map_error2ntstatus(ndr_err);
        }
 
-       if (logon29.domain) {
-               status = dsgetdcname_cache_store(mem_ctx, logon29.domain, &blob);
+       if (r->domain) {
+               status = dsgetdcname_cache_store(mem_ctx, r->domain, &blob);
                if (!NT_STATUS_IS_OK(status)) {
                        goto done;
                }
-               if (logon29.client_site) {
-                       sitename_store(logon29.domain, logon29.client_site);
+               if (r->client_site) {
+                       sitename_store(r->domain, r->client_site);
                }
        }
-       if (logon29.dns_domain) {
-               status = dsgetdcname_cache_store(mem_ctx, logon29.dns_domain, &blob);
+       if (r->dns_domain) {
+               status = dsgetdcname_cache_store(mem_ctx, r->dns_domain, &blob);
                if (!NT_STATUS_IS_OK(status)) {
                        goto done;
                }
-               if (logon29.client_site) {
-                       sitename_store(logon29.dns_domain, logon29.client_site);
+               if (r->client_site) {
+                       sitename_store(r->dns_domain, r->client_site);
                }
        }
 
@@ -387,7 +259,7 @@ static NTSTATUS dsgetdcname_cache_refresh(TALLOC_CTX *mem_ctx,
 /****************************************************************
 ****************************************************************/
 
-static uint32_t get_cldap_reply_server_flags(union nbt_cldap_netlogon *r,
+static uint32_t get_cldap_reply_server_flags(struct netlogon_samlogon_response *r,
                                             uint32_t nt_version)
 {
        switch (nt_version & 0x0000001f) {
@@ -400,12 +272,12 @@ static uint32_t get_cldap_reply_server_flags(union nbt_cldap_netlogon *r,
                case 3:
                case 18:
                case 19:
-                       return r->logon3.server_type;
+                       return r->nt5.server_type;
                case 4:
                case 5:
                case 6:
                case 7:
-                       return r->logon5.server_type;
+                       return r->nt5_ex.server_type;
                case 8:
                case 9:
                case 10:
@@ -414,7 +286,7 @@ static uint32_t get_cldap_reply_server_flags(union nbt_cldap_netlogon *r,
                case 13:
                case 14:
                case 15:
-                       return r->logon13.server_type;
+                       return r->nt5_ex.server_type;
                case 20:
                case 21:
                case 22:
@@ -424,11 +296,11 @@ static uint32_t get_cldap_reply_server_flags(union nbt_cldap_netlogon *r,
                case 26:
                case 27:
                case 28:
-                       return r->logon15.server_type;
+                       return r->nt5_ex.server_type;
                case 29:
                case 30:
                case 31:
-                       return r->logon29.server_type;
+                       return r->nt5_ex.server_type;
                default:
                        return 0;
        }
@@ -486,8 +358,8 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx,
        DATA_BLOB blob;
        enum ndr_err_code ndr_err;
        struct netr_DsRGetDCNameInfo *info;
-       union nbt_cldap_netlogon p;
-       struct nbt_cldap_netlogon_29 r;
+       struct netlogon_samlogon_response p;
+       struct NETLOGON_SAM_LOGON_RESPONSE_EX r;
        NTSTATUS status;
 
        if (!gencache_init()) {
@@ -509,7 +381,7 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx,
        }
 
        ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL, &r,
-                     (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon_29);
+                     (ndr_pull_flags_fn_t)ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX);
 
        data_blob_free(&blob);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
@@ -517,10 +389,9 @@ static NTSTATUS dsgetdcname_cache_fetch(TALLOC_CTX *mem_ctx,
                return ndr_map_error2ntstatus(ndr_err);
        }
 
-       p.logon29 = r;
+       p.nt5_ex = r;
 
        status = make_dc_info_from_cldap_reply(mem_ctx, flags, NULL,
-                                              29,
                                               &p, &info);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
@@ -916,8 +787,7 @@ static void map_dc_and_domain_names(uint32_t flags,
 static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
                                              uint32_t flags,
                                              struct sockaddr_storage *ss,
-                                             uint32_t nt_version,
-                                             union nbt_cldap_netlogon *r,
+                                             struct netlogon_samlogon_response *r,
                                              struct netr_DsRGetDCNameInfo **info)
 {
        const char *dc_hostname = NULL;
@@ -938,19 +808,19 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
                dc_address_type = DS_ADDRESS_TYPE_INET;
        }
 
-       switch (nt_version & 0x0000001f) {
+       switch (r->ntver & 0x0000001f) {
                case 0:
                case 1:
                case 16:
                case 17:
                        if (!ss) {
-                               dc_address      = r->logon1.pdc_name;
+                               dc_address      = r->nt4.server;
                                dc_address_type = DS_ADDRESS_TYPE_NETBIOS;
                        }
 
                        map_dc_and_domain_names(flags,
-                                               r->logon1.pdc_name,
-                                               r->logon1.domain_name,
+                                               r->nt4.server,
+                                               r->nt4.domain,
                                                NULL,
                                                NULL,
                                                &dc_flags,
@@ -966,22 +836,22 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
                case 18:
                case 19:
                        if (!ss) {
-                               dc_address      = r->logon3.pdc_ip;
+                               dc_address      = r->nt5.pdc_ip;
                                dc_address_type = DS_ADDRESS_TYPE_INET;
                        }
 
                        map_dc_and_domain_names(flags,
-                                               r->logon3.pdc_name,
-                                               r->logon3.domain_name,
-                                               r->logon3.pdc_dns_name,
-                                               r->logon3.dns_domain,
+                                               r->nt5.pdc_name,
+                                               r->nt5.domain_name,
+                                               r->nt5.pdc_dns_name,
+                                               r->nt5.dns_domain,
                                                &dc_flags,
                                                &dc_hostname,
                                                &dc_domain_name);
 
-                       dc_flags        |= r->logon3.server_type;
-                       dc_forest       = r->logon3.forest;
-                       dc_domain_guid  = &r->logon3.domain_uuid;
+                       dc_flags        |= r->nt5.server_type;
+                       dc_forest       = r->nt5.forest;
+                       dc_domain_guid  = &r->nt5.domain_uuid;
 
                        break;
                case 4:
@@ -989,24 +859,24 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
                case 6:
                case 7:
                        if (!ss) {
-                               dc_address      = r->logon5.pdc_name;
+                               dc_address      = r->nt5_ex.pdc_name;
                                dc_address_type = DS_ADDRESS_TYPE_NETBIOS;
                        }
 
                        map_dc_and_domain_names(flags,
-                                               r->logon5.pdc_name,
-                                               r->logon5.domain,
-                                               r->logon5.pdc_dns_name,
-                                               r->logon5.dns_domain,
+                                               r->nt5_ex.pdc_name,
+                                               r->nt5_ex.domain,
+                                               r->nt5_ex.pdc_dns_name,
+                                               r->nt5_ex.dns_domain,
                                                &dc_flags,
                                                &dc_hostname,
                                                &dc_domain_name);
 
-                       dc_flags        |= r->logon5.server_type;
-                       dc_forest       = r->logon5.forest;
-                       dc_domain_guid  = &r->logon5.domain_uuid;
-                       dc_server_site  = r->logon5.server_site;
-                       dc_client_site  = r->logon5.client_site;
+                       dc_flags        |= r->nt5_ex.server_type;
+                       dc_forest       = r->nt5_ex.forest;
+                       dc_domain_guid  = &r->nt5_ex.domain_uuid;
+                       dc_server_site  = r->nt5_ex.server_site;
+                       dc_client_site  = r->nt5_ex.client_site;
 
                        break;
                case 8:
@@ -1018,24 +888,24 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
                case 14:
                case 15:
                        if (!ss) {
-                               dc_address      = r->logon13.dc_sock_addr.pdc_ip;
+                               dc_address      = r->nt5_ex.sockaddr.pdc_ip;
                                dc_address_type = DS_ADDRESS_TYPE_INET;
                        }
 
                        map_dc_and_domain_names(flags,
-                                               r->logon13.pdc_name,
-                                               r->logon13.domain,
-                                               r->logon13.pdc_dns_name,
-                                               r->logon13.dns_domain,
+                                               r->nt5_ex.pdc_name,
+                                               r->nt5_ex.domain,
+                                               r->nt5_ex.pdc_dns_name,
+                                               r->nt5_ex.dns_domain,
                                                &dc_flags,
                                                &dc_hostname,
                                                &dc_domain_name);
 
-                       dc_flags        |= r->logon13.server_type;
-                       dc_forest       = r->logon13.forest;
-                       dc_domain_guid  = &r->logon13.domain_uuid;
-                       dc_server_site  = r->logon13.server_site;
-                       dc_client_site  = r->logon13.client_site;
+                       dc_flags        |= r->nt5_ex.server_type;
+                       dc_forest       = r->nt5_ex.forest;
+                       dc_domain_guid  = &r->nt5_ex.domain_uuid;
+                       dc_server_site  = r->nt5_ex.server_site;
+                       dc_client_site  = r->nt5_ex.client_site;
 
                        break;
                case 20:
@@ -1048,48 +918,48 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
                case 27:
                case 28:
                        if (!ss) {
-                               dc_address      = r->logon15.pdc_name;
+                               dc_address      = r->nt5_ex.pdc_name;
                                dc_address_type = DS_ADDRESS_TYPE_NETBIOS;
                        }
 
                        map_dc_and_domain_names(flags,
-                                               r->logon15.pdc_name,
-                                               r->logon15.domain,
-                                               r->logon15.pdc_dns_name,
-                                               r->logon15.dns_domain,
+                                               r->nt5_ex.pdc_name,
+                                               r->nt5_ex.domain,
+                                               r->nt5_ex.pdc_dns_name,
+                                               r->nt5_ex.dns_domain,
                                                &dc_flags,
                                                &dc_hostname,
                                                &dc_domain_name);
 
-                       dc_flags        |= r->logon15.server_type;
-                       dc_forest       = r->logon15.forest;
-                       dc_domain_guid  = &r->logon15.domain_uuid;
-                       dc_server_site  = r->logon15.server_site;
-                       dc_client_site  = r->logon15.client_site;
+                       dc_flags        |= r->nt5_ex.server_type;
+                       dc_forest       = r->nt5_ex.forest;
+                       dc_domain_guid  = &r->nt5_ex.domain_uuid;
+                       dc_server_site  = r->nt5_ex.server_site;
+                       dc_client_site  = r->nt5_ex.client_site;
 
                        break;
                case 29:
                case 30:
                case 31:
                        if (!ss) {
-                               dc_address      = r->logon29.dc_sock_addr.pdc_ip;
+                               dc_address      = r->nt5_ex.sockaddr.pdc_ip;
                                dc_address_type = DS_ADDRESS_TYPE_INET;
                        }
 
                        map_dc_and_domain_names(flags,
-                                               r->logon29.pdc_name,
-                                               r->logon29.domain,
-                                               r->logon29.pdc_dns_name,
-                                               r->logon29.dns_domain,
+                                               r->nt5_ex.pdc_name,
+                                               r->nt5_ex.domain,
+                                               r->nt5_ex.pdc_dns_name,
+                                               r->nt5_ex.dns_domain,
                                                &dc_flags,
                                                &dc_hostname,
                                                &dc_domain_name);
 
-                       dc_flags        |= r->logon29.server_type;
-                       dc_forest       = r->logon29.forest;
-                       dc_domain_guid  = &r->logon29.domain_uuid;
-                       dc_server_site  = r->logon29.server_site;
-                       dc_client_site  = r->logon29.client_site;
+                       dc_flags        |= r->nt5_ex.server_type;
+                       dc_forest       = r->nt5_ex.forest;
+                       dc_domain_guid  = &r->nt5_ex.domain_uuid;
+                       dc_server_site  = r->nt5_ex.server_site;
+                       dc_client_site  = r->nt5_ex.client_site;
 
                        break;
                default:
@@ -1147,7 +1017,7 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx,
 {
        int i = 0;
        bool valid_dc = false;
-       union nbt_cldap_netlogon *r = NULL;
+       struct netlogon_samlogon_response *r = NULL;
        uint32_t nt_version = NETLOGON_NT_VERSION_5 |
                              NETLOGON_NT_VERSION_5EX;
        uint32_t ret_flags = 0;
@@ -1161,9 +1031,10 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx,
 
                if (ads_cldap_netlogon(mem_ctx, dclist[i].hostname,
                                        domain_name,
-                                       &nt_version,
+                                       nt_version,
                                        &r))
                {
+                       nt_version = r->ntver;
                        ret_flags = get_cldap_reply_server_flags(r, nt_version);
 
                        if (check_cldap_reply_required_flags(ret_flags, flags)) {
@@ -1180,10 +1051,10 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx,
        }
 
        status = make_dc_info_from_cldap_reply(mem_ctx, flags, &dclist[i].ss,
-                                              nt_version, r, info);
+                                              r, info);
        if (NT_STATUS_IS_OK(status)) {
                return store_cldap_reply(mem_ctx, flags, &dclist[i].ss,
-                                        nt_version, r);
+                                        nt_version, &r->nt5_ex);
        }
 
        return status;
@@ -1234,7 +1105,7 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx,
        int i;
        const char *dc_name = NULL;
        fstring tmp_dc_name;
-       union nbt_cldap_netlogon *r = NULL;
+       struct netlogon_samlogon_response *r = NULL;
        bool store_cache = false;
        uint32_t nt_version = NETLOGON_NT_VERSION_1 |
                              NETLOGON_NT_VERSION_5 |
@@ -1288,9 +1159,9 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx,
                                     &dclist[i].ss,
                                     tmp_dc_name))
                {
-                       struct nbt_cldap_netlogon_1 logon1;
+                       struct NETLOGON_SAM_LOGON_RESPONSE_NT40 logon1;
 
-                       r = TALLOC_ZERO_P(mem_ctx, union nbt_cldap_netlogon);
+                       r = TALLOC_ZERO_P(mem_ctx, struct netlogon_samlogon_response);
                        NT_STATUS_HAVE_NO_MEMORY(r);
 
                        ZERO_STRUCT(logon1);
@@ -1298,11 +1169,12 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx,
                        nt_version = NETLOGON_NT_VERSION_1;
 
                        logon1.nt_version = nt_version;
-                       logon1.pdc_name = tmp_dc_name;
-                       logon1.domain_name = talloc_strdup_upper(mem_ctx, domain_name);
-                       NT_STATUS_HAVE_NO_MEMORY(logon1.domain_name);
+                       logon1.server = tmp_dc_name;
+                       logon1.domain = talloc_strdup_upper(mem_ctx, domain_name);
+                       NT_STATUS_HAVE_NO_MEMORY(logon1.domain);
 
-                       r->logon1 = logon1;
+                       r->nt4 = logon1;
+                       r->ntver = nt_version;
 
                        namecache_store(tmp_dc_name, NBT_NAME_SERVER, 1, &ip_list);
 
@@ -1315,10 +1187,10 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx,
  make_reply:
 
        status = make_dc_info_from_cldap_reply(mem_ctx, flags, &dclist[i].ss,
-                                              nt_version, r, info);
+                                              r, info);
        if (NT_STATUS_IS_OK(status) && store_cache) {
                return store_cldap_reply(mem_ctx, flags, &dclist[i].ss,
-                                        nt_version, r);
+                                        nt_version, &r->nt5_ex);
        }
 
        return status;
index 7dbe518c3dd0ee521ff7586dd6d75c8de98ada8e..1ef4c152a3db90a2865fbe0cdb9fec1f5c13e865 100644 (file)
@@ -43,7 +43,7 @@ static const char *assume_own_realm(struct net_context *c)
 static int net_ads_cldap_netlogon(struct net_context *c, ADS_STRUCT *ads)
 {
        char addr[INET6_ADDRSTRLEN];
-       struct nbt_cldap_netlogon_5 reply;
+       struct NETLOGON_SAM_LOGON_RESPONSE_EX reply;
 
        print_sockaddr(addr, sizeof(addr), &ads->ldap.ss);
        if ( !ads_cldap_netlogon_5(talloc_tos(), addr, ads->server.realm, &reply ) ) {
@@ -55,7 +55,7 @@ static int net_ads_cldap_netlogon(struct net_context *c, ADS_STRUCT *ads)
                addr);
 
        d_printf("Response Type: ");
-       switch (reply.type) {
+       switch (reply.command) {
        case SAMLOGON_AD_UNK_R:
                d_printf("SAMLOGON\n");
                break;
@@ -63,7 +63,7 @@ static int net_ads_cldap_netlogon(struct net_context *c, ADS_STRUCT *ads)
                d_printf("SAMLOGON_USER\n");
                break;
        default:
-               d_printf("0x%x\n", reply.type);
+               d_printf("0x%x\n", reply.command);
                break;
        }
 
@@ -359,7 +359,7 @@ static int net_ads_workgroup(struct net_context *c, int argc, const char **argv)
 {
        ADS_STRUCT *ads;
        char addr[INET6_ADDRSTRLEN];
-       struct nbt_cldap_netlogon_5 reply;
+       struct NETLOGON_SAM_LOGON_RESPONSE_EX reply;
 
        if (c->display_usage) {
                d_printf("Usage:\n"