netapi: add NetLocalGroupGetInfo() to public headers.
[nivanova/samba-autobuild/.git] / source3 / lib / netapi / netapi.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  NetApi Support
4  *  Copyright (C) Guenther Deschner 2007-2008
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 #ifndef __LIB_NETAPI_H__
21 #define __LIB_NETAPI_H__
22
23 /****************************************************************
24  NET_API_STATUS
25 ****************************************************************/
26 typedef enum {
27         NET_API_STATUS_SUCCESS = 0
28 } NET_API_STATUS;
29
30 #define ERROR_MORE_DATA ( 234L )
31
32 /****************************************************************
33 ****************************************************************/
34
35 #ifndef _HEADER_misc
36
37 struct GUID {
38         uint32_t time_low;
39         uint16_t time_mid;
40         uint16_t time_hi_and_version;
41         uint8_t clock_seq[2];
42         uint8_t node[6];
43 };
44
45 #endif /* _HEADER_misc */
46
47 #ifndef _HEADER_libnetapi
48
49 #ifndef MAXSUBAUTHS
50 #define MAXSUBAUTHS 15 /* max sub authorities in a SID */
51 #endif
52
53 struct domsid {
54         uint8_t   sid_rev_num;
55         uint8_t   num_auths;
56         uint8_t   id_auth[6];
57         uint32_t  sub_auths[MAXSUBAUTHS];
58 };
59
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;
67         uint32_t flags;
68         const char * dc_site_name;
69         const char * client_site_name;
70 };
71
72 struct SERVER_INFO_1005 {
73         const char * sv1005_comment;
74 };
75
76 struct USER_INFO_0 {
77         const char * usri0_name;
78 };
79
80 struct USER_INFO_1 {
81         const char * usri1_name;
82         const char * usri1_password;
83         uint32_t usri1_password_age;
84         uint32_t usri1_priv;
85         const char * usri1_home_dir;
86         const char * usri1_comment;
87         uint32_t usri1_flags;
88         const char * usri1_script_path;
89 };
90
91 struct NET_DISPLAY_USER {
92         const char * usri1_name;
93         const char * usri1_comment;
94         uint32_t usri1_flags;
95         const char * usri1_full_name;
96         uint32_t usri1_user_id;
97         uint32_t usri1_next_index;
98 };
99
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;
106 };
107
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;
114 };
115
116 struct GROUP_INFO_0 {
117         const char * grpi0_name;
118 };
119
120 struct GROUP_INFO_1 {
121         const char * grpi1_name;
122         const char * grpi1_comment;
123 };
124
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;
130 };
131
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;
137 };
138
139 struct GROUP_INFO_1002 {
140         const char * grpi1002_comment;
141 };
142
143 struct GROUP_INFO_1005 {
144         uint32_t grpi1005_attributes;
145 };
146
147 struct LOCALGROUP_INFO_0 {
148         const char * lgrpi0_name;
149 };
150
151 struct LOCALGROUP_INFO_1 {
152         const char * lgrpi1_name;
153         const char * lgrpi1_comment;
154 };
155
156 struct LOCALGROUP_INFO_1002 {
157         const char * lgrpi1002_comment;
158 };
159
160 #endif /* _HEADER_libnetapi */
161
162 /****************************************************************
163 ****************************************************************/
164
165 struct libnetapi_ctx {
166         char *debuglevel;
167         char *error_string;
168         char *username;
169         char *workgroup;
170         char *password;
171         char *krb5_cc_env;
172         int use_kerberos;
173 };
174
175 /****************************************************************
176 ****************************************************************/
177
178 NET_API_STATUS libnetapi_init(struct libnetapi_ctx **ctx);
179
180 /****************************************************************
181 ****************************************************************/
182
183 NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx);
184
185 /****************************************************************
186 ****************************************************************/
187
188 NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx);
189
190 /****************************************************************
191 ****************************************************************/
192
193 NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx,
194                                         const char *debuglevel);
195
196 /****************************************************************
197 ****************************************************************/
198
199 NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
200                                       const char *username);
201
202 /****************************************************************
203 ****************************************************************/
204
205 NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx,
206                                       const char *password);
207
208 /****************************************************************
209 ****************************************************************/
210
211 NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
212                                        const char *workgroup);
213
214 /****************************************************************
215 ****************************************************************/
216
217 NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx);
218
219 /****************************************************************
220 ****************************************************************/
221
222 const char *libnetapi_errstr(NET_API_STATUS status);
223
224 /****************************************************************
225 ****************************************************************/
226
227 const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx,
228                                        NET_API_STATUS status);
229
230
231 /****************************************************************
232  NetApiBufferFree
233 ****************************************************************/
234
235 NET_API_STATUS NetApiBufferFree(void *buffer);
236
237 /************************************************************//**
238  *
239  * NetJoinDomain
240  *
241  * @brief Join a computer to a domain or workgroup
242  *
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
246  * in (AD only)
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
251  *
252  * example netdomjoin/netdomjoin.c
253  ***************************************************************/
254
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] */);
261
262 /************************************************************//**
263  *
264  * NetUnjoinDomain
265  *
266  * @brief Unjoin a computer from a domain or workgroup
267  *
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
273  *
274  ***************************************************************/
275
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] */);
280
281 /************************************************************//**
282  *
283  * NetGetJoinInformation
284  *
285  * @brief Unjoin a computer from a domain or workgroup
286  *
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
291  *
292  * example netdomjoin-gui/netdomjoin-gui.c
293  *
294  ***************************************************************/
295
296 NET_API_STATUS NetGetJoinInformation(const char * server_name /* [in] */,
297                                      const char * *name_buffer /* [out] [ref] */,
298                                      uint16_t *name_type /* [out] [ref] */);
299
300 /************************************************************//**
301  *
302  * NetGetJoinableOUs
303  *
304  * @brief Query for the list of joinable organizational Units that can be used
305  * for joining AD
306  *
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
314  *
315  * example netdomjoin-gui/netdomjoin-gui.c
316  *
317  ***************************************************************/
318
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] */);
325
326 /************************************************************//**
327  *
328  * NetServerGetInfo
329  *
330  * @brief Get Information on a server
331  *
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
336  *
337  ***************************************************************/
338
339 NET_API_STATUS NetServerGetInfo(const char * server_name /* [in] */,
340                                 uint32_t level /* [in] */,
341                                 uint8_t **buffer /* [out] [ref] */);
342
343 /************************************************************//**
344  *
345  * NetServerSetInfo
346  *
347  * @brief Get Information on a server
348  *
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
354  *
355  ***************************************************************/
356
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] */);
361
362 /************************************************************//**
363  *
364  * NetGetDCName
365  *
366  * @brief Query for the PDC for a given domain
367  *
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
372  *
373  * example getdc/getdc.c
374  ***************************************************************/
375
376 NET_API_STATUS NetGetDCName(const char * server_name /* [in] */,
377                             const char * domain_name /* [in] */,
378                             uint8_t **buffer /* [out] [ref] */);
379
380 /************************************************************//**
381  *
382  * NetGetAnyDCName
383  *
384  * @brief Query for any DC for a given domain
385  *
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
390  *
391  * example getdc/getdc.c
392  ***************************************************************/
393
394 NET_API_STATUS NetGetAnyDCName(const char * server_name /* [in] */,
395                                const char * domain_name /* [in] */,
396                                uint8_t **buffer /* [out] [ref] */);
397
398
399 /************************************************************//**
400  *
401  * DsGetDcName
402  *
403  * @brief Lookup a DC for a given domain and return information structure
404  *
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
412  *
413  * example dsgetdc/dsgetdc.c
414  ***************************************************************/
415
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] */);
422
423 /************************************************************//**
424  *
425  * NetUserAdd
426  *
427  * @brief Create a user on a given server
428  *
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
434  * structure
435  * @return NET_API_STATUS
436  *
437  * example user/user_add.c
438  ***************************************************************/
439
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] */);
444
445 /************************************************************//**
446  *
447  * NetUserDel
448  *
449  * @brief Delete a user on a given server
450  *
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
454  *
455  * example user/user_del.c
456  ***************************************************************/
457
458 NET_API_STATUS NetUserDel(const char * server_name /* [in] */,
459                           const char * user_name /* [in] */);
460
461 /************************************************************//**
462  *
463  * NetUserEnum
464  *
465  * @brief Enumerate accounts on a server
466  *
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
476  * operations
477  * @return NET_API_STATUS
478  *
479  * example user/user_enum.c
480  ***************************************************************/
481
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] */);
490
491 /************************************************************//**
492  *
493  * NetQueryDisplayInformation
494  *
495  * @brief Enumerate accounts on a server
496  *
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
505  *
506  * example user/user_dispinfo.c
507  ***************************************************************/
508
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] */);
516
517 /************************************************************//**
518  *
519  * NetGroupAdd
520  *
521  * @brief Create Domain Group
522  *
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
528  *
529  * example group/group_add.c
530  ***************************************************************/
531
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] */);
536
537 /************************************************************//**
538  *
539  * NetGroupDel
540  *
541  * @brief Delete Domain Group
542  *
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
546  *
547  * example group/group_del.c
548  ***************************************************************/
549
550 NET_API_STATUS NetGroupDel(const char * server_name /* [in] */,
551                            const char * group_name /* [in] */);
552
553 /************************************************************//**
554  *
555  * NetGroupSetInfo
556  *
557  * @brief Set Domain Group Information
558  *
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
565  *
566  * example group/group_setinfo.c
567  ***************************************************************/
568
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] */);
574
575 /************************************************************//**
576  *
577  * NetGroupGetInfo
578  *
579  * @brief Get Domain Group Information
580  *
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
586  *
587  * example group/group_del.c
588  ***************************************************************/
589
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] */);
594
595 /************************************************************//**
596  *
597  * NetGroupAddUser
598  *
599  * @brief Add existing User to existing Domain Group
600  *
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
604  * group
605  * @return NET_API_STATUS
606  *
607  * example group/group_adduser.c
608  ***************************************************************/
609
610 NET_API_STATUS NetGroupAddUser(const char * server_name /* [in] */,
611                                const char * group_name /* [in] */,
612                                const char * user_name /* [in] */);
613
614 /************************************************************//**
615  *
616  * NetGroupDelUser
617  *
618  * @brief Remove User from Domain Group
619  *
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
623  * the group
624  * @return NET_API_STATUS
625  *
626  * example group/group_deluser.c
627  ***************************************************************/
628
629 NET_API_STATUS NetGroupDelUser(const char * server_name /* [in] */,
630                                const char * group_name /* [in] */,
631                                const char * user_name /* [in] */);
632
633 /************************************************************//**
634  *
635  * NetLocalGroupAdd
636  *
637  * @brief Create Local Group
638  *
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
644  *
645  * example localgroup/localgroup_add.c
646  ***************************************************************/
647
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] */);
652
653 /************************************************************//**
654  *
655  * NetLocalGroupDel
656  *
657  * @brief Delete Local Group
658  *
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
662  *
663  * example localgroup/localgroup_del.c
664  ***************************************************************/
665
666
667 NET_API_STATUS NetLocalGroupDel(const char * server_name /* [in] */,
668                                 const char * group_name /* [in] */);
669
670 /************************************************************//**
671  *
672  * NetLocalGroupGetInfo
673  *
674  * @brief Get Local Group Information
675  *
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
681  *
682  * example localgroup/localgroup_getinfo.c
683  ***************************************************************/
684
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] */);
689 #endif