2 * Unix SMB/CIFS implementation.
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 /****************************************************************
25 ****************************************************************/
27 NET_API_STATUS_SUCCESS = 0
30 #define ERROR_MORE_DATA ( 234L )
32 /****************************************************************
33 ****************************************************************/
40 uint16_t time_hi_and_version;
45 #endif /* _HEADER_misc */
47 #ifndef _HEADER_libnetapi
50 #define MAXSUBAUTHS 15 /* max sub authorities in a SID */
57 uint32_t sub_auths[MAXSUBAUTHS];
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;
68 const char * dc_site_name;
69 const char * client_site_name;
72 struct SERVER_INFO_1005 {
73 const char * sv1005_comment;
77 const char * usri0_name;
81 const char * usri1_name;
82 const char * usri1_password;
83 uint32_t usri1_password_age;
85 const char * usri1_home_dir;
86 const char * usri1_comment;
88 const char * usri1_script_path;
91 struct NET_DISPLAY_USER {
92 const char * usri1_name;
93 const char * usri1_comment;
95 const char * usri1_full_name;
96 uint32_t usri1_user_id;
97 uint32_t usri1_next_index;
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;
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;
116 struct GROUP_INFO_0 {
117 const char * grpi0_name;
120 struct GROUP_INFO_1 {
121 const char * grpi1_name;
122 const char * grpi1_comment;
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;
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;
139 #endif /* _HEADER_libnetapi */
141 /****************************************************************
142 ****************************************************************/
144 struct libnetapi_ctx {
154 /****************************************************************
155 ****************************************************************/
157 NET_API_STATUS libnetapi_init(struct libnetapi_ctx **ctx);
159 /****************************************************************
160 ****************************************************************/
162 NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx);
164 /****************************************************************
165 ****************************************************************/
167 NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx);
169 /****************************************************************
170 ****************************************************************/
172 NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx,
173 const char *debuglevel);
175 /****************************************************************
176 ****************************************************************/
178 NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
179 const char *username);
181 /****************************************************************
182 ****************************************************************/
184 NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx,
185 const char *password);
187 /****************************************************************
188 ****************************************************************/
190 NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
191 const char *workgroup);
193 /****************************************************************
194 ****************************************************************/
196 NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx);
198 /****************************************************************
199 ****************************************************************/
201 const char *libnetapi_errstr(NET_API_STATUS status);
203 /****************************************************************
204 ****************************************************************/
206 const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
207 NET_API_STATUS status);
210 /****************************************************************
212 ****************************************************************/
214 NET_API_STATUS NetApiBufferFree(void *buffer);
216 /************************************************************//**
220 * @brief Join a computer to a domain or workgroup
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
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
231 * example netdomjoin/netdomjoin.c
232 ***************************************************************/
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] */);
241 /************************************************************//**
245 * @brief Unjoin a computer from a domain or workgroup
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
253 ***************************************************************/
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] */);
260 /************************************************************//**
262 * NetGetJoinInformation
264 * @brief Unjoin a computer from a domain or workgroup
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
271 * example netdomjoin-gui/netdomjoin-gui.c
273 ***************************************************************/
275 NET_API_STATUS NetGetJoinInformation(const char * server_name /* [in] */,
276 const char * *name_buffer /* [out] [ref] */,
277 uint16_t *name_type /* [out] [ref] */);
279 /************************************************************//**
283 * @brief Query for the list of joinable organizational Units that can be used
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
294 * example netdomjoin-gui/netdomjoin-gui.c
296 ***************************************************************/
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] */);
305 /************************************************************//**
309 * @brief Get Information on a server
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
316 ***************************************************************/
318 NET_API_STATUS NetServerGetInfo(const char * server_name /* [in] */,
319 uint32_t level /* [in] */,
320 uint8_t **buffer /* [out] [ref] */);
322 /************************************************************//**
326 * @brief Get Information on a server
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
334 ***************************************************************/
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] */);
341 /************************************************************//**
345 * @brief Query for the PDC for a given domain
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
352 * example getdc/getdc.c
353 ***************************************************************/
355 NET_API_STATUS NetGetDCName(const char * server_name /* [in] */,
356 const char * domain_name /* [in] */,
357 uint8_t **buffer /* [out] [ref] */);
359 /************************************************************//**
363 * @brief Query for any DC for a given domain
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
370 * example getdc/getdc.c
371 ***************************************************************/
373 NET_API_STATUS NetGetAnyDCName(const char * server_name /* [in] */,
374 const char * domain_name /* [in] */,
375 uint8_t **buffer /* [out] [ref] */);
378 /************************************************************//**
382 * @brief Lookup a DC for a given domain and return information structure
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
392 * example dsgetdc/dsgetdc.c
393 ***************************************************************/
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] */);
402 /************************************************************//**
406 * @brief Create a user on a given server
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
414 * @return NET_API_STATUS
416 * example user/user_add.c
417 ***************************************************************/
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] */);
424 /************************************************************//**
428 * @brief Delete a user on a given server
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
434 * example user/user_del.c
435 ***************************************************************/
437 NET_API_STATUS NetUserDel(const char * server_name /* [in] */,
438 const char * user_name /* [in] */);
440 /************************************************************//**
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 (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
456 * @return NET_API_STATUS
458 * example user/user_enum.c
459 ***************************************************************/
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] */);
470 /************************************************************//**
472 * NetQueryDisplayInformation
474 * @brief Enumerate accounts on a server
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
485 * example user/user_dispinfo.c
486 ***************************************************************/
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] */);
496 /************************************************************//**
500 * @brief Create Domain Group
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
508 * example group/group_add.c
509 ***************************************************************/
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] */);
516 /************************************************************//**
520 * @brief Delete Domain Group
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
526 * example group/group_del.c
527 ***************************************************************/
530 NET_API_STATUS NetGroupDel(const char * server_name /* [in] */,
531 const char * group_name /* [in] */);