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 struct TIME_OF_DAY_INFO
{
161 uint32_t tod_elapsedt
;
167 int32_t tod_timezone
;
168 uint32_t tod_tinterval
;
172 uint32_t tod_weekday
;
175 #endif /* _HEADER_libnetapi */
177 /****************************************************************
178 ****************************************************************/
180 struct libnetapi_ctx
{
190 /****************************************************************
191 ****************************************************************/
193 NET_API_STATUS
libnetapi_init(struct libnetapi_ctx
**ctx
);
195 /****************************************************************
196 ****************************************************************/
198 NET_API_STATUS
libnetapi_free(struct libnetapi_ctx
*ctx
);
200 /****************************************************************
201 ****************************************************************/
203 NET_API_STATUS
libnetapi_getctx(struct libnetapi_ctx
**ctx
);
205 /****************************************************************
206 ****************************************************************/
208 NET_API_STATUS
libnetapi_set_debuglevel(struct libnetapi_ctx
*ctx
,
209 const char *debuglevel
);
211 /****************************************************************
212 ****************************************************************/
214 NET_API_STATUS
libnetapi_set_username(struct libnetapi_ctx
*ctx
,
215 const char *username
);
217 /****************************************************************
218 ****************************************************************/
220 NET_API_STATUS
libnetapi_set_password(struct libnetapi_ctx
*ctx
,
221 const char *password
);
223 /****************************************************************
224 ****************************************************************/
226 NET_API_STATUS
libnetapi_set_workgroup(struct libnetapi_ctx
*ctx
,
227 const char *workgroup
);
229 /****************************************************************
230 ****************************************************************/
232 NET_API_STATUS
libnetapi_set_use_kerberos(struct libnetapi_ctx
*ctx
);
234 /****************************************************************
235 ****************************************************************/
237 const char *libnetapi_errstr(NET_API_STATUS status
);
239 /****************************************************************
240 ****************************************************************/
242 const char *libnetapi_get_error_string(struct libnetapi_ctx
*ctx
,
243 NET_API_STATUS status
);
246 /****************************************************************
248 ****************************************************************/
250 NET_API_STATUS
NetApiBufferFree(void *buffer
);
252 /************************************************************//**
256 * @brief Join a computer to a domain or workgroup
258 * @param[in] server The server name to connect to
259 * @param[in] domain The domain or workgroup to join
260 * @param[in] account_ou The organizational Unit to create the computer account
262 * @param[in] account The domain account used for joining a domain
263 * @param[in] password The domain account's password used for joining a domain
264 * @param[in] join_flags Bitmask field to define specific join features
265 * @return NET_API_STATUS
267 * example netdomjoin/netdomjoin.c
268 ***************************************************************/
270 NET_API_STATUS
NetJoinDomain(const char * server
/* [in] */,
271 const char * domain
/* [in] [ref] */,
272 const char * account_ou
/* [in] */,
273 const char * account
/* [in] */,
274 const char * password
/* [in] */,
275 uint32_t join_flags
/* [in] */);
277 /************************************************************//**
281 * @brief Unjoin a computer from a domain or workgroup
283 * @param[in] server_name The server name to connect to
284 * @param[in] account The domain account used for unjoining a domain
285 * @param[in] password The domain account's password used for unjoining a domain
286 * @param[in] unjoin_flags Bitmask field to define specific unjoin features
287 * @return NET_API_STATUS
289 ***************************************************************/
291 NET_API_STATUS
NetUnjoinDomain(const char * server_name
/* [in] */,
292 const char * account
/* [in] */,
293 const char * password
/* [in] */,
294 uint32_t unjoin_flags
/* [in] */);
296 /************************************************************//**
298 * NetGetJoinInformation
300 * @brief Unjoin a computer from a domain or workgroup
302 * @param[in] server_name The server name to connect to
303 * @param[out] name_buffer Returns the name of the workgroup or domain
304 * @param[out] name_type Returns the type of that name
305 * @return NET_API_STATUS
307 * example netdomjoin-gui/netdomjoin-gui.c
309 ***************************************************************/
311 NET_API_STATUS
NetGetJoinInformation(const char * server_name
/* [in] */,
312 const char * *name_buffer
/* [out] [ref] */,
313 uint16_t *name_type
/* [out] [ref] */);
315 /************************************************************//**
319 * @brief Query for the list of joinable organizational Units that can be used
322 * @param[in] server_name The server name to connect to
323 * @param[in] domain The AD domain to query
324 * @param[in] account The domain account used for the query
325 * @param[in] password The domain account's password used for the query
326 * @param[out] ou_count The number of ous returned
327 * @param[out] ous Returned string array containing the ous
328 * @return NET_API_STATUS
330 * example netdomjoin-gui/netdomjoin-gui.c
332 ***************************************************************/
334 NET_API_STATUS
NetGetJoinableOUs(const char * server_name
/* [in] */,
335 const char * domain
/* [in] [ref] */,
336 const char * account
/* [in] */,
337 const char * password
/* [in] */,
338 uint32_t *ou_count
/* [out] [ref] */,
339 const char * **ous
/* [out] [ref] */);
341 /************************************************************//**
345 * @brief Get Information on a server
347 * @param[in] server_name The server name to connect to
348 * @param[in] level The level to define which information is requested
349 * @param[out] buffer The returned buffer carrying the SERVER_INFO structure
350 * @return NET_API_STATUS
352 ***************************************************************/
354 NET_API_STATUS
NetServerGetInfo(const char * server_name
/* [in] */,
355 uint32_t level
/* [in] */,
356 uint8_t **buffer
/* [out] [ref] */);
358 /************************************************************//**
362 * @brief Get Information on a server
364 * @param[in] server_name The server name to connect to
365 * @param[in] level The level to define which information is set
366 * @param[in] buffer The buffer carrying the SERVER_INFO structure
367 * @param[out] parm_error On failure returns the invalid SERVER_INFO member
368 * @return NET_API_STATUS
370 ***************************************************************/
372 NET_API_STATUS
NetServerSetInfo(const char * server_name
/* [in] */,
373 uint32_t level
/* [in] */,
374 uint8_t *buffer
/* [in] [ref] */,
375 uint32_t *parm_error
/* [out] [ref] */);
377 /************************************************************//**
381 * @brief Query for the PDC for a given domain
383 * @param[in] server_name The server name to connect to
384 * @param[in] domain_name The name of the domain to lookup
385 * @param[out] buffer The name of the domain to lookup
386 * @return NET_API_STATUS
388 * example getdc/getdc.c
389 ***************************************************************/
391 NET_API_STATUS
NetGetDCName(const char * server_name
/* [in] */,
392 const char * domain_name
/* [in] */,
393 uint8_t **buffer
/* [out] [ref] */);
395 /************************************************************//**
399 * @brief Query for any DC for a given domain
401 * @param[in] server_name The server name to connect to
402 * @param[in] domain_name The name of the domain to lookup
403 * @param[out] buffer The name of the domain to lookup
404 * @return NET_API_STATUS
406 * example getdc/getdc.c
407 ***************************************************************/
409 NET_API_STATUS
NetGetAnyDCName(const char * server_name
/* [in] */,
410 const char * domain_name
/* [in] */,
411 uint8_t **buffer
/* [out] [ref] */);
414 /************************************************************//**
418 * @brief Lookup a DC for a given domain and return information structure
420 * @param[in] server_name The server name to connect to
421 * @param[in] domain_name The name of the domain to lookup (cannot be NULL)
422 * @param[in] domain_guid The GUID of the domain to lookup (optional)
423 * @param[in] site_name The name of the site the DC should reside in
424 * @param[in] flags A bitmask to request specific features supported by the DC
425 * @param[out] dc_info Pointer to a DOMAIN_CONTROLLER_INFO structure
426 * @return NET_API_STATUS
428 * example dsgetdc/dsgetdc.c
429 ***************************************************************/
431 NET_API_STATUS
DsGetDcName(const char * server_name
/* [in] [unique] */,
432 const char * domain_name
/* [in] [ref] */,
433 struct GUID
*domain_guid
/* [in] [unique] */,
434 const char * site_name
/* [in] [unique] */,
435 uint32_t flags
/* [in] */,
436 struct DOMAIN_CONTROLLER_INFO
**dc_info
/* [out] [ref] */);
438 /************************************************************//**
442 * @brief Create a user on a given server
444 * @param[in] server_name The server name to connect to
445 * @param[in] level The level of the USER_INFO structure passed in (Currently
446 * only level 1 is supported)
447 * @param[in] buffer The buffer carrying the USER_INFO structure
448 * @param[out] parm_error In case of error returns the failing member of the
450 * @return NET_API_STATUS
452 * example user/user_add.c
453 ***************************************************************/
455 NET_API_STATUS
NetUserAdd(const char * server_name
/* [in] */,
456 uint32_t level
/* [in] */,
457 uint8_t *buffer
/* [in] [ref] */,
458 uint32_t *parm_error
/* [out] [ref] */);
460 /************************************************************//**
464 * @brief Delete a user on a given server
466 * @param[in] server_name The server name to connect to
467 * @param[in] user_name The user account to delete
468 * @return NET_API_STATUS
470 * example user/user_del.c
471 ***************************************************************/
473 NET_API_STATUS
NetUserDel(const char * server_name
/* [in] */,
474 const char * user_name
/* [in] */);
476 /************************************************************//**
480 * @brief Enumerate accounts on a server
482 * @param[in] server_name The server name to connect to
483 * @param[in] level The enumeration level used for the query (Currently only
484 * level 0 is supported)
485 * @param[in] filter The account flags filter used for the query
486 * @param[out] buffer The returned enumeration buffer
487 * @param[in] prefmaxlen The requested maximal buffer size
488 * @param[out] entries_read The number of returned entries
489 * @param[out] total_entries The number of total entries
490 * @param[in,out] resume_handle A handle passed in and returned for resuming
492 * @return NET_API_STATUS
494 * example user/user_enum.c
495 ***************************************************************/
497 NET_API_STATUS
NetUserEnum(const char * server_name
/* [in] */,
498 uint32_t level
/* [in] */,
499 uint32_t filter
/* [in] */,
500 uint8_t **buffer
/* [out] [ref] */,
501 uint32_t prefmaxlen
/* [in] */,
502 uint32_t *entries_read
/* [out] [ref] */,
503 uint32_t *total_entries
/* [out] [ref] */,
504 uint32_t *resume_handle
/* [in,out] [ref] */);
506 /************************************************************//**
508 * NetQueryDisplayInformation
510 * @brief Enumerate accounts on a server
512 * @param[in] server_name The server name to connect to
513 * @param[in] level The enumeration level used for the query
514 * @param[in] idx The index to start the the display enumeration at
515 * @param[in] entries_requested The number of entries requested
516 * @param[in] prefmaxlen The requested maximal buffer size
517 * @param[out] entries_read The number of returned entries
518 * @param[out] buffer The returned display information buffer
519 * @return NET_API_STATUS
521 * example user/user_dispinfo.c
522 ***************************************************************/
524 NET_API_STATUS
NetQueryDisplayInformation(const char * server_name
/* [in] [unique] */,
525 uint32_t level
/* [in] */,
526 uint32_t idx
/* [in] */,
527 uint32_t entries_requested
/* [in] */,
528 uint32_t prefmaxlen
/* [in] */,
529 uint32_t *entries_read
/* [out] [ref] */,
530 void **buffer
/* [out] [noprint,ref] */);
532 /************************************************************//**
536 * @brief Create Domain Group
538 * @param[in] server_name The server name to connect to
539 * @param[in] level The level used for the new group creation
540 * @param[in] buf The buffer containing the group structure
541 * @param[out] parm_err The returned parameter error number if any
542 * @return NET_API_STATUS
544 * example group/group_add.c
545 ***************************************************************/
547 NET_API_STATUS
NetGroupAdd(const char * server_name
/* [in] */,
548 uint32_t level
/* [in] */,
549 uint8_t *buf
/* [in] [ref] */,
550 uint32_t *parm_err
/* [out] [ref] */);
552 /************************************************************//**
556 * @brief Delete Domain Group
558 * @param[in] server_name The server name to connect to
559 * @param[in] group_name The name of the group that is going to be deleted
560 * @return NET_API_STATUS
562 * example group/group_del.c
563 ***************************************************************/
565 NET_API_STATUS
NetGroupDel(const char * server_name
/* [in] */,
566 const char * group_name
/* [in] */);
568 /************************************************************//**
572 * @brief Set Domain Group Information
574 * @param[in] server_name The server name to connect to
575 * @param[in] group_name The name of the group that is going to be modified
576 * @param[in] level The level defining the structure type in buf
577 * @param[in] buf The buffer containing a GROUP_INFO_X structure
578 * @param[out] parm_err The returned parameter error number if any
579 * @return NET_API_STATUS
581 * example group/group_setinfo.c
582 ***************************************************************/
584 NET_API_STATUS
NetGroupSetInfo(const char * server_name
/* [in] */,
585 const char * group_name
/* [in] */,
586 uint32_t level
/* [in] */,
587 uint8_t *buf
/* [in] [ref] */,
588 uint32_t *parm_err
/* [out] [ref] */);
590 /************************************************************//**
594 * @brief Get Domain Group Information
596 * @param[in] server_name The server name to connect to
597 * @param[in] group_name The name of the group that is going to be modified
598 * @param[in] level The level defining the requested GROUP_INFO_X structure
599 * @param[out] buf The buffer containing a GROUP_INFO_X structure
600 * @return NET_API_STATUS
602 * example group/group_del.c
603 ***************************************************************/
605 NET_API_STATUS
NetGroupGetInfo(const char * server_name
/* [in] */,
606 const char * group_name
/* [in] */,
607 uint32_t level
/* [in] */,
608 uint8_t **buf
/* [out] [ref] */);
610 /************************************************************//**
614 * @brief Add existing User to existing Domain Group
616 * @param[in] server_name The server name to connect to
617 * @param[in] group_name The name of the group that is going to be modified
618 * @param[in] user_name The name of the user that is going to be added to the
620 * @return NET_API_STATUS
622 * example group/group_adduser.c
623 ***************************************************************/
625 NET_API_STATUS
NetGroupAddUser(const char * server_name
/* [in] */,
626 const char * group_name
/* [in] */,
627 const char * user_name
/* [in] */);
629 /************************************************************//**
633 * @brief Remove User from Domain Group
635 * @param[in] server_name The server name to connect to
636 * @param[in] group_name The name of the group that is going to be modified
637 * @param[in] user_name The name of the user that is going to be removed from
639 * @return NET_API_STATUS
641 * example group/group_deluser.c
642 ***************************************************************/
644 NET_API_STATUS
NetGroupDelUser(const char * server_name
/* [in] */,
645 const char * group_name
/* [in] */,
646 const char * user_name
/* [in] */);
648 /************************************************************//**
652 * @brief Create Local Group
654 * @param[in] server_name The server name to connect to
655 * @param[in] level The level used for the new group creation
656 * @param[in] buf The buffer containing the group structure
657 * @param[out] parm_err The returned parameter error number if any
658 * @return NET_API_STATUS
660 * example localgroup/localgroup_add.c
661 ***************************************************************/
663 NET_API_STATUS
NetLocalGroupAdd(const char * server_name
/* [in] */,
664 uint32_t level
/* [in] */,
665 uint8_t *buf
/* [in] [ref] */,
666 uint32_t *parm_err
/* [out] [ref] */);
668 /************************************************************//**
672 * @brief Delete Local Group
674 * @param[in] server_name The server name to connect to
675 * @param[in] group_name The name of the group that is going to be deleted
676 * @return NET_API_STATUS
678 * example localgroup/localgroup_del.c
679 ***************************************************************/
682 NET_API_STATUS
NetLocalGroupDel(const char * server_name
/* [in] */,
683 const char * group_name
/* [in] */);
685 /************************************************************//**
687 * NetLocalGroupGetInfo
689 * @brief Get Local Group Information
691 * @param[in] server_name The server name to connect to
692 * @param[in] group_name The name of the group that is going to be queried
693 * @param[in] level The level defining the requested LOCALGROUP_INFO_X structure
694 * @param[out] buf The buffer containing a LOCALGROUP_INFO_X structure
695 * @return NET_API_STATUS
697 * example localgroup/localgroup_getinfo.c
698 ***************************************************************/
700 NET_API_STATUS
NetLocalGroupGetInfo(const char * server_name
/* [in] */,
701 const char * group_name
/* [in] */,
702 uint32_t level
/* [in] */,
703 uint8_t **buf
/* [out] [ref] */);
705 /************************************************************//**
707 * NetLocalGroupSetInfo
709 * @brief Set Local Group Information
711 * @param[in] server_name The server name to connect to
712 * @param[in] group_name The name of the group that is going to be modified
713 * @param[in] level The level defining the requested LOCALGROUP_INFO_X structure
714 * @param[in] buf The buffer containing a LOCALGROUP_INFO_X structure
715 * @param[out] parm_err The returned parameter error number if any
716 * @return NET_API_STATUS
718 * example localgroup/localgroup_setinfo.c
719 ***************************************************************/
722 NET_API_STATUS
NetLocalGroupSetInfo(const char * server_name
/* [in] */,
723 const char * group_name
/* [in] */,
724 uint32_t level
/* [in] */,
725 uint8_t *buf
/* [in] [ref] */,
726 uint32_t *parm_err
/* [out] [ref] */);
728 /************************************************************//**
732 * @brief Query remote Time of Day
734 * @param[in] server_name The server name to connect to
735 * @param[out] buf The buffer containing a TIME_OF_DAY_INFO structure
736 * @return NET_API_STATUS
738 * example server/remote_tod.c
739 ***************************************************************/
741 NET_API_STATUS
NetRemoteTOD(const char * server_name
/* [in] */,
742 uint8_t **buf
/* [out] [ref] */);