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 struct GROUP_INFO_1002 {
140 const char * grpi1002_comment;
143 struct GROUP_INFO_1005 {
144 uint32_t grpi1005_attributes;
147 struct LOCALGROUP_INFO_0 {
148 const char * lgrpi0_name;
151 struct LOCALGROUP_INFO_1 {
152 const char * lgrpi1_name;
153 const char * lgrpi1_comment;
156 struct LOCALGROUP_INFO_1002 {
157 const char * lgrpi1002_comment;
160 #endif /* _HEADER_libnetapi */
162 /****************************************************************
163 ****************************************************************/
165 struct libnetapi_ctx {
175 /****************************************************************
176 ****************************************************************/
178 NET_API_STATUS libnetapi_init(struct libnetapi_ctx **ctx);
180 /****************************************************************
181 ****************************************************************/
183 NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx);
185 /****************************************************************
186 ****************************************************************/
188 NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx);
190 /****************************************************************
191 ****************************************************************/
193 NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx,
194 const char *debuglevel);
196 /****************************************************************
197 ****************************************************************/
199 NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
200 const char *username);
202 /****************************************************************
203 ****************************************************************/
205 NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx,
206 const char *password);
208 /****************************************************************
209 ****************************************************************/
211 NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
212 const char *workgroup);
214 /****************************************************************
215 ****************************************************************/
217 NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx);
219 /****************************************************************
220 ****************************************************************/
222 const char *libnetapi_errstr(NET_API_STATUS status);
224 /****************************************************************
225 ****************************************************************/
227 const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
228 NET_API_STATUS status);
231 /****************************************************************
233 ****************************************************************/
235 NET_API_STATUS NetApiBufferFree(void *buffer);
237 /************************************************************//**
241 * @brief Join a computer to a domain or workgroup
243 * @param[in] server The server name to connect to
244 * @param[in] domain The domain or workgroup to join
245 * @param[in] account_ou The organizational Unit to create the computer account
247 * @param[in] account The domain account used for joining a domain
248 * @param[in] password The domain account's password used for joining a domain
249 * @param[in] join_flags Bitmask field to define specific join features
250 * @return NET_API_STATUS
252 * example netdomjoin/netdomjoin.c
253 ***************************************************************/
255 NET_API_STATUS NetJoinDomain(const char * server /* [in] */,
256 const char * domain /* [in] [ref] */,
257 const char * account_ou /* [in] */,
258 const char * account /* [in] */,
259 const char * password /* [in] */,
260 uint32_t join_flags /* [in] */);
262 /************************************************************//**
266 * @brief Unjoin a computer from a domain or workgroup
268 * @param[in] server_name The server name to connect to
269 * @param[in] account The domain account used for unjoining a domain
270 * @param[in] password The domain account's password used for unjoining a domain
271 * @param[in] unjoin_flags Bitmask field to define specific unjoin features
272 * @return NET_API_STATUS
274 ***************************************************************/
276 NET_API_STATUS NetUnjoinDomain(const char * server_name /* [in] */,
277 const char * account /* [in] */,
278 const char * password /* [in] */,
279 uint32_t unjoin_flags /* [in] */);
281 /************************************************************//**
283 * NetGetJoinInformation
285 * @brief Unjoin a computer from a domain or workgroup
287 * @param[in] server_name The server name to connect to
288 * @param[out] name_buffer Returns the name of the workgroup or domain
289 * @param[out] name_type Returns the type of that name
290 * @return NET_API_STATUS
292 * example netdomjoin-gui/netdomjoin-gui.c
294 ***************************************************************/
296 NET_API_STATUS NetGetJoinInformation(const char * server_name /* [in] */,
297 const char * *name_buffer /* [out] [ref] */,
298 uint16_t *name_type /* [out] [ref] */);
300 /************************************************************//**
304 * @brief Query for the list of joinable organizational Units that can be used
307 * @param[in] server_name The server name to connect to
308 * @param[in] domain The AD domain to query
309 * @param[in] account The domain account used for the query
310 * @param[in] password The domain account's password used for the query
311 * @param[out] ou_count The number of ous returned
312 * @param[out] ous Returned string array containing the ous
313 * @return NET_API_STATUS
315 * example netdomjoin-gui/netdomjoin-gui.c
317 ***************************************************************/
319 NET_API_STATUS NetGetJoinableOUs(const char * server_name /* [in] */,
320 const char * domain /* [in] [ref] */,
321 const char * account /* [in] */,
322 const char * password /* [in] */,
323 uint32_t *ou_count /* [out] [ref] */,
324 const char * **ous /* [out] [ref] */);
326 /************************************************************//**
330 * @brief Get Information on a server
332 * @param[in] server_name The server name to connect to
333 * @param[in] level The level to define which information is requested
334 * @param[out] buffer The returned buffer carrying the SERVER_INFO structure
335 * @return NET_API_STATUS
337 ***************************************************************/
339 NET_API_STATUS NetServerGetInfo(const char * server_name /* [in] */,
340 uint32_t level /* [in] */,
341 uint8_t **buffer /* [out] [ref] */);
343 /************************************************************//**
347 * @brief Get Information on a server
349 * @param[in] server_name The server name to connect to
350 * @param[in] level The level to define which information is set
351 * @param[in] buffer The buffer carrying the SERVER_INFO structure
352 * @param[out] parm_error On failure returns the invalid SERVER_INFO member
353 * @return NET_API_STATUS
355 ***************************************************************/
357 NET_API_STATUS NetServerSetInfo(const char * server_name /* [in] */,
358 uint32_t level /* [in] */,
359 uint8_t *buffer /* [in] [ref] */,
360 uint32_t *parm_error /* [out] [ref] */);
362 /************************************************************//**
366 * @brief Query for the PDC for a given domain
368 * @param[in] server_name The server name to connect to
369 * @param[in] domain_name The name of the domain to lookup
370 * @param[out] buffer The name of the domain to lookup
371 * @return NET_API_STATUS
373 * example getdc/getdc.c
374 ***************************************************************/
376 NET_API_STATUS NetGetDCName(const char * server_name /* [in] */,
377 const char * domain_name /* [in] */,
378 uint8_t **buffer /* [out] [ref] */);
380 /************************************************************//**
384 * @brief Query for any DC for a given domain
386 * @param[in] server_name The server name to connect to
387 * @param[in] domain_name The name of the domain to lookup
388 * @param[out] buffer The name of the domain to lookup
389 * @return NET_API_STATUS
391 * example getdc/getdc.c
392 ***************************************************************/
394 NET_API_STATUS NetGetAnyDCName(const char * server_name /* [in] */,
395 const char * domain_name /* [in] */,
396 uint8_t **buffer /* [out] [ref] */);
399 /************************************************************//**
403 * @brief Lookup a DC for a given domain and return information structure
405 * @param[in] server_name The server name to connect to
406 * @param[in] domain_name The name of the domain to lookup (cannot be NULL)
407 * @param[in] domain_guid The GUID of the domain to lookup (optional)
408 * @param[in] site_name The name of the site the DC should reside in
409 * @param[in] flags A bitmask to request specific features supported by the DC
410 * @param[out] dc_info Pointer to a DOMAIN_CONTROLLER_INFO structure
411 * @return NET_API_STATUS
413 * example dsgetdc/dsgetdc.c
414 ***************************************************************/
416 NET_API_STATUS DsGetDcName(const char * server_name /* [in] [unique] */,
417 const char * domain_name /* [in] [ref] */,
418 struct GUID *domain_guid /* [in] [unique] */,
419 const char * site_name /* [in] [unique] */,
420 uint32_t flags /* [in] */,
421 struct DOMAIN_CONTROLLER_INFO **dc_info /* [out] [ref] */);
423 /************************************************************//**
427 * @brief Create a user on a given server
429 * @param[in] server_name The server name to connect to
430 * @param[in] level The level of the USER_INFO structure passed in (Currently
431 * only level 1 is supported)
432 * @param[in] buffer The buffer carrying the USER_INFO structure
433 * @param[out] parm_error In case of error returns the failing member of the
435 * @return NET_API_STATUS
437 * example user/user_add.c
438 ***************************************************************/
440 NET_API_STATUS NetUserAdd(const char * server_name /* [in] */,
441 uint32_t level /* [in] */,
442 uint8_t *buffer /* [in] [ref] */,
443 uint32_t *parm_error /* [out] [ref] */);
445 /************************************************************//**
449 * @brief Delete a user on a given server
451 * @param[in] server_name The server name to connect to
452 * @param[in] user_name The user account to delete
453 * @return NET_API_STATUS
455 * example user/user_del.c
456 ***************************************************************/
458 NET_API_STATUS NetUserDel(const char * server_name /* [in] */,
459 const char * user_name /* [in] */);
461 /************************************************************//**
465 * @brief Enumerate accounts on a server
467 * @param[in] server_name The server name to connect to
468 * @param[in] level The enumeration level used for the query (Currently only
469 * level 0 is supported)
470 * @param[in] filter The account flags filter used for the query
471 * @param[out] buffer The returned enumeration buffer
472 * @param[in] prefmaxlen The requested maximal buffer size
473 * @param[out] entries_read The number of returned entries
474 * @param[out] total_entries The number of total entries
475 * @param[in,out] resume_handle A handle passed in and returned for resuming
477 * @return NET_API_STATUS
479 * example user/user_enum.c
480 ***************************************************************/
482 NET_API_STATUS NetUserEnum(const char * server_name /* [in] */,
483 uint32_t level /* [in] */,
484 uint32_t filter /* [in] */,
485 uint8_t **buffer /* [out] [ref] */,
486 uint32_t prefmaxlen /* [in] */,
487 uint32_t *entries_read /* [out] [ref] */,
488 uint32_t *total_entries /* [out] [ref] */,
489 uint32_t *resume_handle /* [in,out] [ref] */);
491 /************************************************************//**
493 * NetQueryDisplayInformation
495 * @brief Enumerate accounts on a server
497 * @param[in] server_name The server name to connect to
498 * @param[in] level The enumeration level used for the query
499 * @param[in] idx The index to start the the display enumeration at
500 * @param[in] entries_requested The number of entries requested
501 * @param[in] prefmaxlen The requested maximal buffer size
502 * @param[out] entries_read The number of returned entries
503 * @param[out] buffer The returned display information buffer
504 * @return NET_API_STATUS
506 * example user/user_dispinfo.c
507 ***************************************************************/
509 NET_API_STATUS NetQueryDisplayInformation(const char * server_name /* [in] [unique] */,
510 uint32_t level /* [in] */,
511 uint32_t idx /* [in] */,
512 uint32_t entries_requested /* [in] */,
513 uint32_t prefmaxlen /* [in] */,
514 uint32_t *entries_read /* [out] [ref] */,
515 void **buffer /* [out] [noprint,ref] */);
517 /************************************************************//**
521 * @brief Create Domain Group
523 * @param[in] server_name The server name to connect to
524 * @param[in] level The level used for the new group creation
525 * @param[in] buf The buffer containing the group structure
526 * @param[out] parm_err The returned parameter error number if any
527 * @return NET_API_STATUS
529 * example group/group_add.c
530 ***************************************************************/
532 NET_API_STATUS NetGroupAdd(const char * server_name /* [in] */,
533 uint32_t level /* [in] */,
534 uint8_t *buf /* [in] [ref] */,
535 uint32_t *parm_err /* [out] [ref] */);
537 /************************************************************//**
541 * @brief Delete Domain Group
543 * @param[in] server_name The server name to connect to
544 * @param[in] group_name The name of the group that is going to be deleted
545 * @return NET_API_STATUS
547 * example group/group_del.c
548 ***************************************************************/
550 NET_API_STATUS NetGroupDel(const char * server_name /* [in] */,
551 const char * group_name /* [in] */);
553 /************************************************************//**
557 * @brief Set Domain Group Information
559 * @param[in] server_name The server name to connect to
560 * @param[in] group_name The name of the group that is going to be modified
561 * @param[in] level The level defining the structure type in buf
562 * @param[in] buf The buffer containing a GROUP_INFO_X structure
563 * @param[out] parm_err The returned parameter error number if any
564 * @return NET_API_STATUS
566 * example group/group_setinfo.c
567 ***************************************************************/
569 NET_API_STATUS NetGroupSetInfo(const char * server_name /* [in] */,
570 const char * group_name /* [in] */,
571 uint32_t level /* [in] */,
572 uint8_t *buf /* [in] [ref] */,
573 uint32_t *parm_err /* [out] [ref] */);
575 /************************************************************//**
579 * @brief Get Domain Group Information
581 * @param[in] server_name The server name to connect to
582 * @param[in] group_name The name of the group that is going to be modified
583 * @param[in] level The level defining the requested GROUP_INFO_X structure
584 * @param[out] buf The buffer containing a GROUP_INFO_X structure
585 * @return NET_API_STATUS
587 * example group/group_del.c
588 ***************************************************************/
590 NET_API_STATUS NetGroupGetInfo(const char * server_name /* [in] */,
591 const char * group_name /* [in] */,
592 uint32_t level /* [in] */,
593 uint8_t **buf /* [out] [ref] */);
595 /************************************************************//**
599 * @brief Add existing User to existing Domain Group
601 * @param[in] server_name The server name to connect to
602 * @param[in] group_name The name of the group that is going to be modified
603 * @param[in] user_name The name of the user that is going to be added to the
605 * @return NET_API_STATUS
607 * example group/group_adduser.c
608 ***************************************************************/
610 NET_API_STATUS NetGroupAddUser(const char * server_name /* [in] */,
611 const char * group_name /* [in] */,
612 const char * user_name /* [in] */);
614 /************************************************************//**
618 * @brief Remove User from Domain Group
620 * @param[in] server_name The server name to connect to
621 * @param[in] group_name The name of the group that is going to be modified
622 * @param[in] user_name The name of the user that is going to be removed from
624 * @return NET_API_STATUS
626 * example group/group_deluser.c
627 ***************************************************************/
629 NET_API_STATUS NetGroupDelUser(const char * server_name /* [in] */,
630 const char * group_name /* [in] */,
631 const char * user_name /* [in] */);
633 /************************************************************//**
637 * @brief Create Local Group
639 * @param[in] server_name The server name to connect to
640 * @param[in] level The level used for the new group creation
641 * @param[in] buf The buffer containing the group structure
642 * @param[out] parm_err The returned parameter error number if any
643 * @return NET_API_STATUS
645 * example localgroup/localgroup_add.c
646 ***************************************************************/
648 NET_API_STATUS NetLocalGroupAdd(const char * server_name /* [in] */,
649 uint32_t level /* [in] */,
650 uint8_t *buf /* [in] [ref] */,
651 uint32_t *parm_err /* [out] [ref] */);
653 /************************************************************//**
657 * @brief Delete Local Group
659 * @param[in] server_name The server name to connect to
660 * @param[in] group_name The name of the group that is going to be deleted
661 * @return NET_API_STATUS
663 * example localgroup/localgroup_del.c
664 ***************************************************************/
667 NET_API_STATUS NetLocalGroupDel(const char * server_name /* [in] */,
668 const char * group_name /* [in] */);
670 /************************************************************//**
672 * NetLocalGroupGetInfo
674 * @brief Get Local Group Information
676 * @param[in] server_name The server name to connect to
677 * @param[in] group_name The name of the group that is going to be queried
678 * @param[in] level The level defining the requested LOCALGROUP_INFO_X structure
679 * @param[out] buf The buffer containing a LOCALGROUP_INFO_X structure
680 * @return NET_API_STATUS
682 * example localgroup/localgroup_getinfo.c
683 ***************************************************************/
685 NET_API_STATUS NetLocalGroupGetInfo(const char * server_name /* [in] */,
686 const char * group_name /* [in] */,
687 uint32_t level /* [in] */,
688 uint8_t **buf /* [out] [ref] */);