xref: /titanic_44/usr/src/lib/smbsrv/libmlsvc/common/samlib.h (revision 3c112a2b34403220c06c3e2fcac403358cfba168)
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  */
25 
26 #ifndef _SAMLIB_H
27 #define	_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 DWORD sam_create_trust_account(char *, char *);
65 DWORD sam_create_account(char *, char *, char *, DWORD);
66 DWORD sam_remove_trust_account(char *, char *);
67 DWORD sam_delete_account(char *, char *, char *);
68 DWORD sam_get_local_domains(char *, char *);
69 DWORD sam_check_user(char *, char *, char *);
70 
71 /*
72  * samr_open.c
73  */
74 int samr_open(char *, char *, char *, DWORD, mlsvc_handle_t *);
75 int samr_connect(char *, char *, char *, DWORD, mlsvc_handle_t *);
76 int samr_close_handle(mlsvc_handle_t *);
77 DWORD samr_open_domain(mlsvc_handle_t *, DWORD, struct samr_sid *,
78     mlsvc_handle_t *);
79 DWORD samr_open_user(mlsvc_handle_t *, DWORD, DWORD, mlsvc_handle_t *);
80 DWORD samr_delete_user(mlsvc_handle_t *);
81 int samr_open_group(mlsvc_handle_t *, DWORD, mlsvc_handle_t *);
82 DWORD samr_create_user(mlsvc_handle_t *, char *, DWORD, DWORD *,
83     mlsvc_handle_t *);
84 
85 /*
86  * samr_lookup.c
87  */
88 union samr_user_info {
89 	struct info1 {
90 		char *username;
91 		char *fullname;
92 		DWORD group_rid;
93 		char *description;
94 		char *unknown;
95 	} info1;
96 
97 	struct info6 {
98 		char *username;
99 		char *fullname;
100 	} info6;
101 
102 	struct info7 {
103 		char *username;
104 	} info7;
105 
106 	struct info8 {
107 		char *fullname;
108 	} info8;
109 
110 	struct info9 {
111 		DWORD group_rid;
112 	} info9;
113 
114 	struct info16 {
115 		DWORD unknown;
116 	} info16;
117 };
118 
119 
120 smb_sid_t *samr_lookup_domain(mlsvc_handle_t *, char *);
121 DWORD samr_enum_local_domains(mlsvc_handle_t *);
122 uint32_t samr_lookup_domain_names(mlsvc_handle_t *, char *, smb_account_t *);
123 int samr_query_user_info(mlsvc_handle_t *, WORD, union samr_user_info *);
124 DWORD samr_get_user_pwinfo(mlsvc_handle_t *);
125 
126 typedef struct oem_password {
127 	BYTE data[512];
128 	DWORD length;
129 } oem_password_t;
130 
131 
132 int sam_oem_password(oem_password_t *, unsigned char *, unsigned char *);
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 
139 #endif /* _SAMLIB_H */
140