2 Unix SMB/CIFS implementation.
4 dcerpc authentication operations
6 Copyright (C) Andrew Tridgell 2003
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 do a simple ntlm style authentication on a dcerpc pipe
28 NTSTATUS dcerpc_bind_auth_ntlm(struct dcerpc_pipe *p,
29 const char *uuid, unsigned version,
35 struct ntlmssp_state *state;
37 DATA_BLOB credentials;
39 mem_ctx = talloc_init("dcerpc_bind_auth_ntlm");
41 return NT_STATUS_NO_MEMORY;
44 status = ntlmssp_client_start(&state);
45 if (!NT_STATUS_IS_OK(status)) {
49 status = ntlmssp_set_domain(state, domain);
50 if (!NT_STATUS_IS_OK(status)) {
54 status = ntlmssp_set_username(state, username);
55 if (!NT_STATUS_IS_OK(status)) {
59 status = ntlmssp_set_password(state, password);
60 if (!NT_STATUS_IS_OK(status)) {
64 p->auth_info = talloc(p->mem_ctx, sizeof(*p->auth_info));
66 status = NT_STATUS_NO_MEMORY;
70 p->auth_info->auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
71 p->auth_info->auth_level = DCERPC_AUTH_LEVEL_INTEGRITY;
72 p->auth_info->auth_pad_length = 0;
73 p->auth_info->auth_reserved = 0;
74 p->auth_info->auth_context_id = random();
75 p->auth_info->credentials = data_blob(NULL, 0);
76 p->ntlmssp_state = NULL;
78 status = ntlmssp_update(state,
79 p->auth_info->credentials,
81 if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
85 p->auth_info->credentials = data_blob_talloc(mem_ctx,
88 data_blob_free(&credentials);
90 status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version);
91 if (!NT_STATUS_IS_OK(status)) {
96 status = ntlmssp_update(state,
97 p->auth_info->credentials,
99 if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
103 p->auth_info->credentials = data_blob_talloc(mem_ctx,
106 data_blob_free(&credentials);
108 status = dcerpc_auth3(p, mem_ctx);
110 if (!NT_STATUS_IS_OK(status)) {
114 p->ntlmssp_state = state;
116 /* setup for signing */
117 status = ntlmssp_sign_init(state);
120 talloc_destroy(mem_ctx);
122 if (!NT_STATUS_IS_OK(status)) {
123 p->ntlmssp_state = NULL;
131 do a non-athenticated dcerpc bind
133 NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p,
134 const char *uuid, unsigned version)
139 mem_ctx = talloc_init("dcerpc_bind_auth_ntlm");
141 return NT_STATUS_NO_MEMORY;
144 status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version);
145 talloc_destroy(mem_ctx);