xref: /illumos-gate/usr/src/lib/smbsrv/libmlsvc/common/samlib.h (revision 9b4e3ac25d882519cad3fc11f0c53b07f4e60536)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SMBSRV_SAMLIB_H
27 #define	_SMBSRV_SAMLIB_H
28 
29 /*
30  * Prototypes for the SAM library and RPC client side library interface.
31  * There are two levels of interface defined here: sam_xxx and samr_xxx.
32  * The sam_xxx functions provide a high level interface which make
33  * multiple RPC calls and do all the work necessary to obtain and return
34  * the requested information. The samr_xxx functions provide a low level
35  * interface in which each function maps to a single underlying RPC.
36  */
37 
38 #include <smbsrv/ndl/samrpc.ndl>
39 
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /*
46  * Account Control Flags
47  * Use in SAMR Query Display Information RPC
48  */
49 #define	ACF_DISABLED	0x001	/* account disable */
50 #define	ACF_HOMEDIRREQ	0x002	/* home dir required */
51 #define	ACF_PWDNOTREQ	0x004	/* password not required */
52 #define	ACF_TEMPDUP	0x008	/* temp dup account */
53 #define	ACF_NORMUSER	0x010	/* normal user */
54 #define	ACF_MNS		0x020	/* MNS account */
55 #define	ACF_DOMTRUST	0x040	/* Domain trust acct */
56 #define	ACF_WSTRUST	0x080	/* WKST trust acct */
57 #define	ACF_SVRTRUST	0x100	/* Server trust acct */
58 #define	ACF_PWDNOEXP	0x200	/* password no expire */
59 #define	ACF_AUTOLOCK	0x400	/* acct auto lock */
60 
61 /*
62  * samlib.c
63  */
64 int sam_lookup_user_info(char *server, char *domain_name, char *username,
65     smb_userinfo_t *user_info);
66 
67 DWORD sam_create_trust_account(char *server, char *domain,
68     smb_auth_info_t *auth);
69 
70 DWORD sam_create_account(char *server, char *domain_name, char *account_name,
71     smb_auth_info_t *auth, DWORD account_flags);
72 
73 DWORD sam_remove_trust_account(char *server, char *domain);
74 
75 DWORD sam_delete_account(char *server, char *domain_name, char *account_name);
76 
77 DWORD sam_lookup_name(char *server, char *domain_name, char *account_name,
78     DWORD *rid_ret);
79 
80 DWORD sam_get_local_domains(char *server, char *domain_name);
81 DWORD sam_check_user(char *server, char *domain_name, char *account_name);
82 
83 /*
84  * samr_open.c
85  */
86 int samr_open(char *server, char *domain, char *username,
87     DWORD access_mask, mlsvc_handle_t *samr_handle);
88 
89 int samr_connect(char *server, char *domain, char *username,
90     DWORD access_mask, mlsvc_handle_t *samr_handle);
91 
92 int samr_close_handle(mlsvc_handle_t *handle);
93 
94 DWORD samr_open_domain(mlsvc_handle_t *samr_handle, DWORD access_mask,
95     struct samr_sid *sid, mlsvc_handle_t *domain_handle);
96 
97 DWORD samr_open_user(mlsvc_handle_t *domain_handle, DWORD access_mask,
98     DWORD rid, mlsvc_handle_t *user_handle);
99 
100 DWORD samr_delete_user(mlsvc_handle_t *user_handle);
101 
102 int samr_open_group(mlsvc_handle_t *domain_handle, DWORD rid,
103     mlsvc_handle_t *group_handle);
104 
105 DWORD samr_create_user(mlsvc_handle_t *domain_handle, char *username,
106     DWORD account_flags, DWORD *rid, mlsvc_handle_t *user_handle);
107 
108 /*
109  * samr_lookup.c
110  */
111 union samr_user_info {
112 	struct info1 {
113 		char *username;
114 		char *fullname;
115 		DWORD group_rid;
116 		char *description;
117 		char *unknown;
118 	} info1;
119 
120 	struct info6 {
121 		char *username;
122 		char *fullname;
123 	} info6;
124 
125 	struct info7 {
126 		char *username;
127 	} info7;
128 
129 	struct info8 {
130 		char *fullname;
131 	} info8;
132 
133 	struct info9 {
134 		DWORD group_rid;
135 	} info9;
136 
137 	struct info16 {
138 		DWORD unknown;
139 	} info16;
140 };
141 
142 
143 int samr_lookup_domain(mlsvc_handle_t *samr_handle, char *domain_name,
144     smb_userinfo_t *user_info);
145 
146 DWORD samr_enum_local_domains(mlsvc_handle_t *samr_handle);
147 
148 DWORD samr_lookup_domain_names(mlsvc_handle_t *domain_handle, char *name,
149     smb_userinfo_t *user_info);
150 
151 int samr_query_user_info(mlsvc_handle_t *user_handle, WORD switch_value,
152     union samr_user_info *user_info);
153 
154 int samr_query_user_groups(mlsvc_handle_t *user_handle,
155     smb_userinfo_t *user_info);
156 
157 DWORD samr_get_user_pwinfo(mlsvc_handle_t *user_handle);
158 
159 typedef struct oem_password {
160 	BYTE data[512];
161 	DWORD length;
162 } oem_password_t;
163 
164 
165 int sam_oem_password(oem_password_t *oem_password, unsigned char *new_password,
166     unsigned char *old_password);
167 
168 #ifdef __cplusplus
169 }
170 #endif
171 
172 
173 #endif /* _SMBSRV_SAMLIB_H */
174