r23792: convert Samba4 to GPLv3
[garming/samba-autobuild/.git] / source4 / auth / credentials / credentials.h
1 /* 
2    samba -- Unix SMB/CIFS implementation.
3
4    Client credentials structure
5
6    Copyright (C) Jelmer Vernooij 2004-2006
7    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
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 #ifndef __CREDENTIALS_H__
23 #define __CREDENTIALS_H__
24
25 #include "librpc/gen_ndr/misc.h"
26
27 struct ccache_container;
28
29 /* In order of priority */
30 enum credentials_obtained { 
31         CRED_UNINITIALISED = 0,  /* We don't even have a guess yet */
32         CRED_CALLBACK,           /* Callback should be used to obtain value */
33         CRED_GUESS_ENV,          /* Current value should be used, which was guessed */
34         CRED_GUESS_FILE,         /* A guess from a file (or file pointed at in env variable) */
35         CRED_CALLBACK_RESULT,    /* Value was obtained from a callback */
36         CRED_SPECIFIED           /* Was explicitly specified on the command-line */
37 };
38
39 enum credentials_use_kerberos {
40         CRED_AUTO_USE_KERBEROS = 0, /* Default, we try kerberos if available */
41         CRED_DONT_USE_KERBEROS,     /* Sometimes trying kerberos just does 'bad things', so don't */
42         CRED_MUST_USE_KERBEROS      /* Sometimes administrators are parinoid, so always do kerberos */
43 };
44
45 #define CLI_CRED_NTLM2       0x01
46 #define CLI_CRED_NTLMv2_AUTH 0x02
47 #define CLI_CRED_LANMAN_AUTH 0x04
48 #define CLI_CRED_NTLM_AUTH   0x08
49 #define CLI_CRED_CLEAR_AUTH  0x10   /* TODO:  Push cleartext auth with this flag */
50
51 struct cli_credentials {
52         enum credentials_obtained workstation_obtained;
53         enum credentials_obtained username_obtained;
54         enum credentials_obtained password_obtained;
55         enum credentials_obtained domain_obtained;
56         enum credentials_obtained realm_obtained;
57         enum credentials_obtained ccache_obtained;
58         enum credentials_obtained client_gss_creds_obtained;
59         enum credentials_obtained principal_obtained;
60         enum credentials_obtained keytab_obtained;
61         enum credentials_obtained server_gss_creds_obtained;
62
63         /* Threshold values (essentially a MAX() over a number of the
64          * above) for the ccache and GSS credentials, to ensure we
65          * regenerate/pick correctly */
66
67         enum credentials_obtained ccache_threshold;
68         enum credentials_obtained client_gss_creds_threshold;
69
70         const char *workstation;
71         const char *username;
72         const char *password;
73         const char *old_password;
74         const char *domain;
75         const char *realm;
76         const char *principal;
77         const char *salt_principal;
78
79         const char *bind_dn;
80
81         struct samr_Password *nt_hash;
82
83         struct ccache_container *ccache;
84         struct gssapi_creds_container *client_gss_creds;
85         struct keytab_container *keytab;
86         struct gssapi_creds_container *server_gss_creds;
87
88         const char *(*workstation_cb) (struct cli_credentials *);
89         const char *(*password_cb) (struct cli_credentials *);
90         const char *(*username_cb) (struct cli_credentials *);
91         const char *(*domain_cb) (struct cli_credentials *);
92         const char *(*realm_cb) (struct cli_credentials *);
93         const char *(*principal_cb) (struct cli_credentials *);
94
95         /* Private handle for the callback routines to use */
96         void *priv_data;
97
98         struct creds_CredentialState *netlogon_creds;
99         enum netr_SchannelType secure_channel_type;
100         int kvno;
101
102         struct smb_krb5_context *smb_krb5_context;
103
104         /* We are flagged to get machine account details from the
105          * secrets.ldb when we are asked for a username or password */
106
107         BOOL machine_account_pending;
108         
109         /* Is this a machine account? */
110         BOOL machine_account;
111
112         /* Should we be trying to use kerberos? */
113         enum credentials_use_kerberos use_kerberos;
114
115         /* gensec features which should be used for connections */
116         uint32_t gensec_features;
117
118         /* Number of retries left before bailing out */
119         int tries;
120
121         /* Whether any callback is currently running */
122         BOOL callback_running;
123
124         /* an event context for anyone wanting to use the credentials */
125         struct event_context *ev;
126 };
127
128 struct ldb_context;
129 #include "auth/credentials/credentials_proto.h"
130
131 #endif /* __CREDENTIALS_H__ */