xref: /illumos-gate/usr/src/lib/smbsrv/libmlsvc/common/samlib.h (revision bc1f688b4872ace323eaddbb1a6365d054e7bf56)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
25  */
26 
27 #ifndef _SAMLIB_H
28 #define	_SAMLIB_H
29 
30 /*
31  * Prototypes for the SAM library and RPC client side library interface.
32  * There are two levels of interface defined here: sam_xxx and samr_xxx.
33  * The sam_xxx functions provide a high level interface which make
34  * multiple RPC calls and do all the work necessary to obtain and return
35  * the requested information. The samr_xxx functions provide a low level
36  * interface in which each function maps to a single underlying RPC.
37  */
38 
39 #include <smbsrv/ndl/samrpc.ndl>
40 
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /*
47  * Account Control Flags
48  * Use in SAMR Query Display Information RPC
49  */
50 #define	ACF_DISABLED	0x001	/* account disable */
51 #define	ACF_HOMEDIRREQ	0x002	/* home dir required */
52 #define	ACF_PWDNOTREQ	0x004	/* password not required */
53 #define	ACF_TEMPDUP	0x008	/* temp dup account */
54 #define	ACF_NORMUSER	0x010	/* normal user */
55 #define	ACF_MNS		0x020	/* MNS account */
56 #define	ACF_DOMTRUST	0x040	/* Domain trust acct */
57 #define	ACF_WSTRUST	0x080	/* WKST trust acct */
58 #define	ACF_SVRTRUST	0x100	/* Server trust acct */
59 #define	ACF_PWDNOEXP	0x200	/* password no expire */
60 #define	ACF_AUTOLOCK	0x400	/* acct auto lock */
61 
62 /*
63  * samlib.c
64  */
65 DWORD sam_create_trust_account(char *, char *);
66 DWORD sam_create_account(char *, char *, char *, DWORD);
67 DWORD sam_remove_trust_account(char *, char *);
68 DWORD sam_delete_account(char *, char *, char *);
69 DWORD sam_get_local_domains(char *, char *);
70 DWORD sam_check_user(char *, char *, char *);
71 
72 /*
73  * samr_open.c
74  */
75 DWORD samr_open(char *, char *, char *, DWORD, mlsvc_handle_t *);
76 DWORD samr_connect(char *, char *, char *, DWORD, mlsvc_handle_t *);
77 void samr_close_handle(mlsvc_handle_t *);
78 DWORD samr_open_domain(mlsvc_handle_t *, DWORD, struct samr_sid *,
79     mlsvc_handle_t *);
80 DWORD samr_open_user(mlsvc_handle_t *, DWORD, DWORD, mlsvc_handle_t *);
81 DWORD samr_delete_user(mlsvc_handle_t *);
82 int samr_open_group(mlsvc_handle_t *, DWORD, mlsvc_handle_t *);
83 DWORD samr_create_user(mlsvc_handle_t *, char *, DWORD, DWORD *,
84     mlsvc_handle_t *);
85 
86 /*
87  * samr_lookup.c
88  */
89 union samr_user_info {
90 	struct info1 {
91 		char *username;
92 		char *fullname;
93 		DWORD group_rid;
94 		char *description;
95 		char *unknown;
96 	} info1;
97 
98 	struct info6 {
99 		char *username;
100 		char *fullname;
101 	} info6;
102 
103 	struct info7 {
104 		char *username;
105 	} info7;
106 
107 	struct info8 {
108 		char *fullname;
109 	} info8;
110 
111 	struct info9 {
112 		DWORD group_rid;
113 	} info9;
114 
115 	struct info16 {
116 		DWORD acct_ctrl;
117 	} info16;
118 };
119 
120 
121 smb_sid_t *samr_lookup_domain(mlsvc_handle_t *, char *);
122 DWORD samr_enum_local_domains(mlsvc_handle_t *);
123 uint32_t samr_lookup_domain_names(mlsvc_handle_t *, char *, smb_account_t *);
124 DWORD samr_query_user_info(mlsvc_handle_t *, WORD, union samr_user_info *);
125 DWORD samr_get_user_pwinfo(mlsvc_handle_t *);
126 
127 DWORD
128 samr_change_password(
129 	mlsvc_handle_t *handle,
130 	char *server,
131 	char *account,
132 	struct samr_encr_passwd *newpw,
133 	struct samr_encr_hash *oldpw);
134 
135 DWORD
136 samr_set_user_info(
137 	mlsvc_handle_t *user_handle,
138 	int info_level,
139 	void *info_buf);
140 
141 DWORD
142 netr_set_user_control(
143 	mlsvc_handle_t *user_handle,
144 	DWORD UserAccountControl);
145 
146 DWORD
147 netr_set_user_password(
148 	mlsvc_handle_t *user_handle,
149 	char *new_pw_clear);
150 
151 DWORD
152 netr_change_password(
153 	char *server,
154 	char *account,
155 	char *old_password,
156 	char *new_password);
157 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 
163 #endif /* _SAMLIB_H */
164