7b03e41c1956101d6bfa0a06e5f0b50f303dee87
[ira/wip.git] / source3 / lib / netapi / netapi.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  NetApi Support
4  *  Copyright (C) Guenther Deschner 2007-2008
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef __LIB_NETAPI_H__
21 #define __LIB_NETAPI_H__
22
23 /****************************************************************
24  NET_API_STATUS
25 ****************************************************************/
26 typedef enum {
27         NET_API_STATUS_SUCCESS = 0
28 } NET_API_STATUS;
29
30 #define ERROR_MORE_DATA ( 234L )
31
32 /****************************************************************
33 ****************************************************************/
34
35 #ifndef _HEADER_misc
36
37 struct GUID {
38         uint32_t time_low;
39         uint16_t time_mid;
40         uint16_t time_hi_and_version;
41         uint8_t clock_seq[2];
42         uint8_t node[6];
43 };
44
45 #endif /* _HEADER_misc */
46
47 #ifndef _HEADER_libnetapi
48
49 struct DOMAIN_CONTROLLER_INFO {
50         const char * domain_controller_name;
51         const char * domain_controller_address;
52         uint32_t domain_controller_address_type;
53         struct GUID domain_guid;
54         const char * domain_name;
55         const char * dns_forest_name;
56         uint32_t flags;
57         const char * dc_site_name;
58         const char * client_site_name;
59 };
60
61 struct SERVER_INFO_1005 {
62         const char * sv1005_comment;
63 };
64
65 struct USER_INFO_0 {
66         const char * usri0_name;
67 };
68
69 struct USER_INFO_1 {
70         const char * usri1_name;
71         const char * usri1_password;
72         uint32_t usri1_password_age;
73         uint32_t usri1_priv;
74         const char * usri1_home_dir;
75         const char * usri1_comment;
76         uint32_t usri1_flags;
77         const char * usri1_script_path;
78 };
79
80 #endif /* _HEADER_libnetapi */
81
82 /****************************************************************
83 ****************************************************************/
84
85 struct libnetapi_ctx {
86         char *debuglevel;
87         char *error_string;
88         char *username;
89         char *workgroup;
90         char *password;
91         char *krb5_cc_env;
92 };
93
94 /****************************************************************
95 ****************************************************************/
96
97 NET_API_STATUS libnetapi_init(struct libnetapi_ctx **ctx);
98
99 /****************************************************************
100 ****************************************************************/
101
102 NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx);
103
104 /****************************************************************
105 ****************************************************************/
106
107 NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx);
108
109 /****************************************************************
110 ****************************************************************/
111
112 NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx,
113                                         const char *debuglevel);
114
115 /****************************************************************
116 ****************************************************************/
117
118 NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
119                                       const char *username);
120
121 /****************************************************************
122 ****************************************************************/
123
124 NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx,
125                                       const char *password);
126
127 /****************************************************************
128 ****************************************************************/
129
130 NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
131                                        const char *workgroup);
132
133 /****************************************************************
134 ****************************************************************/
135
136 const char *libnetapi_errstr(NET_API_STATUS status);
137
138 /****************************************************************
139 ****************************************************************/
140
141 const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
142                                        NET_API_STATUS status);
143
144
145 /****************************************************************
146  NetApiBufferFree
147 ****************************************************************/
148
149 NET_API_STATUS NetApiBufferFree(void *buffer);
150
151 /****************************************************************
152  NetJoinDomain
153 ****************************************************************/
154
155 NET_API_STATUS NetJoinDomain(const char * server /* [in] */,
156                              const char * domain /* [in] [ref] */,
157                              const char * account_ou /* [in] */,
158                              const char * account /* [in] */,
159                              const char * password /* [in] */,
160                              uint32_t join_flags /* [in] */);
161
162 /****************************************************************
163  NetUnjoinDomain
164 ****************************************************************/
165
166 NET_API_STATUS NetUnjoinDomain(const char * server_name /* [in] */,
167                                const char * account /* [in] */,
168                                const char * password /* [in] */,
169                                uint32_t unjoin_flags /* [in] */);
170
171 /****************************************************************
172  NetGetJoinInformation
173 ****************************************************************/
174
175 NET_API_STATUS NetGetJoinInformation(const char * server_name /* [in] */,
176                                      const char * *name_buffer /* [out] [ref] */,
177                                      uint16_t *name_type /* [out] [ref] */);
178
179 /****************************************************************
180  NetGetJoinableOUs
181 ****************************************************************/
182
183 NET_API_STATUS NetGetJoinableOUs(const char * server_name /* [in] */,
184                                  const char * domain /* [in] [ref] */,
185                                  const char * account /* [in] */,
186                                  const char * password /* [in] */,
187                                  uint32_t *ou_count /* [out] [ref] */,
188                                  const char * **ous /* [out] [ref] */);
189
190 /****************************************************************
191  NetServerGetInfo
192 ****************************************************************/
193
194 NET_API_STATUS NetServerGetInfo(const char * server_name /* [in] */,
195                                 uint32_t level /* [in] */,
196                                 uint8_t **buffer /* [out] [ref] */);
197
198 /****************************************************************
199  NetServerSetInfo
200 ****************************************************************/
201
202 NET_API_STATUS NetServerSetInfo(const char * server_name /* [in] */,
203                                 uint32_t level /* [in] */,
204                                 uint8_t *buffer /* [in] [ref] */,
205                                 uint32_t *parm_error /* [out] [ref] */);
206
207 /****************************************************************
208  NetGetDCName
209 ****************************************************************/
210
211 NET_API_STATUS NetGetDCName(const char * server_name /* [in] */,
212                             const char * domain_name /* [in] */,
213                             uint8_t **buffer /* [out] [ref] */);
214
215 /****************************************************************
216  NetGetAnyDCName
217 ****************************************************************/
218
219 NET_API_STATUS NetGetAnyDCName(const char * server_name /* [in] */,
220                                const char * domain_name /* [in] */,
221                                uint8_t **buffer /* [out] [ref] */);
222
223
224 /****************************************************************
225  DsGetDcName
226 ****************************************************************/
227
228 NET_API_STATUS DsGetDcName(const char * server_name /* [in] [unique] */,
229                            const char * domain_name /* [in] [ref] */,
230                            struct GUID *domain_guid /* [in] [unique] */,
231                            const char * site_name /* [in] [unique] */,
232                            uint32_t flags /* [in] */,
233                            struct DOMAIN_CONTROLLER_INFO **dc_info /* [out] [ref] */);
234
235 /****************************************************************
236  NetUserAdd
237 ****************************************************************/
238
239 NET_API_STATUS NetUserAdd(const char * server_name /* [in] */,
240                           uint32_t level /* [in] */,
241                           uint8_t *buffer /* [in] [ref] */,
242                           uint32_t *parm_error /* [out] [ref] */);
243
244 /****************************************************************
245  NetUserDel
246 ****************************************************************/
247
248 NET_API_STATUS NetUserDel(const char * server_name /* [in] */,
249                           const char * user_name /* [in] */);
250
251 /****************************************************************
252  NetUserEnum
253 ****************************************************************/
254
255 NET_API_STATUS NetUserEnum(const char * server_name /* [in] */,
256                            uint32_t level /* [in] */,
257                            uint32_t filter /* [in] */,
258                            uint8_t **buffer /* [out] [ref] */,
259                            uint32_t prefmaxlen /* [in] */,
260                            uint32_t *entries_read /* [out] [ref] */,
261                            uint32_t *total_entries /* [out] [ref] */,
262                            uint32_t *resume_handle /* [in,out] [ref] */);
263
264 #endif