Fix resume handle for _samr_EnumDomainGroups
[Samba.git] / source / lib / netapi / netapi.h
blobce97e4c02e8ecf25fb47b10727585e824ebec6f2
1 /*
2 * Unix SMB/CIFS implementation.
3 * NetApi Support
4 * Copyright (C) Guenther Deschner 2007-2008
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.
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.
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/>.
20 #ifndef __LIB_NETAPI_H__
21 #define __LIB_NETAPI_H__
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
27 /****************************************************************
28 NET_API_STATUS
29 ****************************************************************/
30 typedef enum {
31 NET_API_STATUS_SUCCESS = 0
32 } NET_API_STATUS;
34 #define ERROR_MORE_DATA ( 234L )
36 /****************************************************************
37 ****************************************************************/
39 #ifndef _HEADER_misc
41 struct GUID {
42 uint32_t time_low;
43 uint16_t time_mid;
44 uint16_t time_hi_and_version;
45 uint8_t clock_seq[2];
46 uint8_t node[6];
49 #endif /* _HEADER_misc */
51 #ifndef _HEADER_libnetapi
53 struct DOMAIN_CONTROLLER_INFO {
54 const char * domain_controller_name;
55 const char * domain_controller_address;
56 uint32_t domain_controller_address_type;
57 struct GUID domain_guid;
58 const char * domain_name;
59 const char * dns_forest_name;
60 uint32_t flags;
61 const char * dc_site_name;
62 const char * client_site_name;
65 struct SERVER_INFO_1005 {
66 const char * sv1005_comment;
69 struct USER_INFO_0 {
70 const char * usri0_name;
73 struct USER_INFO_1 {
74 const char * usri1_name;
75 const char * usri1_password;
76 uint32_t usri1_password_age;
77 uint32_t usri1_priv;
78 const char * usri1_home_dir;
79 const char * usri1_comment;
80 uint32_t usri1_flags;
81 const char * usri1_script_path;
84 struct NET_DISPLAY_USER {
85 const char * usri1_name;
86 const char * usri1_comment;
87 uint32_t usri1_flags;
88 const char * usri1_full_name;
89 uint32_t usri1_user_id;
90 uint32_t usri1_next_index;
93 struct NET_DISPLAY_MACHINE {
94 const char * usri2_name;
95 const char * usri2_comment;
96 uint32_t usri2_flags;
97 uint32_t usri2_user_id;
98 uint32_t usri2_next_index;
101 struct NET_DISPLAY_GROUP {
102 const char * grpi3_name;
103 const char * grpi3_comment;
104 uint32_t grpi3_group_id;
105 uint32_t grpi3_attributes;
106 uint32_t grpi3_next_index;
109 #endif /* _HEADER_libnetapi */
111 /****************************************************************
112 ****************************************************************/
114 struct libnetapi_ctx {
115 char *debuglevel;
116 char *error_string;
117 char *username;
118 char *workgroup;
119 char *password;
120 char *krb5_cc_env;
121 int use_kerberos;
124 /****************************************************************
125 ****************************************************************/
127 NET_API_STATUS libnetapi_init(struct libnetapi_ctx **ctx);
129 /****************************************************************
130 ****************************************************************/
132 NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx);
134 /****************************************************************
135 ****************************************************************/
137 NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx);
139 /****************************************************************
140 ****************************************************************/
142 NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx,
143 const char *debuglevel);
145 /****************************************************************
146 ****************************************************************/
148 NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
149 const char *username);
151 /****************************************************************
152 ****************************************************************/
154 NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx,
155 const char *password);
157 /****************************************************************
158 ****************************************************************/
160 NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
161 const char *workgroup);
163 /****************************************************************
164 ****************************************************************/
166 NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx);
168 /****************************************************************
169 ****************************************************************/
171 const char *libnetapi_errstr(NET_API_STATUS status);
173 /****************************************************************
174 ****************************************************************/
176 const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
177 NET_API_STATUS status);
180 /****************************************************************
181 NetApiBufferFree
182 ****************************************************************/
184 NET_API_STATUS NetApiBufferFree(void *buffer);
186 /************************************************************//**
188 * NetJoinDomain
190 * @brief Join a computer to a domain or workgroup
192 * @param[in] server The server name to connect to
193 * @param[in] domain The domain or workgroup to join
194 * @param[in] account_ou The organizational Unit to create the computer account
195 * in (AD only)
196 * @param[in] account The domain account used for joining a domain
197 * @param[in] password The domain account's password used for joining a domain
198 * @param[in] join_flags Bitmask field to define specific join features
199 * @return NET_API_STATUS
201 * example netdomjoin/netdomjoin.c
202 ***************************************************************/
204 NET_API_STATUS NetJoinDomain(const char * server /* [in] */,
205 const char * domain /* [in] [ref] */,
206 const char * account_ou /* [in] */,
207 const char * account /* [in] */,
208 const char * password /* [in] */,
209 uint32_t join_flags /* [in] */);
211 /************************************************************//**
213 * NetUnjoinDomain
215 * @brief Unjoin a computer from a domain or workgroup
217 * @param[in] server_name The server name to connect to
218 * @param[in] account The domain account used for unjoining a domain
219 * @param[in] password The domain account's password used for unjoining a domain
220 * @param[in] unjoin_flags Bitmask field to define specific unjoin features
221 * @return NET_API_STATUS
223 ***************************************************************/
225 NET_API_STATUS NetUnjoinDomain(const char * server_name /* [in] */,
226 const char * account /* [in] */,
227 const char * password /* [in] */,
228 uint32_t unjoin_flags /* [in] */);
230 /************************************************************//**
232 * NetGetJoinInformation
234 * @brief Unjoin a computer from a domain or workgroup
236 * @param[in] server_name The server name to connect to
237 * @param[out] name_buffer Returns the name of the workgroup or domain
238 * @param[out] name_type Returns the type of that name
239 * @return NET_API_STATUS
241 * example netdomjoin-gui/netdomjoin-gui.c
243 ***************************************************************/
245 NET_API_STATUS NetGetJoinInformation(const char * server_name /* [in] */,
246 const char * *name_buffer /* [out] [ref] */,
247 uint16_t *name_type /* [out] [ref] */);
249 /************************************************************//**
251 * NetGetJoinableOUs
253 * @brief Query for the list of joinable organizational Units that can be used
254 * for joining AD
256 * @param[in] server_name The server name to connect to
257 * @param[in] domain The AD domain to query
258 * @param[in] account The domain account used for the query
259 * @param[in] password The domain account's password used for the query
260 * @param[out] ou_count The number of ous returned
261 * @param[out] ous Returned string array containing the ous
262 * @return NET_API_STATUS
264 * example netdomjoin-gui/netdomjoin-gui.c
266 ***************************************************************/
268 NET_API_STATUS NetGetJoinableOUs(const char * server_name /* [in] */,
269 const char * domain /* [in] [ref] */,
270 const char * account /* [in] */,
271 const char * password /* [in] */,
272 uint32_t *ou_count /* [out] [ref] */,
273 const char * **ous /* [out] [ref] */);
275 /************************************************************//**
277 * NetServerGetInfo
279 * @brief Get Information on a server
281 * @param[in] server_name The server name to connect to
282 * @param[in] level The level to define which information is requested
283 * @param[out] buffer The returned buffer carrying the SERVER_INFO structure
284 * @return NET_API_STATUS
286 ***************************************************************/
288 NET_API_STATUS NetServerGetInfo(const char * server_name /* [in] */,
289 uint32_t level /* [in] */,
290 uint8_t **buffer /* [out] [ref] */);
292 /************************************************************//**
294 * NetServerSetInfo
296 * @brief Get Information on a server
298 * @param[in] server_name The server name to connect to
299 * @param[in] level The level to define which information is set
300 * @param[in] buffer The buffer carrying the SERVER_INFO structure
301 * @param[out] parm_error On failure returns the invalid SERVER_INFO member
302 * @return NET_API_STATUS
304 ***************************************************************/
306 NET_API_STATUS NetServerSetInfo(const char * server_name /* [in] */,
307 uint32_t level /* [in] */,
308 uint8_t *buffer /* [in] [ref] */,
309 uint32_t *parm_error /* [out] [ref] */);
311 /************************************************************//**
313 * NetGetDCName
315 * @brief Query for the PDC for a given domain
317 * @param[in] server_name The server name to connect to
318 * @param[in] domain_name The name of the domain to lookup
319 * @param[out] buffer The name of the domain to lookup
320 * @return NET_API_STATUS
322 * example getdc/getdc.c
323 ***************************************************************/
325 NET_API_STATUS NetGetDCName(const char * server_name /* [in] */,
326 const char * domain_name /* [in] */,
327 uint8_t **buffer /* [out] [ref] */);
329 /************************************************************//**
331 * NetGetAnyDCName
333 * @brief Query for any DC for a given domain
335 * @param[in] server_name The server name to connect to
336 * @param[in] domain_name The name of the domain to lookup
337 * @param[out] buffer The name of the domain to lookup
338 * @return NET_API_STATUS
340 * example getdc/getdc.c
341 ***************************************************************/
343 NET_API_STATUS NetGetAnyDCName(const char * server_name /* [in] */,
344 const char * domain_name /* [in] */,
345 uint8_t **buffer /* [out] [ref] */);
348 /************************************************************//**
350 * DsGetDcName
352 * @brief Lookup a DC for a given domain and return information structure
354 * @param[in] server_name The server name to connect to
355 * @param[in] domain_name The name of the domain to lookup (cannot be NULL)
356 * @param[in] domain_guid The GUID of the domain to lookup (optional)
357 * @param[in] site_name The name of the site the DC should reside in
358 * @param[in] flags A bitmask to request specific features supported by the DC
359 * @param[out] dc_info Pointer to a DOMAIN_CONTROLLER_INFO structure
360 * @return NET_API_STATUS
362 * example dsgetdc/dsgetdc.c
363 ***************************************************************/
365 NET_API_STATUS DsGetDcName(const char * server_name /* [in] [unique] */,
366 const char * domain_name /* [in] [ref] */,
367 struct GUID *domain_guid /* [in] [unique] */,
368 const char * site_name /* [in] [unique] */,
369 uint32_t flags /* [in] */,
370 struct DOMAIN_CONTROLLER_INFO **dc_info /* [out] [ref] */);
372 /************************************************************//**
374 * NetUserAdd
376 * @brief Create a user on a given server
378 * @param[in] server_name The server name to connect to
379 * @param[in] level The level of the USER_INFO structure passed in (Currently
380 * only level 1 is supported)
381 * @param[in] buffer The buffer carrying the USER_INFO structure
382 * @param[out] parm_error In case of error returns the failing member of the
383 * structure
384 * @return NET_API_STATUS
386 * example user/user_add.c
387 ***************************************************************/
389 NET_API_STATUS NetUserAdd(const char * server_name /* [in] */,
390 uint32_t level /* [in] */,
391 uint8_t *buffer /* [in] [ref] */,
392 uint32_t *parm_error /* [out] [ref] */);
394 /************************************************************//**
396 * NetUserDel
398 * @brief Delete a user on a given server
400 * @param[in] server_name The server name to connect to
401 * @param[in] user_name The user account to delete
402 * @return NET_API_STATUS
404 * example user/user_del.c
405 ***************************************************************/
407 NET_API_STATUS NetUserDel(const char * server_name /* [in] */,
408 const char * user_name /* [in] */);
410 /************************************************************//**
412 * NetUserEnum
414 * @brief Enumerate accounts on a server
416 * @param[in] server_name The server name to connect to
417 * @param[in] level The enumeration level used for the query (Currently only
418 * level 0 is supported)
419 * @param[in] filter The account flags filter used for the query
420 * @param[out] buffer The returned enumeration buffer
421 * @param[in] prefmaxlen The requested maximal buffer size
422 * @param[out] entries_read The number of returned entries
423 * @param[out] total_entries The number of total entries
424 * @param[in,out] resume_handle A handle passed in and returned for resuming
425 * operations
426 * @return NET_API_STATUS
428 * example user/user_enum.c
429 ***************************************************************/
431 NET_API_STATUS NetUserEnum(const char * server_name /* [in] */,
432 uint32_t level /* [in] */,
433 uint32_t filter /* [in] */,
434 uint8_t **buffer /* [out] [ref] */,
435 uint32_t prefmaxlen /* [in] */,
436 uint32_t *entries_read /* [out] [ref] */,
437 uint32_t *total_entries /* [out] [ref] */,
438 uint32_t *resume_handle /* [in,out] [ref] */);
440 /************************************************************//**
442 * NetQueryDisplayInformation
444 * @brief Enumerate accounts on a server
446 * @param[in] server_name The server name to connect to
447 * @param[in] level The enumeration level used for the query
448 * @param[in] idx The index to start the the display enumeration at
449 * @param[in] entries_requested The number of entries requested
450 * @param[in] prefmaxlen The requested maximal buffer size
451 * @param[out] entries_read The number of returned entries
452 * @param[out] buffer The returned display information buffer
453 * @return NET_API_STATUS
455 * example user/user_dispinfo.c
456 ***************************************************************/
458 NET_API_STATUS NetQueryDisplayInformation(const char * server_name /* [in] [unique] */,
459 uint32_t level /* [in] */,
460 uint32_t idx /* [in] */,
461 uint32_t entries_requested /* [in] */,
462 uint32_t prefmaxlen /* [in] */,
463 uint32_t *entries_read /* [out] [ref] */,
464 void **buffer /* [out] [noprint,ref] */);
466 #ifdef __cplusplus
468 #endif /* __cplusplus */
470 #endif /* __LIB_NETAPI_H__ */