2 Unix SMB/CIFS implementation.
4 dcerpc utility functions
6 Copyright (C) Andrew Tridgell 2003
7 Copyright (C) Jelmer Vernooij 2004
8 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
9 Copyright (C) Rafal Szczesniak 2006
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include "lib/events/events.h"
27 #include "libcli/composite/composite.h"
28 #include "librpc/gen_ndr/ndr_epmapper_c.h"
29 #include "librpc/gen_ndr/ndr_dcerpc.h"
30 #include "librpc/gen_ndr/ndr_misc.h"
31 #include "librpc/rpc/dcerpc_proto.h"
32 #include "auth/credentials/credentials.h"
33 #include "param/param.h"
36 find a dcerpc call on an interface by name
38 const struct ndr_interface_call *dcerpc_iface_find_call(const struct ndr_interface_table *iface,
42 for (i=0;i<iface->num_calls;i++) {
43 if (strcmp(iface->calls[i].name, name) == 0) {
44 return &iface->calls[i];
51 push a ncacn_packet into a blob, potentially with auth info
53 NTSTATUS ncacn_push_auth(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
54 struct smb_iconv_convenience *iconv_convenience,
55 struct ncacn_packet *pkt,
56 struct dcerpc_auth *auth_info)
59 enum ndr_err_code ndr_err;
61 ndr = ndr_push_init_ctx(mem_ctx, iconv_convenience);
63 return NT_STATUS_NO_MEMORY;
66 if (!(pkt->drep[0] & DCERPC_DREP_LE)) {
67 ndr->flags |= LIBNDR_FLAG_BIGENDIAN;
70 if (pkt->pfc_flags & DCERPC_PFC_FLAG_OBJECT_UUID) {
71 ndr->flags |= LIBNDR_FLAG_OBJECT_PRESENT;
75 pkt->auth_length = auth_info->credentials.length;
80 ndr_err = ndr_push_ncacn_packet(ndr, NDR_SCALARS|NDR_BUFFERS, pkt);
81 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
82 return ndr_map_error2ntstatus(ndr_err);
87 /* the s3 rpc server doesn't handle auth padding in
88 bind requests. Use zero auth padding to keep us
89 working with old servers */
90 uint32_t offset = ndr->offset;
91 ndr_err = ndr_push_align(ndr, 16);
92 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
93 return ndr_map_error2ntstatus(ndr_err);
95 auth_info->auth_pad_length = ndr->offset - offset;
97 auth_info->auth_pad_length = 0;
99 ndr_err = ndr_push_dcerpc_auth(ndr, NDR_SCALARS|NDR_BUFFERS, auth_info);
100 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
101 return ndr_map_error2ntstatus(ndr_err);
105 *blob = ndr_push_blob(ndr);
107 /* fill in the frag length */
108 dcerpc_set_frag_length(blob, blob->length);
114 struct epm_map_binding_state {
115 struct dcerpc_binding *binding;
116 const struct ndr_interface_table *table;
117 struct dcerpc_pipe *pipe;
118 struct policy_handle handle;
120 struct epm_twr_t twr;
121 struct epm_twr_t *twr_r;
126 static void continue_epm_recv_binding(struct composite_context *ctx);
127 static void continue_epm_map(struct rpc_request *req);
131 Stage 2 of epm_map_binding: Receive connected rpc pipe and send endpoint
134 static void continue_epm_recv_binding(struct composite_context *ctx)
136 struct rpc_request *map_req;
138 struct composite_context *c = talloc_get_type(ctx->async.private_data,
139 struct composite_context);
140 struct epm_map_binding_state *s = talloc_get_type(c->private_data,
141 struct epm_map_binding_state);
143 /* receive result of rpc pipe connect request */
144 c->status = dcerpc_pipe_connect_b_recv(ctx, c, &s->pipe);
145 if (!composite_is_ok(c)) return;
147 s->pipe->conn->flags |= DCERPC_NDR_REF_ALLOC;
149 /* prepare requested binding parameters */
150 s->binding->object = s->table->syntax_id;
152 c->status = dcerpc_binding_build_tower(s->pipe, s->binding, &s->twr.tower);
153 if (!composite_is_ok(c)) return;
155 /* with some nice pretty paper around it of course */
156 s->r.in.object = &s->guid;
157 s->r.in.map_tower = &s->twr;
158 s->r.in.entry_handle = &s->handle;
159 s->r.in.max_towers = 1;
160 s->r.out.entry_handle = &s->handle;
162 /* send request for an endpoint mapping - a rpc request on connected pipe */
163 map_req = dcerpc_epm_Map_send(s->pipe, c, &s->r);
164 if (composite_nomem(map_req, c)) return;
166 composite_continue_rpc(c, map_req, continue_epm_map, c);
171 Stage 3 of epm_map_binding: Receive endpoint mapping and provide binding details
173 static void continue_epm_map(struct rpc_request *req)
175 struct composite_context *c = talloc_get_type(req->async.private_data,
176 struct composite_context);
177 struct epm_map_binding_state *s = talloc_get_type(c->private_data,
178 struct epm_map_binding_state);
180 /* receive result of a rpc request */
181 c->status = dcerpc_ndr_request_recv(req);
182 if (!composite_is_ok(c)) return;
184 /* check the details */
185 if (s->r.out.result != 0 || *s->r.out.num_towers != 1) {
186 composite_error(c, NT_STATUS_PORT_UNREACHABLE);
190 s->twr_r = s->r.out.towers[0].twr;
191 if (s->twr_r == NULL) {
192 composite_error(c, NT_STATUS_PORT_UNREACHABLE);
196 if (s->twr_r->tower.num_floors != s->twr.tower.num_floors ||
197 s->twr_r->tower.floors[3].lhs.protocol != s->twr.tower.floors[3].lhs.protocol) {
198 composite_error(c, NT_STATUS_PORT_UNREACHABLE);
202 /* get received endpoint */
203 s->binding->endpoint = talloc_reference(s->binding,
204 dcerpc_floor_get_rhs_data(c, &s->twr_r->tower.floors[3]));
205 if (composite_nomem(s->binding->endpoint, c)) return;
212 Request for endpoint mapping of dcerpc binding - try to request for endpoint
213 unless there is default one.
215 struct composite_context *dcerpc_epm_map_binding_send(TALLOC_CTX *mem_ctx,
216 struct dcerpc_binding *binding,
217 const struct ndr_interface_table *table,
218 struct tevent_context *ev,
219 struct loadparm_context *lp_ctx)
221 struct composite_context *c;
222 struct epm_map_binding_state *s;
223 struct composite_context *pipe_connect_req;
224 struct cli_credentials *anon_creds;
227 struct dcerpc_binding *epmapper_binding;
234 /* composite context allocation and setup */
235 c = composite_create(mem_ctx, ev);
240 s = talloc_zero(c, struct epm_map_binding_state);
241 if (composite_nomem(s, c)) return c;
244 s->binding = binding;
247 /* anonymous credentials for rpc connection used to get endpoint mapping */
248 anon_creds = cli_credentials_init(mem_ctx);
249 cli_credentials_set_anonymous(anon_creds);
252 First, check if there is a default endpoint specified in the IDL
255 struct dcerpc_binding *default_binding;
257 /* Find one of the default pipes for this interface */
258 for (i = 0; i < table->endpoints->count; i++) {
259 status = dcerpc_parse_binding(mem_ctx, table->endpoints->names[i], &default_binding);
261 if (NT_STATUS_IS_OK(status)) {
262 if (binding->transport == NCA_UNKNOWN)
263 binding->transport = default_binding->transport;
264 if (default_binding->transport == binding->transport &&
265 default_binding->endpoint) {
266 binding->endpoint = talloc_reference(binding, default_binding->endpoint);
267 talloc_free(default_binding);
273 talloc_free(default_binding);
279 epmapper_binding = talloc_zero(c, struct dcerpc_binding);
280 if (composite_nomem(epmapper_binding, c)) return c;
282 /* basic endpoint mapping data */
283 epmapper_binding->transport = binding->transport;
284 epmapper_binding->host = talloc_reference(epmapper_binding, binding->host);
285 epmapper_binding->target_hostname = epmapper_binding->host;
286 epmapper_binding->options = NULL;
287 epmapper_binding->flags = 0;
288 epmapper_binding->assoc_group_id = 0;
289 epmapper_binding->endpoint = NULL;
291 /* initiate rpc pipe connection */
292 pipe_connect_req = dcerpc_pipe_connect_b_send(c, epmapper_binding,
294 anon_creds, c->event_ctx,
296 if (composite_nomem(pipe_connect_req, c)) return c;
298 composite_continue(c, pipe_connect_req, continue_epm_recv_binding, c);
304 Receive result of endpoint mapping request
306 NTSTATUS dcerpc_epm_map_binding_recv(struct composite_context *c)
308 NTSTATUS status = composite_wait(c);
316 Get endpoint mapping for rpc connection
318 _PUBLIC_ NTSTATUS dcerpc_epm_map_binding(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding,
319 const struct ndr_interface_table *table, struct tevent_context *ev,
320 struct loadparm_context *lp_ctx)
322 struct composite_context *c;
324 c = dcerpc_epm_map_binding_send(mem_ctx, binding, table, ev, lp_ctx);
325 return dcerpc_epm_map_binding_recv(c);
329 struct pipe_auth_state {
330 struct dcerpc_pipe *pipe;
331 struct dcerpc_binding *binding;
332 const struct ndr_interface_table *table;
333 struct loadparm_context *lp_ctx;
334 struct cli_credentials *credentials;
338 static void continue_auth_schannel(struct composite_context *ctx);
339 static void continue_auth(struct composite_context *ctx);
340 static void continue_auth_none(struct composite_context *ctx);
341 static void continue_ntlmssp_connection(struct composite_context *ctx);
342 static void continue_spnego_after_wrong_pass(struct composite_context *ctx);
346 Stage 2 of pipe_auth: Receive result of schannel bind request
348 static void continue_auth_schannel(struct composite_context *ctx)
350 struct composite_context *c = talloc_get_type(ctx->async.private_data,
351 struct composite_context);
353 c->status = dcerpc_bind_auth_schannel_recv(ctx);
354 if (!composite_is_ok(c)) return;
361 Stage 2 of pipe_auth: Receive result of authenticated bind request
363 static void continue_auth(struct composite_context *ctx)
365 struct composite_context *c = talloc_get_type(ctx->async.private_data,
366 struct composite_context);
368 c->status = dcerpc_bind_auth_recv(ctx);
369 if (!composite_is_ok(c)) return;
374 Stage 2 of pipe_auth: Receive result of authenticated bind request, but handle fallbacks:
377 static void continue_auth_auto(struct composite_context *ctx)
379 struct composite_context *c = talloc_get_type(ctx->async.private_data,
380 struct composite_context);
381 struct pipe_auth_state *s = talloc_get_type(c->private_data, struct pipe_auth_state);
382 struct composite_context *sec_conn_req;
384 c->status = dcerpc_bind_auth_recv(ctx);
385 if (NT_STATUS_EQUAL(c->status, NT_STATUS_INVALID_PARAMETER)) {
387 * Retry with NTLMSSP auth as fallback
388 * send a request for secondary rpc connection
390 sec_conn_req = dcerpc_secondary_connection_send(s->pipe,
392 composite_continue(c, sec_conn_req, continue_ntlmssp_connection, c);
394 } else if (NT_STATUS_EQUAL(c->status, NT_STATUS_LOGON_FAILURE)) {
395 if (cli_credentials_wrong_password(s->credentials)) {
397 * Retry SPNEGO with a better password
398 * send a request for secondary rpc connection
400 sec_conn_req = dcerpc_secondary_connection_send(s->pipe,
402 composite_continue(c, sec_conn_req, continue_spnego_after_wrong_pass, c);
407 if (!composite_is_ok(c)) return;
413 Stage 3 of pipe_auth (fallback to NTLMSSP case): Receive secondary
414 rpc connection (the first one can't be used any more, due to the
415 bind nak) and perform authenticated bind request
417 static void continue_ntlmssp_connection(struct composite_context *ctx)
419 struct composite_context *c;
420 struct pipe_auth_state *s;
421 struct composite_context *auth_req;
422 struct dcerpc_pipe *p2;
424 c = talloc_get_type(ctx->async.private_data, struct composite_context);
425 s = talloc_get_type(c->private_data, struct pipe_auth_state);
427 /* receive secondary rpc connection */
428 c->status = dcerpc_secondary_connection_recv(ctx, &p2);
429 if (!composite_is_ok(c)) return;
432 talloc_steal(p2, s->pipe);
435 /* initiate a authenticated bind */
436 auth_req = dcerpc_bind_auth_send(c, s->pipe, s->table,
438 lp_gensec_settings(c, s->lp_ctx),
439 DCERPC_AUTH_TYPE_NTLMSSP,
440 dcerpc_auth_level(s->pipe->conn),
441 s->table->authservices->names[0]);
442 composite_continue(c, auth_req, continue_auth, c);
446 Stage 3 of pipe_auth (retry on wrong password): Receive secondary
447 rpc connection (the first one can't be used any more, due to the
448 bind nak) and perform authenticated bind request
450 static void continue_spnego_after_wrong_pass(struct composite_context *ctx)
452 struct composite_context *c;
453 struct pipe_auth_state *s;
454 struct composite_context *auth_req;
455 struct dcerpc_pipe *p2;
457 c = talloc_get_type(ctx->async.private_data, struct composite_context);
458 s = talloc_get_type(c->private_data, struct pipe_auth_state);
460 /* receive secondary rpc connection */
461 c->status = dcerpc_secondary_connection_recv(ctx, &p2);
462 if (!composite_is_ok(c)) return;
465 talloc_steal(p2, s->pipe);
468 /* initiate a authenticated bind */
469 auth_req = dcerpc_bind_auth_send(c, s->pipe, s->table,
471 lp_gensec_settings(c, s->lp_ctx),
472 DCERPC_AUTH_TYPE_SPNEGO,
473 dcerpc_auth_level(s->pipe->conn),
474 s->table->authservices->names[0]);
475 composite_continue(c, auth_req, continue_auth, c);
480 Stage 2 of pipe_auth: Receive result of non-authenticated bind request
482 static void continue_auth_none(struct composite_context *ctx)
484 struct composite_context *c = talloc_get_type(ctx->async.private_data,
485 struct composite_context);
487 c->status = dcerpc_bind_auth_none_recv(ctx);
488 if (!composite_is_ok(c)) return;
495 Request to perform an authenticated bind if required. Authentication
496 is determined using credentials passed and binding flags.
498 struct composite_context *dcerpc_pipe_auth_send(struct dcerpc_pipe *p,
499 struct dcerpc_binding *binding,
500 const struct ndr_interface_table *table,
501 struct cli_credentials *credentials,
502 struct loadparm_context *lp_ctx)
504 struct composite_context *c;
505 struct pipe_auth_state *s;
506 struct composite_context *auth_schannel_req;
507 struct composite_context *auth_req;
508 struct composite_context *auth_none_req;
509 struct dcerpc_connection *conn;
512 /* composite context allocation and setup */
513 c = composite_create(p, p->conn->event_ctx);
514 if (c == NULL) return NULL;
516 s = talloc_zero(c, struct pipe_auth_state);
517 if (composite_nomem(s, c)) return c;
520 /* store parameters in state structure */
521 s->binding = binding;
523 s->credentials = credentials;
527 conn = s->pipe->conn;
528 conn->flags = binding->flags;
531 conn->flags |= DCERPC_DEBUG_PRINT_BOTH;
534 /* remember the binding string for possible secondary connections */
535 conn->binding_string = dcerpc_binding_string(p, binding);
537 if (cli_credentials_is_anonymous(s->credentials)) {
538 auth_none_req = dcerpc_bind_auth_none_send(c, s->pipe, s->table);
539 composite_continue(c, auth_none_req, continue_auth_none, c);
543 if ((binding->flags & DCERPC_SCHANNEL) &&
544 !cli_credentials_get_netlogon_creds(s->credentials)) {
545 /* If we don't already have netlogon credentials for
546 * the schannel bind, then we have to get these
548 auth_schannel_req = dcerpc_bind_auth_schannel_send(c, s->pipe, s->table,
549 s->credentials, s->lp_ctx,
550 dcerpc_auth_level(conn));
551 composite_continue(c, auth_schannel_req, continue_auth_schannel, c);
556 * we rely on the already authenticated CIFS connection
557 * if not doing sign or seal
559 if (conn->transport.transport == NCACN_NP &&
560 !(s->binding->flags & (DCERPC_SIGN|DCERPC_SEAL))) {
561 auth_none_req = dcerpc_bind_auth_none_send(c, s->pipe, s->table);
562 composite_continue(c, auth_none_req, continue_auth_none, c);
567 /* Perform an authenticated DCE-RPC bind
569 if (!(conn->flags & (DCERPC_SIGN|DCERPC_SEAL))) {
571 we are doing an authenticated connection,
572 but not using sign or seal. We must force
573 the CONNECT dcerpc auth type as a NONE auth
574 type doesn't allow authentication
575 information to be passed.
577 conn->flags |= DCERPC_CONNECT;
580 if (s->binding->flags & DCERPC_AUTH_SPNEGO) {
581 auth_type = DCERPC_AUTH_TYPE_SPNEGO;
583 } else if (s->binding->flags & DCERPC_AUTH_KRB5) {
584 auth_type = DCERPC_AUTH_TYPE_KRB5;
586 } else if (s->binding->flags & DCERPC_SCHANNEL) {
587 auth_type = DCERPC_AUTH_TYPE_SCHANNEL;
589 } else if (s->binding->flags & DCERPC_AUTH_NTLM) {
590 auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
593 /* try SPNEGO with fallback to NTLMSSP */
594 auth_req = dcerpc_bind_auth_send(c, s->pipe, s->table,
596 lp_gensec_settings(c, s->lp_ctx),
597 DCERPC_AUTH_TYPE_SPNEGO,
598 dcerpc_auth_level(conn),
599 s->table->authservices->names[0]);
600 composite_continue(c, auth_req, continue_auth_auto, c);
604 auth_req = dcerpc_bind_auth_send(c, s->pipe, s->table,
606 lp_gensec_settings(c, s->lp_ctx),
608 dcerpc_auth_level(conn),
609 s->table->authservices->names[0]);
610 composite_continue(c, auth_req, continue_auth, c);
616 Receive result of authenticated bind request on dcerpc pipe
618 This returns *p, which may be different to the one originally
619 supllied, as it rebinds to a new pipe due to authentication fallback
622 NTSTATUS dcerpc_pipe_auth_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
623 struct dcerpc_pipe **p)
627 struct pipe_auth_state *s = talloc_get_type(c->private_data,
628 struct pipe_auth_state);
629 status = composite_wait(c);
630 if (!NT_STATUS_IS_OK(status)) {
631 char *uuid_str = GUID_string(s->pipe, &s->table->syntax_id.uuid);
632 DEBUG(0, ("Failed to bind to uuid %s - %s\n", uuid_str, nt_errstr(status)));
633 talloc_free(uuid_str);
635 talloc_steal(mem_ctx, s->pipe);
645 Perform an authenticated bind if needed - sync version
647 This may change *p, as it rebinds to a new pipe due to authentication fallback
649 _PUBLIC_ NTSTATUS dcerpc_pipe_auth(TALLOC_CTX *mem_ctx,
650 struct dcerpc_pipe **p,
651 struct dcerpc_binding *binding,
652 const struct ndr_interface_table *table,
653 struct cli_credentials *credentials,
654 struct loadparm_context *lp_ctx)
656 struct composite_context *c;
658 c = dcerpc_pipe_auth_send(*p, binding, table, credentials, lp_ctx);
659 return dcerpc_pipe_auth_recv(c, mem_ctx, p);
663 NTSTATUS dcerpc_generic_session_key(struct dcerpc_connection *c,
664 DATA_BLOB *session_key)
666 /* this took quite a few CPU cycles to find ... */
667 session_key->data = discard_const_p(unsigned char, "SystemLibraryDTC");
668 session_key->length = 16;
673 fetch the user session key - may be default (above) or the SMB session key
675 The key is always truncated to 16 bytes
677 _PUBLIC_ NTSTATUS dcerpc_fetch_session_key(struct dcerpc_pipe *p,
678 DATA_BLOB *session_key)
681 status = p->conn->security_state.session_key(p->conn, session_key);
682 if (!NT_STATUS_IS_OK(status)) {
686 session_key->length = MIN(session_key->length, 16);
693 log a rpc packet in a format suitable for ndrdump. This is especially useful
694 for sealed packets, where ethereal cannot easily see the contents
696 this triggers on a debug level of >= 10
698 _PUBLIC_ void dcerpc_log_packet(const char *lockdir,
699 const struct ndr_interface_table *ndr,
700 uint32_t opnum, uint32_t flags,
703 const int num_examples = 20;
706 if (lockdir == NULL) return;
708 for (i=0;i<num_examples;i++) {
710 asprintf(&name, "%s/rpclog/%s-%u.%d.%s",
711 lockdir, ndr->name, opnum, i,
712 (flags&NDR_IN)?"in":"out");
716 if (!file_exist(name)) {
717 if (file_save(name, pkt->data, pkt->length)) {
718 DEBUG(10,("Logged rpc packet to %s\n", name));
730 create a secondary context from a primary connection
732 this uses dcerpc_alter_context() to create a new dcerpc context_id
734 _PUBLIC_ NTSTATUS dcerpc_secondary_context(struct dcerpc_pipe *p,
735 struct dcerpc_pipe **pp2,
736 const struct ndr_interface_table *table)
739 struct dcerpc_pipe *p2;
741 p2 = talloc_zero(p, struct dcerpc_pipe);
743 return NT_STATUS_NO_MEMORY;
745 p2->conn = talloc_reference(p2, p->conn);
746 p2->request_timeout = p->request_timeout;
748 p2->context_id = ++p->conn->next_context_id;
750 p2->syntax = table->syntax_id;
752 p2->transfer_syntax = p->transfer_syntax;
754 p2->binding = talloc_reference(p2, p->binding);
756 status = dcerpc_alter_context(p2, p2, &p2->syntax, &p2->transfer_syntax);
757 if (!NT_STATUS_IS_OK(status)) {
769 pull an dcerpc_auth structure, taking account of any auth padding in
770 the blob at the end of the structure
772 NTSTATUS dcerpc_pull_auth_trailer(struct ncacn_packet *pkt,
774 DATA_BLOB *pkt_auth_blob,
775 struct dcerpc_auth *auth,
776 uint32_t *auth_length,
779 struct ndr_pull *ndr;
780 enum ndr_err_code ndr_err;
783 pad = pkt_auth_blob->length - (DCERPC_AUTH_TRAILER_LENGTH + pkt->auth_length);
785 /* paranoia check for pad size. This would be caught anyway by
786 the ndr_pull_advance() a few lines down, but it scared
787 Jeremy enough for him to call me, so we might as well check
788 it now, just to prevent someone posting a bogus YouTube
791 if (pad > pkt_auth_blob->length) {
792 return NT_STATUS_INFO_LENGTH_MISMATCH;
795 *auth_length = pkt_auth_blob->length - pad;
797 ndr = ndr_pull_init_blob(pkt_auth_blob, mem_ctx, NULL);
799 return NT_STATUS_NO_MEMORY;
802 if (!(pkt->drep[0] & DCERPC_DREP_LE)) {
803 ndr->flags |= LIBNDR_FLAG_BIGENDIAN;
806 ndr_err = ndr_pull_advance(ndr, pad);
807 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
809 return ndr_map_error2ntstatus(ndr_err);
812 ndr_err = ndr_pull_dcerpc_auth(ndr, NDR_SCALARS|NDR_BUFFERS, auth);
813 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
815 return ndr_map_error2ntstatus(ndr_err);
818 if (check_pad && pad != auth->auth_pad_length) {
819 DEBUG(1,(__location__ ": WARNING: pad length mismatch. Calculated %u got %u\n",
820 (unsigned)pad, (unsigned)auth->auth_pad_length));
823 DEBUG(6,(__location__ ": auth_pad_length %u\n",
824 (unsigned)auth->auth_pad_length));
826 talloc_steal(mem_ctx, auth->credentials.data);