lib/util: charset modules do not exist any more
[amitay/samba.git] / librpc / ndr / ndr_nbt.c
1 /*
2    Unix SMB/CIFS implementation.
3
4    CLDAP server structures
5
6    Copyright (C) Andrew Tridgell 2005
7    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 /* parser auto-generated by pidl, then hand-modified by abartlet */
24
25 #include "includes.h"
26 #include "../libcli/nbt/libnbt.h"
27 #include "../libcli/netlogon/netlogon.h"
28
29 /* don't allow an unlimited number of name components */
30 #define MAX_COMPONENTS 10
31
32 /**
33   print a nbt string
34 */
35 _PUBLIC_ void ndr_print_nbt_string(struct ndr_print *ndr, const char *name, const char *s)
36 {
37         ndr_print_string(ndr, name, s);
38 }
39
40 /*
41   pull one component of a nbt_string
42 */
43 static enum ndr_err_code ndr_pull_component(struct ndr_pull *ndr,
44                                             uint8_t **component,
45                                             uint32_t *offset,
46                                             uint32_t *max_offset)
47 {
48         uint8_t len;
49         unsigned int loops = 0;
50         while (loops < 5) {
51                 if (*offset >= ndr->data_size) {
52                         return ndr_pull_error(ndr, NDR_ERR_STRING,
53                                               "BAD NBT NAME component");
54                 }
55                 len = ndr->data[*offset];
56                 if (len == 0) {
57                         *offset += 1;
58                         *max_offset = MAX(*max_offset, *offset);
59                         *component = NULL;
60                         return NDR_ERR_SUCCESS;
61                 }
62                 if ((len & 0xC0) == 0xC0) {
63                         /* its a label pointer */
64                         if (1 + *offset >= ndr->data_size) {
65                                 return ndr_pull_error(ndr, NDR_ERR_STRING,
66                                                       "BAD NBT NAME component");
67                         }
68                         *max_offset = MAX(*max_offset, *offset + 2);
69                         *offset = ((len&0x3F)<<8) | ndr->data[1 + *offset];
70                         *max_offset = MAX(*max_offset, *offset);
71                         loops++;
72                         continue;
73                 }
74                 if ((len & 0xC0) != 0) {
75                         /* its a reserved length field */
76                         return ndr_pull_error(ndr, NDR_ERR_STRING,
77                                               "BAD NBT NAME component");
78                 }
79                 if (*offset + len + 1 > ndr->data_size) {
80                         return ndr_pull_error(ndr, NDR_ERR_STRING,
81                                               "BAD NBT NAME component");
82                 }
83                 *component = (uint8_t*)talloc_strndup(
84                         ndr->current_mem_ctx,
85                         (const char *)&ndr->data[1 + *offset], len);
86                 NDR_ERR_HAVE_NO_MEMORY(*component);
87                 *offset += len + 1;
88                 *max_offset = MAX(*max_offset, *offset);
89                 return NDR_ERR_SUCCESS;
90         }
91
92         /* too many pointers */
93         return ndr_pull_error(ndr, NDR_ERR_STRING, "BAD NBT NAME component");
94 }
95
96 /**
97   pull a nbt_string from the wire
98 */
99 _PUBLIC_ enum ndr_err_code ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
100 {
101         uint32_t offset = ndr->offset;
102         uint32_t max_offset = offset;
103         unsigned num_components;
104         char *name;
105
106         if (!(ndr_flags & NDR_SCALARS)) {
107                 return NDR_ERR_SUCCESS;
108         }
109
110         name = NULL;
111
112         /* break up name into a list of components */
113         for (num_components=0;num_components<MAX_COMPONENTS;num_components++) {
114                 uint8_t *component = NULL;
115                 NDR_CHECK(ndr_pull_component(ndr, &component, &offset, &max_offset));
116                 if (component == NULL) break;
117                 if (name) {
118                         name = talloc_asprintf_append_buffer(name, ".%s", component);
119                         NDR_ERR_HAVE_NO_MEMORY(name);
120                 } else {
121                         name = (char *)component;
122                 }
123         }
124         if (num_components == MAX_COMPONENTS) {
125                 return ndr_pull_error(ndr, NDR_ERR_STRING,
126                                       "BAD NBT NAME too many components");
127         }
128         if (num_components == 0) {
129                 name = talloc_strdup(ndr->current_mem_ctx, "");
130                 NDR_ERR_HAVE_NO_MEMORY(name);
131         }
132
133         (*s) = name;
134         ndr->offset = max_offset;
135
136         return NDR_ERR_SUCCESS;
137 }
138
139 /**
140   push a nbt string to the wire
141 */
142 _PUBLIC_ enum ndr_err_code ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const char *s)
143 {
144         if (!(ndr_flags & NDR_SCALARS)) {
145                 return NDR_ERR_SUCCESS;
146         }
147
148         while (s && *s) {
149                 enum ndr_err_code ndr_err;
150                 char *compname;
151                 size_t complen;
152                 uint32_t offset;
153
154                 /* see if we have pushed the remaing string allready,
155                  * if so we use a label pointer to this string
156                  */
157                 ndr_err = ndr_token_retrieve_cmp_fn(&ndr->nbt_string_list, s, &offset, (comparison_fn_t)strcmp, false);
158                 if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
159                         uint8_t b[2];
160
161                         if (offset > 0x3FFF) {
162                                 return ndr_push_error(ndr, NDR_ERR_STRING,
163                                                       "offset for nbt string label pointer %u[%08X] > 0x00003FFF",
164                                                       offset, offset);
165                         }
166
167                         b[0] = 0xC0 | (offset>>8);
168                         b[1] = (offset & 0xFF);
169
170                         return ndr_push_bytes(ndr, b, 2);
171                 }
172
173                 complen = strcspn(s, ".");
174
175                 /* we need to make sure the length fits into 6 bytes */
176                 if (complen > 0x3F) {
177                         return ndr_push_error(ndr, NDR_ERR_STRING,
178                                               "component length %u[%08X] > 0x0000003F",
179                                               (unsigned)complen, (unsigned)complen);
180                 }
181
182                 compname = talloc_asprintf(ndr, "%c%*.*s",
183                                                 (unsigned char)complen,
184                                                 (unsigned char)complen,
185                                                 (unsigned char)complen, s);
186                 NDR_ERR_HAVE_NO_MEMORY(compname);
187
188                 /* remember the current componemt + the rest of the string
189                  * so it can be reused later
190                  */
191                 NDR_CHECK(ndr_token_store(ndr, &ndr->nbt_string_list, s, ndr->offset));
192
193                 /* push just this component into the blob */
194                 NDR_CHECK(ndr_push_bytes(ndr, (const uint8_t *)compname, complen+1));
195                 talloc_free(compname);
196
197                 s += complen;
198                 if (*s == '.') s++;
199         }
200
201         /* if we reach the end of the string and have pushed the last component
202          * without using a label pointer, we need to terminate the string
203          */
204         return ndr_push_bytes(ndr, (const uint8_t *)"", 1);
205 }
206
207
208 /* Manually modified to handle the dom_sid being optional based on if it is present or all zero */
209 enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_REQUEST(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_REQUEST *r)
210 {
211         if (ndr_flags & NDR_SCALARS) {
212                 NDR_CHECK(ndr_push_align(ndr, 4));
213                 NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->request_count));
214                 {
215                         uint32_t _flags_save_string = ndr->flags;
216                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
217                         NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->computer_name));
218                         ndr->flags = _flags_save_string;
219                 }
220                 {
221                         uint32_t _flags_save_string = ndr->flags;
222                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
223                         NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name));
224                         ndr->flags = _flags_save_string;
225                 }
226                 {
227                         uint32_t _flags_save_string = ndr->flags;
228                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
229                         NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->mailslot_name));
230                         ndr->flags = _flags_save_string;
231                 }
232                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->acct_control));
233                 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_dom_sid0(&r->sid, ndr->flags)));
234                 if (ndr_size_dom_sid0(&r->sid, ndr->flags)) {
235                         struct ndr_push *_ndr_sid;
236                         uint32_t _flags_save_DATA_BLOB = ndr->flags;
237                         ndr->flags &= ~LIBNDR_FLAG_NOALIGN;
238                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4);
239                         NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad));
240                         ndr->flags = _flags_save_DATA_BLOB;
241                         NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags)));
242                         NDR_CHECK(ndr_push_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid));
243                         NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags)));
244                 }
245                 NDR_CHECK(ndr_push_netlogon_nt_version_flags(ndr, NDR_SCALARS, r->nt_version));
246                 NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
247                 NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
248         }
249         if (ndr_flags & NDR_BUFFERS) {
250         }
251         return NDR_ERR_SUCCESS;
252 }
253
254 /* Manually modified to handle the dom_sid being optional based on if it is present (size is non-zero) or not */
255 enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_REQUEST(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_REQUEST *r)
256 {
257         if (ndr_flags & NDR_SCALARS) {
258                 NDR_CHECK(ndr_pull_align(ndr, 4));
259                 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->request_count));
260                 {
261                         uint32_t _flags_save_string = ndr->flags;
262                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
263                         NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->computer_name));
264                         ndr->flags = _flags_save_string;
265                 }
266                 {
267                         uint32_t _flags_save_string = ndr->flags;
268                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
269                         NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name));
270                         ndr->flags = _flags_save_string;
271                 }
272                 {
273                         uint32_t _flags_save_string = ndr->flags;
274                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
275                         NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->mailslot_name));
276                         ndr->flags = _flags_save_string;
277                 }
278                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->acct_control));
279                 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sid_size));
280                 if (r->sid_size) {
281                         uint32_t _flags_save_DATA_BLOB = ndr->flags;
282                         struct ndr_pull *_ndr_sid;
283                         ndr->flags &= ~LIBNDR_FLAG_NOALIGN;
284                         ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4);
285                         NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad));
286                         ndr->flags = _flags_save_DATA_BLOB;
287                         NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sid, 0, r->sid_size));
288                         NDR_CHECK(ndr_pull_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid));
289                         NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sid, 0, r->sid_size));
290                 } else {
291                         ZERO_STRUCT(r->sid);
292                 }
293                 NDR_CHECK(ndr_pull_netlogon_nt_version_flags(ndr, NDR_SCALARS, &r->nt_version));
294                 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
295                 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
296         }
297         if (ndr_flags & NDR_BUFFERS) {
298         }
299         return NDR_ERR_SUCCESS;
300 }
301
302 /* Manually modified to only push some parts of the structure if certain flags are set */
303 enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_RESPONSE_EX *r)
304 {
305         {
306                 uint32_t _flags_save_STRUCT = ndr->flags;
307                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
308                 if (ndr_flags & NDR_SCALARS) {
309                         NDR_CHECK(ndr_push_align(ndr, 4));
310                         NDR_CHECK(ndr_push_netlogon_command(ndr, NDR_SCALARS, r->command));
311                         NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->sbz));
312                         NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type));
313                         NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid));
314                         NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest));
315                         NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain));
316                         NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name));
317                         NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->domain_name));
318                         NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_name));
319                         NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->user_name));
320                         NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->server_site));
321                         NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->client_site));
322                         if (r->nt_version & NETLOGON_NT_VERSION_5EX_WITH_IP) {
323                                 NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags)));
324                                 {
325                                         struct ndr_push *_ndr_sockaddr;
326                                         NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sockaddr, 0, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags)));
327                                         NDR_CHECK(ndr_push_nbt_sockaddr(_ndr_sockaddr, NDR_SCALARS|NDR_BUFFERS, &r->sockaddr));
328                                         NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sockaddr, 0, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags)));
329                                 }
330                         }
331                         if (r->nt_version & NETLOGON_NT_VERSION_WITH_CLOSEST_SITE) {
332                                 NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->next_closest_site));
333                         }
334                         NDR_CHECK(ndr_push_netlogon_nt_version_flags(ndr, NDR_SCALARS, r->nt_version));
335                         NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
336                         NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
337                 }
338                 if (ndr_flags & NDR_BUFFERS) {
339                         NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->domain_uuid));
340                 }
341                 ndr->flags = _flags_save_STRUCT;
342         }
343         return NDR_ERR_SUCCESS;
344 }
345
346 /* Manually modified to only pull some parts of the structure if certain flags provided */
347 enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_RESPONSE_EX *r,
348                                                                      uint32_t nt_version_flags)
349 {
350         {
351                 uint32_t _flags_save_STRUCT = ndr->flags;
352                 ZERO_STRUCTP(r);
353                 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
354                 if (ndr_flags & NDR_SCALARS) {
355                         NDR_CHECK(ndr_pull_align(ndr, 4));
356                         NDR_CHECK(ndr_pull_netlogon_command(ndr, NDR_SCALARS, &r->command));
357                         NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->sbz));
358                         NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type));
359                         NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid));
360                         NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest));
361                         NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain));
362                         NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name));
363                         NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->domain_name));
364                         NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_name));
365                         NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->user_name));
366                         NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->server_site));
367                         NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->client_site));
368                         if (nt_version_flags & NETLOGON_NT_VERSION_5EX_WITH_IP) {
369                                 NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->sockaddr_size));
370                                 {
371                                         struct ndr_pull *_ndr_sockaddr;
372                                         NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sockaddr, 0, r->sockaddr_size));
373                                         NDR_CHECK(ndr_pull_nbt_sockaddr(_ndr_sockaddr, NDR_SCALARS|NDR_BUFFERS, &r->sockaddr));
374                                         NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sockaddr, 0, r->sockaddr_size));
375                                 }
376                         }
377                         if (nt_version_flags & NETLOGON_NT_VERSION_WITH_CLOSEST_SITE) {
378                                 NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->next_closest_site));
379                         }
380                         NDR_CHECK(ndr_pull_netlogon_nt_version_flags(ndr, NDR_SCALARS, &r->nt_version));
381                         if (r->nt_version != nt_version_flags) {
382                                 return NDR_ERR_VALIDATE;
383                         }
384                         NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
385                         NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
386                 }
387                 if (ndr_flags & NDR_BUFFERS) {
388                         NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->domain_uuid));
389                 }
390                 ndr->flags = _flags_save_STRUCT;
391         }
392         return NDR_ERR_SUCCESS;
393 }
394
395 _PUBLIC_ enum ndr_err_code ndr_push_netlogon_samlogon_response(struct ndr_push *ndr, int ndr_flags, const struct netlogon_samlogon_response *r)
396 {
397         if (r->ntver == NETLOGON_NT_VERSION_1) {
398                 NDR_CHECK(ndr_push_NETLOGON_SAM_LOGON_RESPONSE_NT40(
399                         ndr, ndr_flags, &r->data.nt4));
400         } else if (r->ntver & NETLOGON_NT_VERSION_5EX) {
401                 NDR_CHECK(ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(
402                         ndr, ndr_flags, &r->data.nt5_ex));
403         } else if (r->ntver & NETLOGON_NT_VERSION_5) {
404                 NDR_CHECK(ndr_push_NETLOGON_SAM_LOGON_RESPONSE(
405                         ndr, ndr_flags, &r->data.nt5));
406         } else {
407                 return NDR_ERR_BAD_SWITCH;
408         }
409
410         return NDR_ERR_SUCCESS;
411 }
412
413 _PUBLIC_ enum ndr_err_code ndr_pull_netlogon_samlogon_response(struct ndr_pull *ndr, int ndr_flags, struct netlogon_samlogon_response *r)
414 {
415         if (ndr->data_size < 8) {
416                 return NDR_ERR_BUFSIZE;
417         }
418
419         /* lmnttoken */
420         if (SVAL(ndr->data, ndr->data_size - 4) != 0xffff) {
421                 return NDR_ERR_TOKEN;
422         }
423         /* lm20token */
424         if (SVAL(ndr->data, ndr->data_size - 2) != 0xffff) {
425                 return NDR_ERR_TOKEN;
426         }
427
428         r->ntver = IVAL(ndr->data, ndr->data_size - 8);
429
430         if (r->ntver == NETLOGON_NT_VERSION_1) {
431                 NDR_CHECK(ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_NT40(
432                         ndr, ndr_flags, &r->data.nt4));
433         } else if (r->ntver & NETLOGON_NT_VERSION_5EX) {
434                 NDR_CHECK(ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(
435                         ndr, ndr_flags, &r->data.nt5_ex, r->ntver));
436                 if (ndr->offset < ndr->data_size) {
437                         return ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
438                                                  "not all bytes consumed ofs[%u] size[%u]",
439                                                  ndr->offset, ndr->data_size);
440                 }
441         } else if (r->ntver & NETLOGON_NT_VERSION_5) {
442                 NDR_CHECK(ndr_pull_NETLOGON_SAM_LOGON_RESPONSE(
443                         ndr, ndr_flags, &r->data.nt5));
444         } else {
445                 return NDR_ERR_BAD_SWITCH;
446         }
447
448         return NDR_ERR_SUCCESS;
449 }