libnetapi: Add initial inline doxygen comments.
[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 struct NET_DISPLAY_USER {
81         const char * usri1_name;
82         const char * usri1_comment;
83         uint32_t usri1_flags;
84         const char * usri1_full_name;
85         uint32_t usri1_user_id;
86         uint32_t usri1_next_index;
87 };
88
89 struct NET_DISPLAY_MACHINE {
90         const char * usri2_name;
91         const char * usri2_comment;
92         uint32_t usri2_flags;
93         uint32_t usri2_user_id;
94         uint32_t usri2_next_index;
95 };
96
97 struct NET_DISPLAY_GROUP {
98         const char * grpi3_name;
99         const char * grpi3_comment;
100         uint32_t grpi3_group_id;
101         uint32_t grpi3_attributes;
102         uint32_t grpi3_next_index;
103 };
104
105 #endif /* _HEADER_libnetapi */
106
107 /****************************************************************
108 ****************************************************************/
109
110 struct libnetapi_ctx {
111         char *debuglevel;
112         char *error_string;
113         char *username;
114         char *workgroup;
115         char *password;
116         char *krb5_cc_env;
117         int use_kerberos;
118 };
119
120 /****************************************************************
121 ****************************************************************/
122
123 NET_API_STATUS libnetapi_init(struct libnetapi_ctx **ctx);
124
125 /****************************************************************
126 ****************************************************************/
127
128 NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx);
129
130 /****************************************************************
131 ****************************************************************/
132
133 NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx);
134
135 /****************************************************************
136 ****************************************************************/
137
138 NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx,
139                                         const char *debuglevel);
140
141 /****************************************************************
142 ****************************************************************/
143
144 NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
145                                       const char *username);
146
147 /****************************************************************
148 ****************************************************************/
149
150 NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx,
151                                       const char *password);
152
153 /****************************************************************
154 ****************************************************************/
155
156 NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
157                                        const char *workgroup);
158
159 /****************************************************************
160 ****************************************************************/
161
162 NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx);
163
164 /****************************************************************
165 ****************************************************************/
166
167 const char *libnetapi_errstr(NET_API_STATUS status);
168
169 /****************************************************************
170 ****************************************************************/
171
172 const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
173                                        NET_API_STATUS status);
174
175
176 /****************************************************************
177  NetApiBufferFree
178 ****************************************************************/
179
180 NET_API_STATUS NetApiBufferFree(void *buffer);
181
182 /************************************************************//**
183  *
184  * NetJoinDomain
185  *
186  * @brief Join a computer to a domain or workgroup
187  *
188  * @param[in] server The server name to connect to
189  * @param[in] domain The domain or workgroup to join
190  * @param[in] account_ou The organizational Unit to create the computer account
191  * in (AD only)
192  * @param[in] account The domain account used for joining a domain
193  * @param[in] password The domain account's password used for joining a domain
194  * @param[in] join_flags Bitmask field to define specific join features
195  * @return NET_API_STATUS
196  *
197  * example netdomjoin/netdomjoin.c
198  ***************************************************************/
199
200 NET_API_STATUS NetJoinDomain(const char * server /* [in] */,
201                              const char * domain /* [in] [ref] */,
202                              const char * account_ou /* [in] */,
203                              const char * account /* [in] */,
204                              const char * password /* [in] */,
205                              uint32_t join_flags /* [in] */);
206
207 /************************************************************//**
208  *
209  * NetUnjoinDomain
210  *
211  * @brief Unjoin a computer from a domain or workgroup
212  *
213  * @param[in] server_name The server name to connect to
214  * @param[in] account The domain account used for unjoining a domain
215  * @param[in] password The domain account's password used for unjoining a domain
216  * @param[in] unjoin_flags Bitmask field to define specific unjoin features
217  * @return NET_API_STATUS
218  *
219  ***************************************************************/
220
221 NET_API_STATUS NetUnjoinDomain(const char * server_name /* [in] */,
222                                const char * account /* [in] */,
223                                const char * password /* [in] */,
224                                uint32_t unjoin_flags /* [in] */);
225
226 /************************************************************//**
227  *
228  * NetGetJoinInformation
229  *
230  * @brief Unjoin a computer from a domain or workgroup
231  *
232  * @param[in] server_name The server name to connect to
233  * @param[out] name_buffer Returns the name of the workgroup or domain
234  * @param[out] name_type  Returns the type of that name
235  * @return NET_API_STATUS
236  *
237  * example netdomjoin-gui/netdomjoin-gui.c
238  *
239  ***************************************************************/
240
241 NET_API_STATUS NetGetJoinInformation(const char * server_name /* [in] */,
242                                      const char * *name_buffer /* [out] [ref] */,
243                                      uint16_t *name_type /* [out] [ref] */);
244
245 /************************************************************//**
246  *
247  * NetGetJoinableOUs
248  *
249  * @brief Query for the list of joinable organizational Units that can be used
250  * for joining AD
251  *
252  * @param[in] server_name The server name to connect to
253  * @param[in] domain The AD domain to query
254  * @param[in] account The domain account used for the query
255  * @param[in] password The domain account's password used for the query
256  * @param[out] ou_count The number of ous returned
257  * @param[out] ous Returned string array containing the ous
258  * @return NET_API_STATUS
259  *
260  * example netdomjoin-gui/netdomjoin-gui.c
261  *
262  ***************************************************************/
263
264 NET_API_STATUS NetGetJoinableOUs(const char * server_name /* [in] */,
265                                  const char * domain /* [in] [ref] */,
266                                  const char * account /* [in] */,
267                                  const char * password /* [in] */,
268                                  uint32_t *ou_count /* [out] [ref] */,
269                                  const char * **ous /* [out] [ref] */);
270
271 /************************************************************//**
272  *
273  * NetServerGetInfo
274  *
275  * @brief Get Information on a server
276  *
277  * @param[in] server_name The server name to connect to
278  * @param[in] level The level to define which information is requested
279  * @param[out] buffer The returned buffer carrying the SERVER_INFO structure
280  * @return NET_API_STATUS
281  *
282  ***************************************************************/
283
284 NET_API_STATUS NetServerGetInfo(const char * server_name /* [in] */,
285                                 uint32_t level /* [in] */,
286                                 uint8_t **buffer /* [out] [ref] */);
287
288 /************************************************************//**
289  *
290  * NetServerSetInfo
291  *
292  * @brief Get Information on a server
293  *
294  * @param[in] server_name The server name to connect to
295  * @param[in] level The level to define which information is set
296  * @param[in] buffer The buffer carrying the SERVER_INFO structure
297  * @param[out] parm_error On failure returns the invalid SERVER_INFO member
298  * @return NET_API_STATUS
299  *
300  ***************************************************************/
301
302 NET_API_STATUS NetServerSetInfo(const char * server_name /* [in] */,
303                                 uint32_t level /* [in] */,
304                                 uint8_t *buffer /* [in] [ref] */,
305                                 uint32_t *parm_error /* [out] [ref] */);
306
307 /************************************************************//**
308  *
309  * NetGetDCName
310  *
311  * @brief Query for the PDC for a given domain
312  *
313  * @param[in] server_name The server name to connect to
314  * @param[in] domain_name The name of the domain to lookup
315  * @param[out] buffer The name of the domain to lookup
316  * @return NET_API_STATUS
317  *
318  * example getdc/getdc.c
319  ***************************************************************/
320
321 NET_API_STATUS NetGetDCName(const char * server_name /* [in] */,
322                             const char * domain_name /* [in] */,
323                             uint8_t **buffer /* [out] [ref] */);
324
325 /************************************************************//**
326  *
327  * NetGetAnyDCName
328  *
329  * @brief Query for any DC for a given domain
330  *
331  * @param[in] server_name The server name to connect to
332  * @param[in] domain_name The name of the domain to lookup
333  * @param[out] buffer The name of the domain to lookup
334  * @return NET_API_STATUS
335  *
336  * example getdc/getdc.c
337  ***************************************************************/
338
339 NET_API_STATUS NetGetAnyDCName(const char * server_name /* [in] */,
340                                const char * domain_name /* [in] */,
341                                uint8_t **buffer /* [out] [ref] */);
342
343
344 /************************************************************//**
345  *
346  * DsGetDcName
347  *
348  * @brief Lookup a DC for a given domain and return information structure
349  *
350  * @param[in] server_name The server name to connect to
351  * @param[in] domain_name The name of the domain to lookup (cannot be NULL)
352  * @param[in] domain_guid The GUID of the domain to lookup (optional)
353  * @param[in] site_name The name of the site the DC should reside in
354  * @param[in] flags A bitmask to request specific features supported by the DC
355  * @param[out] dc_info Pointer to a DOMAIN_CONTROLLER_INFO structure
356  * @return NET_API_STATUS
357  *
358  * example dsgetdc/dsgetdc.c
359  ***************************************************************/
360
361 NET_API_STATUS DsGetDcName(const char * server_name /* [in] [unique] */,
362                            const char * domain_name /* [in] [ref] */,
363                            struct GUID *domain_guid /* [in] [unique] */,
364                            const char * site_name /* [in] [unique] */,
365                            uint32_t flags /* [in] */,
366                            struct DOMAIN_CONTROLLER_INFO **dc_info /* [out] [ref] */);
367
368 /************************************************************//**
369  *
370  * NetUserAdd
371  *
372  * @brief Create a user on a given server
373  *
374  * @param[in] server_name The server name to connect to
375  * @param[in] level The level of the USER_INFO structure passed in (Currently
376  * only level 1 is supported)
377  * @param[in] buffer The buffer carrying the USER_INFO structure
378  * @param[out] parm_error In case of error returns the failing member of the
379  * structure
380  * @return NET_API_STATUS
381  *
382  * example user/user_add.c
383  ***************************************************************/
384
385 NET_API_STATUS NetUserAdd(const char * server_name /* [in] */,
386                           uint32_t level /* [in] */,
387                           uint8_t *buffer /* [in] [ref] */,
388                           uint32_t *parm_error /* [out] [ref] */);
389
390 /************************************************************//**
391  *
392  * NetUserDel
393  *
394  * @brief Delete a user on a given server
395  *
396  * @param[in] server_name The server name to connect to
397  * @param[in] user_name The user account to delete
398  * @return NET_API_STATUS
399  *
400  * example user/user_del.c
401  ***************************************************************/
402
403 NET_API_STATUS NetUserDel(const char * server_name /* [in] */,
404                           const char * user_name /* [in] */);
405
406 /************************************************************//**
407  *
408  * NetUserEnum
409  *
410  * @brief Enumerate accounts on a server
411  *
412  * @param[in] server_name The server name to connect to
413  * @param[in] level The enumeration level used for the query (Currently only
414  * level 0 is supported)
415  * @param[in] filter The account flags filter used for the query
416  * @param[out] buffer The returned enumeration buffer
417  * @param[in] prefmaxlen The requested maximal buffer size
418  * @param[out] entries_read The number of returned entries
419  * @param[out] total_entries The number of total entries
420  * @param[in,out] resume_handle A handle passed in and returned for resuming
421  * operations
422  * @return NET_API_STATUS
423  *
424  * example user/user_enum.c
425  ***************************************************************/
426
427 NET_API_STATUS NetUserEnum(const char * server_name /* [in] */,
428                            uint32_t level /* [in] */,
429                            uint32_t filter /* [in] */,
430                            uint8_t **buffer /* [out] [ref] */,
431                            uint32_t prefmaxlen /* [in] */,
432                            uint32_t *entries_read /* [out] [ref] */,
433                            uint32_t *total_entries /* [out] [ref] */,
434                            uint32_t *resume_handle /* [in,out] [ref] */);
435
436 /************************************************************//**
437  *
438  * NetQueryDisplayInformation
439  *
440  * @brief Enumerate accounts on a server
441  *
442  * @param[in] server_name The server name to connect to
443  * @param[in] level The enumeration level used for the query
444  * @param[in] idx The index to start the the display enumeration at
445  * @param[in] entries_requested The number of entries requested
446  * @param[in] prefmaxlen The requested maximal buffer size
447  * @param[out] entries_read The number of returned entries
448  * @param[out] buffer The returned display information buffer
449  * @return NET_API_STATUS
450  *
451  * example user/user_dispinfo.c
452  ***************************************************************/
453
454 NET_API_STATUS NetQueryDisplayInformation(const char * server_name /* [in] [unique] */,
455                                           uint32_t level /* [in] */,
456                                           uint32_t idx /* [in] */,
457                                           uint32_t entries_requested /* [in] */,
458                                           uint32_t prefmaxlen /* [in] */,
459                                           uint32_t *entries_read /* [out] [ref] */,
460                                           void **buffer /* [out] [noprint,ref] */);
461
462 #endif