2 Unix SMB/CIFS implementation.
4 Generic Authentication Interface
6 Copyright (C) Andrew Tridgell 2003
7 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 do a non-athenticated dcerpc bind
30 NTSTATUS dcerpc_bind_auth_none(struct dcerpc_pipe *p,
31 const char *uuid, uint_t version)
36 mem_ctx = talloc_init("dcerpc_bind_auth_ntlm");
38 return NT_STATUS_NO_MEMORY;
41 status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version);
42 talloc_destroy(mem_ctx);
47 NTSTATUS dcerpc_bind_auth3(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth_level,
48 const char *uuid, uint_t version)
52 DATA_BLOB credentials;
53 DATA_BLOB null_data_blob = data_blob(NULL, 0);
55 mem_ctx = talloc_init("dcerpc_bind_auth");
57 return NT_STATUS_NO_MEMORY;
60 if (!p->security_state.generic_state) {
61 status = gensec_client_start(p, &p->security_state.generic_state);
62 if (!NT_STATUS_IS_OK(status)) {
66 status = gensec_start_mech_by_authtype(p->security_state.generic_state, auth_type, auth_level);
68 if (!NT_STATUS_IS_OK(status)) {
73 p->security_state.auth_info = talloc_p(p, struct dcerpc_auth);
74 if (!p->security_state.auth_info) {
75 status = NT_STATUS_NO_MEMORY;
79 p->security_state.auth_info->auth_type = auth_type;
80 p->security_state.auth_info->auth_level = auth_level;
81 p->security_state.auth_info->auth_pad_length = 0;
82 p->security_state.auth_info->auth_reserved = 0;
83 p->security_state.auth_info->auth_context_id = random();
84 p->security_state.auth_info->credentials = null_data_blob;
86 status = gensec_update(p->security_state.generic_state, mem_ctx,
90 if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
94 p->security_state.auth_info->credentials = credentials;
96 status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version);
97 if (!NT_STATUS_IS_OK(status)) {
101 status = gensec_update(p->security_state.generic_state, mem_ctx,
102 p->security_state.auth_info->credentials,
105 if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
109 p->security_state.auth_info->credentials = credentials;
111 status = dcerpc_auth3(p, mem_ctx);
113 talloc_destroy(mem_ctx);
115 if (!NT_STATUS_IS_OK(status)) {
116 talloc_free(p->security_state.generic_state);
117 ZERO_STRUCT(p->security_state);
119 /* Authenticated connections use the generic session key */
120 p->security_state.session_key = dcerpc_generic_session_key;
126 NTSTATUS dcerpc_bind_alter(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth_level,
127 const char *uuid, uint_t version)
131 DATA_BLOB credentials;
132 DATA_BLOB null_data_blob = data_blob(NULL, 0);
134 mem_ctx = talloc_init("dcerpc_bind_auth");
136 return NT_STATUS_NO_MEMORY;
139 if (!p->security_state.generic_state) {
140 status = gensec_client_start(p, &p->security_state.generic_state);
141 if (!NT_STATUS_IS_OK(status)) {
145 status = gensec_start_mech_by_authtype(p->security_state.generic_state,
146 auth_type, auth_level);
148 if (!NT_STATUS_IS_OK(status)) {
153 p->security_state.auth_info = talloc_p(p, struct dcerpc_auth);
154 if (!p->security_state.auth_info) {
155 status = NT_STATUS_NO_MEMORY;
159 p->security_state.auth_info->auth_type = auth_type;
160 p->security_state.auth_info->auth_level = auth_level;
161 p->security_state.auth_info->auth_pad_length = 0;
162 p->security_state.auth_info->auth_reserved = 0;
163 p->security_state.auth_info->auth_context_id = random();
164 p->security_state.auth_info->credentials = null_data_blob;
166 status = gensec_update(p->security_state.generic_state, mem_ctx,
170 if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
174 p->security_state.auth_info->credentials = credentials;
176 status = dcerpc_bind_byuuid(p, mem_ctx, uuid, version);
177 if (!NT_STATUS_IS_OK(status)) {
182 status = gensec_update(p->security_state.generic_state, mem_ctx,
183 p->security_state.auth_info->credentials,
186 if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
190 p->security_state.auth_info->credentials = credentials;
192 status = dcerpc_alter(p, mem_ctx);
193 if (!NT_STATUS_IS_OK(status)) {
199 talloc_destroy(mem_ctx);
201 if (!NT_STATUS_IS_OK(status)) {
202 ZERO_STRUCT(p->security_state);
204 /* Authenticated connections use the generic session key */
205 p->security_state.session_key = dcerpc_generic_session_key;