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 #define FILTER_TEMP_DUPLICATE_ACCOUNT ( 0x0001 )
73 #define FILTER_NORMAL_ACCOUNT ( 0x0002 )
74 #define FILTER_INTERDOMAIN_TRUST_ACCOUNT ( 0x0008 )
75 #define FILTER_WORKSTATION_TRUST_ACCOUNT ( 0x0010 )
76 #define FILTER_SERVER_TRUST_ACCOUNT ( 0x0020 )
78 struct SERVER_INFO_1005 {
79 const char * sv1005_comment;
83 const char * usri0_name;
87 const char * usri1_name;
88 const char * usri1_password;
89 uint32_t usri1_password_age;
91 const char * usri1_home_dir;
92 const char * usri1_comment;
94 const char * usri1_script_path;
97 struct NET_DISPLAY_USER {
98 const char * usri1_name;
99 const char * usri1_comment;
100 uint32_t usri1_flags;
101 const char * usri1_full_name;
102 uint32_t usri1_user_id;
103 uint32_t usri1_next_index;
106 struct NET_DISPLAY_MACHINE {
107 const char * usri2_name;
108 const char * usri2_comment;
109 uint32_t usri2_flags;
110 uint32_t usri2_user_id;
111 uint32_t usri2_next_index;
114 struct NET_DISPLAY_GROUP {
115 const char * grpi3_name;
116 const char * grpi3_comment;
117 uint32_t grpi3_group_id;
118 uint32_t grpi3_attributes;
119 uint32_t grpi3_next_index;
122 struct GROUP_INFO_0 {
123 const char * grpi0_name;
126 struct GROUP_INFO_1 {
127 const char * grpi1_name;
128 const char * grpi1_comment;
131 struct GROUP_INFO_2 {
132 const char * grpi2_name;
133 const char * grpi2_comment;
134 uint32_t grpi2_group_id;
135 uint32_t grpi2_attributes;
138 struct GROUP_INFO_3 {
139 const char * grpi3_name;
140 const char * grpi3_comment;
141 struct domsid grpi3_group_sid;
142 uint32_t grpi3_attributes;
145 struct GROUP_INFO_1002 {
146 const char * grpi1002_comment;
149 struct GROUP_INFO_1005 {
150 uint32_t grpi1005_attributes;
153 struct LOCALGROUP_INFO_0 {
154 const char * lgrpi0_name;
157 struct LOCALGROUP_INFO_1 {
158 const char * lgrpi1_name;
159 const char * lgrpi1_comment;
162 struct LOCALGROUP_INFO_1002 {
163 const char * lgrpi1002_comment;
166 struct TIME_OF_DAY_INFO {
167 uint32_t tod_elapsedt;
173 int32_t tod_timezone;
174 uint32_t tod_tinterval;
178 uint32_t tod_weekday;
181 #endif /* _HEADER_libnetapi */
183 /****************************************************************
184 ****************************************************************/
186 struct libnetapi_ctx {
196 /****************************************************************
197 ****************************************************************/
199 NET_API_STATUS libnetapi_init(struct libnetapi_ctx **ctx);
201 /****************************************************************
202 ****************************************************************/
204 NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx);
206 /****************************************************************
207 ****************************************************************/
209 NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx);
211 /****************************************************************
212 ****************************************************************/
214 NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx,
215 const char *debuglevel);
217 /****************************************************************
218 ****************************************************************/
220 NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
221 const char *username);
223 /****************************************************************
224 ****************************************************************/
226 NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx,
227 const char *password);
229 /****************************************************************
230 ****************************************************************/
232 NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
233 const char *workgroup);
235 /****************************************************************
236 ****************************************************************/
238 NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx);
240 /****************************************************************
241 ****************************************************************/
243 const char *libnetapi_errstr(NET_API_STATUS status);
245 /****************************************************************
246 ****************************************************************/
248 const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
249 NET_API_STATUS status);
252 /****************************************************************
254 ****************************************************************/
256 NET_API_STATUS NetApiBufferFree(void *buffer);
258 /************************************************************//**
262 * @brief Join a computer to a domain or workgroup
264 * @param[in] server The server name to connect to
265 * @param[in] domain The domain or workgroup to join
266 * @param[in] account_ou The organizational Unit to create the computer account
268 * @param[in] account The domain account used for joining a domain
269 * @param[in] password The domain account's password used for joining a domain
270 * @param[in] join_flags Bitmask field to define specific join features
271 * @return NET_API_STATUS
273 * example netdomjoin/netdomjoin.c
274 ***************************************************************/
276 NET_API_STATUS NetJoinDomain(const char * server /* [in] */,
277 const char * domain /* [in] [ref] */,
278 const char * account_ou /* [in] */,
279 const char * account /* [in] */,
280 const char * password /* [in] */,
281 uint32_t join_flags /* [in] */);
283 /************************************************************//**
287 * @brief Unjoin a computer from a domain or workgroup
289 * @param[in] server_name The server name to connect to
290 * @param[in] account The domain account used for unjoining a domain
291 * @param[in] password The domain account's password used for unjoining a domain
292 * @param[in] unjoin_flags Bitmask field to define specific unjoin features
293 * @return NET_API_STATUS
295 ***************************************************************/
297 NET_API_STATUS NetUnjoinDomain(const char * server_name /* [in] */,
298 const char * account /* [in] */,
299 const char * password /* [in] */,
300 uint32_t unjoin_flags /* [in] */);
302 /************************************************************//**
304 * NetGetJoinInformation
306 * @brief Unjoin a computer from a domain or workgroup
308 * @param[in] server_name The server name to connect to
309 * @param[out] name_buffer Returns the name of the workgroup or domain
310 * @param[out] name_type Returns the type of that name
311 * @return NET_API_STATUS
313 * example netdomjoin-gui/netdomjoin-gui.c
315 ***************************************************************/
317 NET_API_STATUS NetGetJoinInformation(const char * server_name /* [in] */,
318 const char * *name_buffer /* [out] [ref] */,
319 uint16_t *name_type /* [out] [ref] */);
321 /************************************************************//**
325 * @brief Query for the list of joinable organizational Units that can be used
328 * @param[in] server_name The server name to connect to
329 * @param[in] domain The AD domain to query
330 * @param[in] account The domain account used for the query
331 * @param[in] password The domain account's password used for the query
332 * @param[out] ou_count The number of ous returned
333 * @param[out] ous Returned string array containing the ous
334 * @return NET_API_STATUS
336 * example netdomjoin-gui/netdomjoin-gui.c
338 ***************************************************************/
340 NET_API_STATUS NetGetJoinableOUs(const char * server_name /* [in] */,
341 const char * domain /* [in] [ref] */,
342 const char * account /* [in] */,
343 const char * password /* [in] */,
344 uint32_t *ou_count /* [out] [ref] */,
345 const char * **ous /* [out] [ref] */);
347 /************************************************************//**
351 * @brief Get Information on a server
353 * @param[in] server_name The server name to connect to
354 * @param[in] level The level to define which information is requested
355 * @param[out] buffer The returned buffer carrying the SERVER_INFO structure
356 * @return NET_API_STATUS
358 ***************************************************************/
360 NET_API_STATUS NetServerGetInfo(const char * server_name /* [in] */,
361 uint32_t level /* [in] */,
362 uint8_t **buffer /* [out] [ref] */);
364 /************************************************************//**
368 * @brief Get Information on a server
370 * @param[in] server_name The server name to connect to
371 * @param[in] level The level to define which information is set
372 * @param[in] buffer The buffer carrying the SERVER_INFO structure
373 * @param[out] parm_error On failure returns the invalid SERVER_INFO member
374 * @return NET_API_STATUS
376 ***************************************************************/
378 NET_API_STATUS NetServerSetInfo(const char * server_name /* [in] */,
379 uint32_t level /* [in] */,
380 uint8_t *buffer /* [in] [ref] */,
381 uint32_t *parm_error /* [out] [ref] */);
383 /************************************************************//**
387 * @brief Query for the PDC for a given domain
389 * @param[in] server_name The server name to connect to
390 * @param[in] domain_name The name of the domain to lookup
391 * @param[out] buffer The name of the domain to lookup
392 * @return NET_API_STATUS
394 * example getdc/getdc.c
395 ***************************************************************/
397 NET_API_STATUS NetGetDCName(const char * server_name /* [in] */,
398 const char * domain_name /* [in] */,
399 uint8_t **buffer /* [out] [ref] */);
401 /************************************************************//**
405 * @brief Query for any DC for a given domain
407 * @param[in] server_name The server name to connect to
408 * @param[in] domain_name The name of the domain to lookup
409 * @param[out] buffer The name of the domain to lookup
410 * @return NET_API_STATUS
412 * example getdc/getdc.c
413 ***************************************************************/
415 NET_API_STATUS NetGetAnyDCName(const char * server_name /* [in] */,
416 const char * domain_name /* [in] */,
417 uint8_t **buffer /* [out] [ref] */);
420 /************************************************************//**
424 * @brief Lookup a DC for a given domain and return information structure
426 * @param[in] server_name The server name to connect to
427 * @param[in] domain_name The name of the domain to lookup (cannot be NULL)
428 * @param[in] domain_guid The GUID of the domain to lookup (optional)
429 * @param[in] site_name The name of the site the DC should reside in
430 * @param[in] flags A bitmask to request specific features supported by the DC
431 * @param[out] dc_info Pointer to a DOMAIN_CONTROLLER_INFO structure
432 * @return NET_API_STATUS
434 * example dsgetdc/dsgetdc.c
435 ***************************************************************/
437 NET_API_STATUS DsGetDcName(const char * server_name /* [in] [unique] */,
438 const char * domain_name /* [in] [ref] */,
439 struct GUID *domain_guid /* [in] [unique] */,
440 const char * site_name /* [in] [unique] */,
441 uint32_t flags /* [in] */,
442 struct DOMAIN_CONTROLLER_INFO **dc_info /* [out] [ref] */);
444 /************************************************************//**
448 * @brief Create a user on a given server
450 * @param[in] server_name The server name to connect to
451 * @param[in] level The level of the USER_INFO structure passed in (Currently
452 * only level 1 is supported)
453 * @param[in] buffer The buffer carrying the USER_INFO structure
454 * @param[out] parm_error In case of error returns the failing member of the
456 * @return NET_API_STATUS
458 * example user/user_add.c
459 ***************************************************************/
461 NET_API_STATUS NetUserAdd(const char * server_name /* [in] */,
462 uint32_t level /* [in] */,
463 uint8_t *buffer /* [in] [ref] */,
464 uint32_t *parm_error /* [out] [ref] */);
466 /************************************************************//**
470 * @brief Delete a user on a given server
472 * @param[in] server_name The server name to connect to
473 * @param[in] user_name The user account to delete
474 * @return NET_API_STATUS
476 * example user/user_del.c
477 ***************************************************************/
479 NET_API_STATUS NetUserDel(const char * server_name /* [in] */,
480 const char * user_name /* [in] */);
482 /************************************************************//**
486 * @brief Enumerate accounts on a server
488 * @param[in] server_name The server name to connect to
489 * @param[in] level The enumeration level used for the query (Currently only
490 * level 0 is supported)
491 * @param[in] filter The account flags filter used for the query
492 * @param[out] buffer The returned enumeration buffer
493 * @param[in] prefmaxlen The requested maximal buffer size
494 * @param[out] entries_read The number of returned entries
495 * @param[out] total_entries The number of total entries
496 * @param[in,out] resume_handle A handle passed in and returned for resuming
498 * @return NET_API_STATUS
500 * example user/user_enum.c
501 ***************************************************************/
503 NET_API_STATUS NetUserEnum(const char * server_name /* [in] */,
504 uint32_t level /* [in] */,
505 uint32_t filter /* [in] */,
506 uint8_t **buffer /* [out] [ref] */,
507 uint32_t prefmaxlen /* [in] */,
508 uint32_t *entries_read /* [out] [ref] */,
509 uint32_t *total_entries /* [out] [ref] */,
510 uint32_t *resume_handle /* [in,out] [ref] */);
512 /************************************************************//**
514 * NetUserChangePassword
516 * @brief Change the password for a user on a given server or in a given domain
518 * @param[in] domain_name The server or domain name to connect to
519 * @param[in] user_name The user account to change the password for
520 * @param[in] old_password The user account's old password
521 * @param[in] new_password The user account's new password
522 * @return NET_API_STATUS
524 * example user/user_chgpwd.c
525 ***************************************************************/
527 NET_API_STATUS NetUserChangePassword(const char * domain_name /* [in] */,
528 const char * user_name /* [in] */,
529 const char * old_password /* [in] */,
530 const char * new_password /* [in] */);
532 /************************************************************//**
534 * NetQueryDisplayInformation
536 * @brief Enumerate accounts on a server
538 * @param[in] server_name The server name to connect to
539 * @param[in] level The enumeration level used for the query
540 * @param[in] idx The index to start the the display enumeration at
541 * @param[in] entries_requested The number of entries requested
542 * @param[in] prefmaxlen The requested maximal buffer size
543 * @param[out] entries_read The number of returned entries
544 * @param[out] buffer The returned display information buffer
545 * @return NET_API_STATUS
547 * example user/user_dispinfo.c
548 ***************************************************************/
550 NET_API_STATUS NetQueryDisplayInformation(const char * server_name /* [in] [unique] */,
551 uint32_t level /* [in] */,
552 uint32_t idx /* [in] */,
553 uint32_t entries_requested /* [in] */,
554 uint32_t prefmaxlen /* [in] */,
555 uint32_t *entries_read /* [out] [ref] */,
556 void **buffer /* [out] [noprint,ref] */);
558 /************************************************************//**
562 * @brief Create Domain Group
564 * @param[in] server_name The server name to connect to
565 * @param[in] level The level used for the new group creation
566 * @param[in] buf The buffer containing the group structure
567 * @param[out] parm_err The returned parameter error number if any
568 * @return NET_API_STATUS
570 * example group/group_add.c
571 ***************************************************************/
573 NET_API_STATUS NetGroupAdd(const char * server_name /* [in] */,
574 uint32_t level /* [in] */,
575 uint8_t *buf /* [in] [ref] */,
576 uint32_t *parm_err /* [out] [ref] */);
578 /************************************************************//**
582 * @brief Delete Domain Group
584 * @param[in] server_name The server name to connect to
585 * @param[in] group_name The name of the group that is going to be deleted
586 * @return NET_API_STATUS
588 * example group/group_del.c
589 ***************************************************************/
591 NET_API_STATUS NetGroupDel(const char * server_name /* [in] */,
592 const char * group_name /* [in] */);
594 /************************************************************//**
598 * @brief Set Domain Group Information
600 * @param[in] server_name The server name to connect to
601 * @param[in] group_name The name of the group that is going to be modified
602 * @param[in] level The level defining the structure type in buf
603 * @param[in] buf The buffer containing a GROUP_INFO_X structure
604 * @param[out] parm_err The returned parameter error number if any
605 * @return NET_API_STATUS
607 * example group/group_setinfo.c
608 ***************************************************************/
610 NET_API_STATUS NetGroupSetInfo(const char * server_name /* [in] */,
611 const char * group_name /* [in] */,
612 uint32_t level /* [in] */,
613 uint8_t *buf /* [in] [ref] */,
614 uint32_t *parm_err /* [out] [ref] */);
616 /************************************************************//**
620 * @brief Get Domain Group Information
622 * @param[in] server_name The server name to connect to
623 * @param[in] group_name The name of the group that is going to be modified
624 * @param[in] level The level defining the requested GROUP_INFO_X structure
625 * @param[out] buf The buffer containing a GROUP_INFO_X structure
626 * @return NET_API_STATUS
628 * example group/group_del.c
629 ***************************************************************/
631 NET_API_STATUS NetGroupGetInfo(const char * server_name /* [in] */,
632 const char * group_name /* [in] */,
633 uint32_t level /* [in] */,
634 uint8_t **buf /* [out] [ref] */);
636 /************************************************************//**
640 * @brief Add existing User to existing Domain Group
642 * @param[in] server_name The server name to connect to
643 * @param[in] group_name The name of the group that is going to be modified
644 * @param[in] user_name The name of the user that is going to be added to the
646 * @return NET_API_STATUS
648 * example group/group_adduser.c
649 ***************************************************************/
651 NET_API_STATUS NetGroupAddUser(const char * server_name /* [in] */,
652 const char * group_name /* [in] */,
653 const char * user_name /* [in] */);
655 /************************************************************//**
659 * @brief Remove User from Domain Group
661 * @param[in] server_name The server name to connect to
662 * @param[in] group_name The name of the group that is going to be modified
663 * @param[in] user_name The name of the user that is going to be removed from
665 * @return NET_API_STATUS
667 * example group/group_deluser.c
668 ***************************************************************/
670 NET_API_STATUS NetGroupDelUser(const char * server_name /* [in] */,
671 const char * group_name /* [in] */,
672 const char * user_name /* [in] */);
674 /************************************************************//**
678 * @brief Create Local Group
680 * @param[in] server_name The server name to connect to
681 * @param[in] level The level used for the new group creation
682 * @param[in] buf The buffer containing the group structure
683 * @param[out] parm_err The returned parameter error number if any
684 * @return NET_API_STATUS
686 * example localgroup/localgroup_add.c
687 ***************************************************************/
689 NET_API_STATUS NetLocalGroupAdd(const char * server_name /* [in] */,
690 uint32_t level /* [in] */,
691 uint8_t *buf /* [in] [ref] */,
692 uint32_t *parm_err /* [out] [ref] */);
694 /************************************************************//**
698 * @brief Delete Local Group
700 * @param[in] server_name The server name to connect to
701 * @param[in] group_name The name of the group that is going to be deleted
702 * @return NET_API_STATUS
704 * example localgroup/localgroup_del.c
705 ***************************************************************/
708 NET_API_STATUS NetLocalGroupDel(const char * server_name /* [in] */,
709 const char * group_name /* [in] */);
711 /************************************************************//**
713 * NetLocalGroupGetInfo
715 * @brief Get Local Group Information
717 * @param[in] server_name The server name to connect to
718 * @param[in] group_name The name of the group that is going to be queried
719 * @param[in] level The level defining the requested LOCALGROUP_INFO_X structure
720 * @param[out] buf The buffer containing a LOCALGROUP_INFO_X structure
721 * @return NET_API_STATUS
723 * example localgroup/localgroup_getinfo.c
724 ***************************************************************/
726 NET_API_STATUS NetLocalGroupGetInfo(const char * server_name /* [in] */,
727 const char * group_name /* [in] */,
728 uint32_t level /* [in] */,
729 uint8_t **buf /* [out] [ref] */);
731 /************************************************************//**
733 * NetLocalGroupSetInfo
735 * @brief Set Local Group Information
737 * @param[in] server_name The server name to connect to
738 * @param[in] group_name The name of the group that is going to be modified
739 * @param[in] level The level defining the requested LOCALGROUP_INFO_X structure
740 * @param[in] buf The buffer containing a LOCALGROUP_INFO_X structure
741 * @param[out] parm_err The returned parameter error number if any
742 * @return NET_API_STATUS
744 * example localgroup/localgroup_setinfo.c
745 ***************************************************************/
748 NET_API_STATUS NetLocalGroupSetInfo(const char * server_name /* [in] */,
749 const char * group_name /* [in] */,
750 uint32_t level /* [in] */,
751 uint8_t *buf /* [in] [ref] */,
752 uint32_t *parm_err /* [out] [ref] */);
754 /************************************************************//**
758 * @brief Query remote Time of Day
760 * @param[in] server_name The server name to connect to
761 * @param[out] buf The buffer containing a TIME_OF_DAY_INFO structure
762 * @return NET_API_STATUS
764 * example server/remote_tod.c
765 ***************************************************************/
767 NET_API_STATUS NetRemoteTOD(const char * server_name /* [in] */,
768 uint8_t **buf /* [out] [ref] */);