netapi: Add NetGroupDel/NetGroupAdd header.
[jra/samba/.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 #ifndef MAXSUBAUTHS
50 #define MAXSUBAUTHS 15 /* max sub authorities in a SID */
51 #endif
52
53 struct domsid {
54         uint8_t   sid_rev_num;
55         uint8_t   num_auths;
56         uint8_t   id_auth[6];
57         uint32_t  sub_auths[MAXSUBAUTHS];
58 };
59
60 struct DOMAIN_CONTROLLER_INFO {
61         const char * domain_controller_name;
62         const char * domain_controller_address;
63         uint32_t domain_controller_address_type;
64         struct GUID domain_guid;
65         const char * domain_name;
66         const char * dns_forest_name;
67         uint32_t flags;
68         const char * dc_site_name;
69         const char * client_site_name;
70 };
71
72 struct SERVER_INFO_1005 {
73         const char * sv1005_comment;
74 };
75
76 struct USER_INFO_0 {
77         const char * usri0_name;
78 };
79
80 struct USER_INFO_1 {
81         const char * usri1_name;
82         const char * usri1_password;
83         uint32_t usri1_password_age;
84         uint32_t usri1_priv;
85         const char * usri1_home_dir;
86         const char * usri1_comment;
87         uint32_t usri1_flags;
88         const char * usri1_script_path;
89 };
90
91 struct NET_DISPLAY_USER {
92         const char * usri1_name;
93         const char * usri1_comment;
94         uint32_t usri1_flags;
95         const char * usri1_full_name;
96         uint32_t usri1_user_id;
97         uint32_t usri1_next_index;
98 };
99
100 struct NET_DISPLAY_MACHINE {
101         const char * usri2_name;
102         const char * usri2_comment;
103         uint32_t usri2_flags;
104         uint32_t usri2_user_id;
105         uint32_t usri2_next_index;
106 };
107
108 struct NET_DISPLAY_GROUP {
109         const char * grpi3_name;
110         const char * grpi3_comment;
111         uint32_t grpi3_group_id;
112         uint32_t grpi3_attributes;
113         uint32_t grpi3_next_index;
114 };
115
116 struct GROUP_INFO_0 {
117         const char * grpi0_name;
118 };
119
120 struct GROUP_INFO_1 {
121         const char * grpi1_name;
122         const char * grpi1_comment;
123 };
124
125 struct GROUP_INFO_2 {
126         const char * grpi2_name;
127         const char * grpi2_comment;
128         uint32_t grpi2_group_id;
129         uint32_t grpi2_attributes;
130 };
131
132 struct GROUP_INFO_3 {
133         const char * grpi3_name;
134         const char * grpi3_comment;
135         struct domsid grpi3_group_sid;
136         uint32_t grpi3_attributes;
137 };
138
139 #endif /* _HEADER_libnetapi */
140
141 /****************************************************************
142 ****************************************************************/
143
144 struct libnetapi_ctx {
145         char *debuglevel;
146         char *error_string;
147         char *username;
148         char *workgroup;
149         char *password;
150         char *krb5_cc_env;
151         int use_kerberos;
152 };
153
154 /****************************************************************
155 ****************************************************************/
156
157 NET_API_STATUS libnetapi_init(struct libnetapi_ctx **ctx);
158
159 /****************************************************************
160 ****************************************************************/
161
162 NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx);
163
164 /****************************************************************
165 ****************************************************************/
166
167 NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx);
168
169 /****************************************************************
170 ****************************************************************/
171
172 NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx,
173                                         const char *debuglevel);
174
175 /****************************************************************
176 ****************************************************************/
177
178 NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
179                                       const char *username);
180
181 /****************************************************************
182 ****************************************************************/
183
184 NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx,
185                                       const char *password);
186
187 /****************************************************************
188 ****************************************************************/
189
190 NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
191                                        const char *workgroup);
192
193 /****************************************************************
194 ****************************************************************/
195
196 NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx);
197
198 /****************************************************************
199 ****************************************************************/
200
201 const char *libnetapi_errstr(NET_API_STATUS status);
202
203 /****************************************************************
204 ****************************************************************/
205
206 const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
207                                        NET_API_STATUS status);
208
209
210 /****************************************************************
211  NetApiBufferFree
212 ****************************************************************/
213
214 NET_API_STATUS NetApiBufferFree(void *buffer);
215
216 /************************************************************//**
217  *
218  * NetJoinDomain
219  *
220  * @brief Join a computer to a domain or workgroup
221  *
222  * @param[in] server The server name to connect to
223  * @param[in] domain The domain or workgroup to join
224  * @param[in] account_ou The organizational Unit to create the computer account
225  * in (AD only)
226  * @param[in] account The domain account used for joining a domain
227  * @param[in] password The domain account's password used for joining a domain
228  * @param[in] join_flags Bitmask field to define specific join features
229  * @return NET_API_STATUS
230  *
231  * example netdomjoin/netdomjoin.c
232  ***************************************************************/
233
234 NET_API_STATUS NetJoinDomain(const char * server /* [in] */,
235                              const char * domain /* [in] [ref] */,
236                              const char * account_ou /* [in] */,
237                              const char * account /* [in] */,
238                              const char * password /* [in] */,
239                              uint32_t join_flags /* [in] */);
240
241 /************************************************************//**
242  *
243  * NetUnjoinDomain
244  *
245  * @brief Unjoin a computer from a domain or workgroup
246  *
247  * @param[in] server_name The server name to connect to
248  * @param[in] account The domain account used for unjoining a domain
249  * @param[in] password The domain account's password used for unjoining a domain
250  * @param[in] unjoin_flags Bitmask field to define specific unjoin features
251  * @return NET_API_STATUS
252  *
253  ***************************************************************/
254
255 NET_API_STATUS NetUnjoinDomain(const char * server_name /* [in] */,
256                                const char * account /* [in] */,
257                                const char * password /* [in] */,
258                                uint32_t unjoin_flags /* [in] */);
259
260 /************************************************************//**
261  *
262  * NetGetJoinInformation
263  *
264  * @brief Unjoin a computer from a domain or workgroup
265  *
266  * @param[in] server_name The server name to connect to
267  * @param[out] name_buffer Returns the name of the workgroup or domain
268  * @param[out] name_type  Returns the type of that name
269  * @return NET_API_STATUS
270  *
271  * example netdomjoin-gui/netdomjoin-gui.c
272  *
273  ***************************************************************/
274
275 NET_API_STATUS NetGetJoinInformation(const char * server_name /* [in] */,
276                                      const char * *name_buffer /* [out] [ref] */,
277                                      uint16_t *name_type /* [out] [ref] */);
278
279 /************************************************************//**
280  *
281  * NetGetJoinableOUs
282  *
283  * @brief Query for the list of joinable organizational Units that can be used
284  * for joining AD
285  *
286  * @param[in] server_name The server name to connect to
287  * @param[in] domain The AD domain to query
288  * @param[in] account The domain account used for the query
289  * @param[in] password The domain account's password used for the query
290  * @param[out] ou_count The number of ous returned
291  * @param[out] ous Returned string array containing the ous
292  * @return NET_API_STATUS
293  *
294  * example netdomjoin-gui/netdomjoin-gui.c
295  *
296  ***************************************************************/
297
298 NET_API_STATUS NetGetJoinableOUs(const char * server_name /* [in] */,
299                                  const char * domain /* [in] [ref] */,
300                                  const char * account /* [in] */,
301                                  const char * password /* [in] */,
302                                  uint32_t *ou_count /* [out] [ref] */,
303                                  const char * **ous /* [out] [ref] */);
304
305 /************************************************************//**
306  *
307  * NetServerGetInfo
308  *
309  * @brief Get Information on a server
310  *
311  * @param[in] server_name The server name to connect to
312  * @param[in] level The level to define which information is requested
313  * @param[out] buffer The returned buffer carrying the SERVER_INFO structure
314  * @return NET_API_STATUS
315  *
316  ***************************************************************/
317
318 NET_API_STATUS NetServerGetInfo(const char * server_name /* [in] */,
319                                 uint32_t level /* [in] */,
320                                 uint8_t **buffer /* [out] [ref] */);
321
322 /************************************************************//**
323  *
324  * NetServerSetInfo
325  *
326  * @brief Get Information on a server
327  *
328  * @param[in] server_name The server name to connect to
329  * @param[in] level The level to define which information is set
330  * @param[in] buffer The buffer carrying the SERVER_INFO structure
331  * @param[out] parm_error On failure returns the invalid SERVER_INFO member
332  * @return NET_API_STATUS
333  *
334  ***************************************************************/
335
336 NET_API_STATUS NetServerSetInfo(const char * server_name /* [in] */,
337                                 uint32_t level /* [in] */,
338                                 uint8_t *buffer /* [in] [ref] */,
339                                 uint32_t *parm_error /* [out] [ref] */);
340
341 /************************************************************//**
342  *
343  * NetGetDCName
344  *
345  * @brief Query for the PDC for a given domain
346  *
347  * @param[in] server_name The server name to connect to
348  * @param[in] domain_name The name of the domain to lookup
349  * @param[out] buffer The name of the domain to lookup
350  * @return NET_API_STATUS
351  *
352  * example getdc/getdc.c
353  ***************************************************************/
354
355 NET_API_STATUS NetGetDCName(const char * server_name /* [in] */,
356                             const char * domain_name /* [in] */,
357                             uint8_t **buffer /* [out] [ref] */);
358
359 /************************************************************//**
360  *
361  * NetGetAnyDCName
362  *
363  * @brief Query for any DC for a given domain
364  *
365  * @param[in] server_name The server name to connect to
366  * @param[in] domain_name The name of the domain to lookup
367  * @param[out] buffer The name of the domain to lookup
368  * @return NET_API_STATUS
369  *
370  * example getdc/getdc.c
371  ***************************************************************/
372
373 NET_API_STATUS NetGetAnyDCName(const char * server_name /* [in] */,
374                                const char * domain_name /* [in] */,
375                                uint8_t **buffer /* [out] [ref] */);
376
377
378 /************************************************************//**
379  *
380  * DsGetDcName
381  *
382  * @brief Lookup a DC for a given domain and return information structure
383  *
384  * @param[in] server_name The server name to connect to
385  * @param[in] domain_name The name of the domain to lookup (cannot be NULL)
386  * @param[in] domain_guid The GUID of the domain to lookup (optional)
387  * @param[in] site_name The name of the site the DC should reside in
388  * @param[in] flags A bitmask to request specific features supported by the DC
389  * @param[out] dc_info Pointer to a DOMAIN_CONTROLLER_INFO structure
390  * @return NET_API_STATUS
391  *
392  * example dsgetdc/dsgetdc.c
393  ***************************************************************/
394
395 NET_API_STATUS DsGetDcName(const char * server_name /* [in] [unique] */,
396                            const char * domain_name /* [in] [ref] */,
397                            struct GUID *domain_guid /* [in] [unique] */,
398                            const char * site_name /* [in] [unique] */,
399                            uint32_t flags /* [in] */,
400                            struct DOMAIN_CONTROLLER_INFO **dc_info /* [out] [ref] */);
401
402 /************************************************************//**
403  *
404  * NetUserAdd
405  *
406  * @brief Create a user on a given server
407  *
408  * @param[in] server_name The server name to connect to
409  * @param[in] level The level of the USER_INFO structure passed in (Currently
410  * only level 1 is supported)
411  * @param[in] buffer The buffer carrying the USER_INFO structure
412  * @param[out] parm_error In case of error returns the failing member of the
413  * structure
414  * @return NET_API_STATUS
415  *
416  * example user/user_add.c
417  ***************************************************************/
418
419 NET_API_STATUS NetUserAdd(const char * server_name /* [in] */,
420                           uint32_t level /* [in] */,
421                           uint8_t *buffer /* [in] [ref] */,
422                           uint32_t *parm_error /* [out] [ref] */);
423
424 /************************************************************//**
425  *
426  * NetUserDel
427  *
428  * @brief Delete a user on a given server
429  *
430  * @param[in] server_name The server name to connect to
431  * @param[in] user_name The user account to delete
432  * @return NET_API_STATUS
433  *
434  * example user/user_del.c
435  ***************************************************************/
436
437 NET_API_STATUS NetUserDel(const char * server_name /* [in] */,
438                           const char * user_name /* [in] */);
439
440 /************************************************************//**
441  *
442  * NetUserEnum
443  *
444  * @brief Enumerate accounts on a server
445  *
446  * @param[in] server_name The server name to connect to
447  * @param[in] level The enumeration level used for the query (Currently only
448  * level 0 is supported)
449  * @param[in] filter The account flags filter used for the query
450  * @param[out] buffer The returned enumeration buffer
451  * @param[in] prefmaxlen The requested maximal buffer size
452  * @param[out] entries_read The number of returned entries
453  * @param[out] total_entries The number of total entries
454  * @param[in,out] resume_handle A handle passed in and returned for resuming
455  * operations
456  * @return NET_API_STATUS
457  *
458  * example user/user_enum.c
459  ***************************************************************/
460
461 NET_API_STATUS NetUserEnum(const char * server_name /* [in] */,
462                            uint32_t level /* [in] */,
463                            uint32_t filter /* [in] */,
464                            uint8_t **buffer /* [out] [ref] */,
465                            uint32_t prefmaxlen /* [in] */,
466                            uint32_t *entries_read /* [out] [ref] */,
467                            uint32_t *total_entries /* [out] [ref] */,
468                            uint32_t *resume_handle /* [in,out] [ref] */);
469
470 /************************************************************//**
471  *
472  * NetQueryDisplayInformation
473  *
474  * @brief Enumerate accounts on a server
475  *
476  * @param[in] server_name The server name to connect to
477  * @param[in] level The enumeration level used for the query
478  * @param[in] idx The index to start the the display enumeration at
479  * @param[in] entries_requested The number of entries requested
480  * @param[in] prefmaxlen The requested maximal buffer size
481  * @param[out] entries_read The number of returned entries
482  * @param[out] buffer The returned display information buffer
483  * @return NET_API_STATUS
484  *
485  * example user/user_dispinfo.c
486  ***************************************************************/
487
488 NET_API_STATUS NetQueryDisplayInformation(const char * server_name /* [in] [unique] */,
489                                           uint32_t level /* [in] */,
490                                           uint32_t idx /* [in] */,
491                                           uint32_t entries_requested /* [in] */,
492                                           uint32_t prefmaxlen /* [in] */,
493                                           uint32_t *entries_read /* [out] [ref] */,
494                                           void **buffer /* [out] [noprint,ref] */);
495
496 /************************************************************//**
497  *
498  * NetGroupAdd
499  *
500  * @brief Create Domain Group
501  *
502  * @param[in] server_name The server name to connect to
503  * @param[in] level The level used for the new group creation
504  * @param[in] buf The buffer containing the group structure
505  * @param[out] parm_err The returned parameter error number if any
506  * @return NET_API_STATUS
507  *
508  * example group/group_add.c
509  ***************************************************************/
510
511 NET_API_STATUS NetGroupAdd(const char * server_name /* [in] */,
512                            uint32_t level /* [in] */,
513                            uint8_t *buf /* [in] [ref] */,
514                            uint32_t *parm_err /* [out] [ref] */);
515
516 /************************************************************//**
517  *
518  * NetGroupDel
519  *
520  * @brief Delete Domain Group
521  *
522  * @param[in] server_name The server name to connect to
523  * @param[in] group_name The name of the group that is going to be deleted
524  * @return NET_API_STATUS
525  *
526  * example group/group_del.c
527  ***************************************************************/
528
529
530 NET_API_STATUS NetGroupDel(const char * server_name /* [in] */,
531                            const char * group_name /* [in] */);
532
533 #endif