Fix const.
[ira/wip.git] / source4 / auth / credentials / credentials.i
1 /* 
2    Unix SMB/CIFS implementation.
3    Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
4    
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9    
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14    
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 %module(package="samba.credentials") credentials
20
21 %{
22
23 /* Include headers */
24 #include <stdint.h>
25 #include <stdbool.h>
26
27 #include "includes.h"
28 #include "auth/credentials/credentials.h"
29 #include "param/param.h"
30 #include "lib/cmdline/credentials.h"
31 typedef struct cli_credentials cli_credentials;
32 %}
33
34 %import "carrays.i"
35 %import "typemaps.i"
36 %import "param/param.i"
37
38 %typemap(default,noblock=1) struct cli_credentials * {
39     $1 = NULL;
40 }
41
42 %constant int AUTO_USE_KERBEROS = CRED_AUTO_USE_KERBEROS;
43 %constant int DONT_USE_KERBEROS = CRED_DONT_USE_KERBEROS;
44 %constant int MUST_USE_KERBEROS = CRED_MUST_USE_KERBEROS;
45
46 %{
47 #include "librpc/gen_ndr/samr.h" /* for struct samr_Password */
48 %}
49
50 %typemap(out,noblock=1) struct samr_Password * {
51     $result = PyString_FromStringAndSize((char *)$1->hash, 16);
52 }
53
54 %talloctype(cli_credentials);
55 %rename(Credentials) cli_credentials;
56 typedef struct cli_credentials {
57     %extend {
58         cli_credentials(void) {
59             return cli_credentials_init(NULL);
60         }
61         /* username */
62         const char *get_username(void);
63         bool set_username(const char *value, 
64                           enum credentials_obtained=CRED_SPECIFIED);
65
66         /* password */
67         const char *get_password(void);
68         bool set_password(const char *val, 
69                           enum credentials_obtained=CRED_SPECIFIED);
70
71         /* domain */
72         const char *get_domain(void);
73         bool set_domain(const char *val, 
74                         enum credentials_obtained=CRED_SPECIFIED);
75
76         /* realm */
77         const char *get_realm(void);
78         bool set_realm(const char *val, 
79                        enum credentials_obtained=CRED_SPECIFIED);
80
81         /* Kerberos */
82         void set_kerberos_state(enum credentials_use_kerberos use_kerberos);
83
84         void parse_string(const char *text,
85                           enum credentials_obtained=CRED_SPECIFIED);
86
87         /* bind dn */
88         const char *get_bind_dn(void);
89         bool set_bind_dn(const char *bind_dn);
90
91         void set_anonymous();
92
93         /* workstation name */
94         const char *get_workstation(void);
95         bool set_workstation(const char *workstation, 
96                              enum credentials_obtained obtained=CRED_SPECIFIED);
97
98         NTSTATUS set_machine_account(struct loadparm_context *lp_ctx);
99
100         void guess(struct loadparm_context *lp_ctx);
101         bool is_anonymous(void);
102
103         const struct samr_Password *get_nt_hash(TALLOC_CTX *mem_ctx);
104
105         bool authentication_requested(void);
106
107         bool wrong_password(void);
108
109         bool set_cmdline_callbacks();
110     }
111 } cli_credentials;
112
113 %{
114 struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj)
115 {
116     struct cli_credentials *ret;
117
118     if (py_obj == Py_None) {
119         return cli_credentials_init_anon(NULL);
120     }
121
122     if (SWIG_ConvertPtr(py_obj, (void *)&ret, SWIGTYPE_p_cli_credentials, 0 |  0 ) < 0) {
123         return NULL; 
124     }
125     return ret;
126 }
127
128 %}