4 Unix SMB/Netbios implementation.
6 Standardised Authentication types
7 Copyright (C) Andrew Bartlett 2001
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 2 of the License, or
12 (at your option) any later version.
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.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 /* AUTH_STR - string */
25 typedef struct normal_string
31 /* AUTH_UNISTR - unicode string or buffer */
32 typedef struct unicode_string
38 typedef struct interactive_password
40 OWF_INFO lm_owf; /* LM OWF Password */
41 OWF_INFO nt_owf; /* NT OWF Password */
42 } auth_interactive_password;
44 #define AUTH_FLAG_NONE 0x000000
45 #define AUTH_FLAG_PLAINTEXT 0x000001
46 #define AUTH_FLAG_LM_RESP 0x000002
47 #define AUTH_FLAG_NTLM_RESP 0x000004
48 #define AUTH_FLAG_NTLMv2_RESP 0x000008
50 typedef struct auth_usersupplied_info
55 auth_interactive_password * interactive_password;
56 DATA_BLOB plaintext_password;
62 AUTH_STR client_domain; /* domain name string */
63 AUTH_STR domain; /* domain name after mapping */
64 AUTH_STR internal_username; /* username after mapping */
65 AUTH_STR smb_name; /* username before mapping */
66 AUTH_STR wksta_name; /* workstation name (netbios calling name) unicode string */
68 } auth_usersupplied_info;
70 #define SAM_FILL_NAME 0x01
71 #define SAM_FILL_INFO3 0x02
72 #define SAM_FILL_SAM 0x04
73 #define SAM_FILL_UNIX 0x08
74 #define SAM_FILL_ALL (SAM_FILL_NAME | SAM_FILL_INFO3 | SAM_FILL_SAM | SAM_FILL_UNIX)
76 typedef struct auth_serversupplied_info
80 /* This groups info is needed for when we become_user() for this uid */
84 /* NT group information taken from the info3 structure */
88 uint8 session_key[16];
90 uint8 first_8_lm_hash[8];
92 uint32 sam_fill_level; /* How far is this structure filled? */
94 SAM_ACCOUNT *sam_account;
98 } auth_serversupplied_info;
100 struct auth_context {
103 /* Who set this up in the first place? */
104 char *challenge_set_by;
106 struct auth_methods *challenge_set_method;
107 /* What order are the various methods in? Try to stop it changing under us */
108 struct auth_methods *auth_method_list;
111 const uint8 *(*get_ntlm_challenge)(struct auth_context *auth_context);
112 NTSTATUS (*check_ntlm_password)(const struct auth_context *auth_context,
113 const struct auth_usersupplied_info *user_info,
114 struct auth_serversupplied_info **server_info);
115 NTSTATUS (*nt_status_squash)(NTSTATUS nt_status);
116 void (*free)(struct auth_context **auth_context);
119 typedef struct auth_methods
121 struct auth_methods *prev, *next;
122 char *name; /* What name got this module */
124 NTSTATUS (*auth)(const struct auth_context *auth_context,
125 void *my_private_data,
127 const struct auth_usersupplied_info *user_info,
128 auth_serversupplied_info **server_info);
130 DATA_BLOB (*get_chal)(const struct auth_context *auth_context,
131 void **my_private_data,
132 TALLOC_CTX *mem_ctx);
134 /* Used to keep tabs on things like the cli for SMB server authentication */
137 /* Function to clean up the above arbitary structure */
138 void (*free_private_data)(void **private_data);
140 /* Function to send a keepalive message on the above structure */
141 void (*send_keepalive)(void **private_data);
145 struct auth_init_function {
147 /* Function to create a member of the authmethods list */
148 BOOL (*init)(struct auth_context *auth_context, struct auth_methods **auth_method);
152 #endif /* _SMBAUTH_H_ */