1 #ifndef _INCLUDE_ADS_H_
2 #define _INCLUDE_ADS_H_
4 header for ads (active directory) library routines
6 basically this is a wrapper around ldap
10 * This should be under the HAVE_KRB5 flag but since they're used
11 * in lp_kerberos_method(), they ned to be always available
13 #define KERBEROS_VERIFY_SECRETS 0
14 #define KERBEROS_VERIFY_SYSTEM_KEYTAB 1
15 #define KERBEROS_VERIFY_DEDICATED_KEYTAB 2
16 #define KERBEROS_VERIFY_SECRETS_AND_KEYTAB 3
19 * If you add any entries to the above, please modify the below expressions
20 * so they remain accurate.
22 #define USE_KERBEROS_KEYTAB (KERBEROS_VERIFY_SECRETS != lp_kerberos_method())
23 #define USE_SYSTEM_KEYTAB \
24 ((KERBEROS_VERIFY_SECRETS_AND_KEYTAB == lp_kerberos_method()) || \
25 (KERBEROS_VERIFY_SYSTEM_KEYTAB == lp_kerberos_method()))
27 enum wb_posix_mapping
{
28 WB_POSIX_MAP_UNKNOWN
= -1,
29 WB_POSIX_MAP_TEMPLATE
= 0,
31 WB_POSIX_MAP_SFU20
= 2,
32 WB_POSIX_MAP_RFC2307
= 3,
33 WB_POSIX_MAP_UNIXINFO
= 4
36 /* there are 5 possible types of errors the ads subsystem can produce */
37 enum ads_error_type
{ENUM_ADS_ERROR_KRB5
, ENUM_ADS_ERROR_GSS
,
38 ENUM_ADS_ERROR_LDAP
, ENUM_ADS_ERROR_SYSTEM
, ENUM_ADS_ERROR_NT
};
41 enum ads_error_type error_type
;
46 /* For error_type = ENUM_ADS_ERROR_GSS minor_status describe GSS API error */
47 /* Where rc represents major_status of GSS API error */
53 struct ads_saslwrap_ops
{
55 ADS_STATUS (*wrap
)(struct ads_struct
*, uint8
*buf
, uint32 len
);
56 ADS_STATUS (*unwrap
)(struct ads_struct
*);
57 void (*disconnect
)(struct ads_struct
*);
60 enum ads_saslwrap_type
{
61 ADS_SASLWRAP_TYPE_PLAIN
= 1,
62 ADS_SASLWRAP_TYPE_SIGN
= 2,
63 ADS_SASLWRAP_TYPE_SEAL
= 4
66 typedef struct ads_struct
{
67 int is_mine
; /* do I own this structure's memory? */
69 /* info needed to find the server */
74 int foreign
; /* set to 1 if connecting to a foreign
76 bool gc
; /* Is this a global catalog server? */
79 /* info needed to authenticate */
92 /* info derived from the servers config */
94 uint32 flags
; /* cldap flags identifying the services. */
97 char *ldap_server_name
;
98 char *server_site_name
;
99 char *client_site_name
;
105 /* info about the current LDAP connection */
109 struct sockaddr_storage ss
; /* the ip of the active connection, if any */
110 time_t last_attempt
; /* last attempt to reconnect */
113 enum ads_saslwrap_type wrap_type
;
115 #ifdef HAVE_LDAP_SASL_WRAPPING
116 Sockbuf_IO_Desc
*sbiod
; /* lowlevel state for LDAP wrapping */
117 #endif /* HAVE_LDAP_SASL_WRAPPING */
119 const struct ads_saslwrap_ops
*wrap_ops
;
120 void *wrap_private_data
;
125 #define ADS_SASL_WRAPPING_IN_MAX_WRAPPED 0x0FFFFFFF
134 #define ADS_SASL_WRAPPING_OUT_MAX_WRAPPED 0x00A00000
135 uint32 max_unwrapped
;
141 #endif /* HAVE_LDAP */
144 /* used to remember the names of the posix attributes in AD */
145 /* see the rfc2307 & sfu nss backends */
147 struct posix_schema
{
148 char *posix_homedir_attr
;
149 char *posix_shell_attr
;
150 char *posix_uidnumber_attr
;
151 char *posix_gidnumber_attr
;
152 char *posix_gecos_attr
;
153 char *posix_uid_attr
;
159 typedef LDAPMod
**ADS_MODLIST
;
161 typedef void **ADS_MODLIST
;
164 /* macros to simplify error returning */
165 #define ADS_ERROR(rc) ADS_ERROR_LDAP(rc)
166 #define ADS_ERROR_LDAP(rc) ads_build_error(ENUM_ADS_ERROR_LDAP, rc, 0)
167 #define ADS_ERROR_SYSTEM(rc) ads_build_error(ENUM_ADS_ERROR_SYSTEM, rc?rc:EINVAL, 0)
168 #define ADS_ERROR_KRB5(rc) ads_build_error(ENUM_ADS_ERROR_KRB5, rc, 0)
169 #define ADS_ERROR_GSS(rc, minor) ads_build_error(ENUM_ADS_ERROR_GSS, rc, minor)
170 #define ADS_ERROR_NT(rc) ads_build_nt_error(ENUM_ADS_ERROR_NT,rc)
172 #define ADS_ERR_OK(status) ((status.error_type == ENUM_ADS_ERROR_NT) ? NT_STATUS_IS_OK(status.err.nt_status):(status.err.rc == 0))
173 #define ADS_SUCCESS ADS_ERROR(0)
175 #define ADS_ERROR_HAVE_NO_MEMORY(x) do { \
177 return ADS_ERROR(LDAP_NO_MEMORY);\
182 /* time between reconnect attempts */
183 #define ADS_RECONNECT_TIME 5
185 /* ldap control oids */
186 #define ADS_PAGE_CTL_OID "1.2.840.113556.1.4.319"
187 #define ADS_NO_REFERRALS_OID "1.2.840.113556.1.4.1339"
188 #define ADS_SERVER_SORT_OID "1.2.840.113556.1.4.473"
189 #define ADS_PERMIT_MODIFY_OID "1.2.840.113556.1.4.1413"
190 #define ADS_ASQ_OID "1.2.840.113556.1.4.1504"
191 #define ADS_EXTENDED_DN_OID "1.2.840.113556.1.4.529"
192 #define ADS_SD_FLAGS_OID "1.2.840.113556.1.4.801"
194 /* ldap attribute oids (Services for Unix 3.0, 3.5) */
195 #define ADS_ATTR_SFU_UIDNUMBER_OID "1.2.840.113556.1.6.18.1.310"
196 #define ADS_ATTR_SFU_GIDNUMBER_OID "1.2.840.113556.1.6.18.1.311"
197 #define ADS_ATTR_SFU_HOMEDIR_OID "1.2.840.113556.1.6.18.1.344"
198 #define ADS_ATTR_SFU_SHELL_OID "1.2.840.113556.1.6.18.1.312"
199 #define ADS_ATTR_SFU_GECOS_OID "1.2.840.113556.1.6.18.1.337"
200 #define ADS_ATTR_SFU_UID_OID "1.2.840.113556.1.6.18.1.309"
202 /* ldap attribute oids (Services for Unix 2.0) */
203 #define ADS_ATTR_SFU20_UIDNUMBER_OID "1.2.840.113556.1.4.7000.187.70"
204 #define ADS_ATTR_SFU20_GIDNUMBER_OID "1.2.840.113556.1.4.7000.187.71"
205 #define ADS_ATTR_SFU20_HOMEDIR_OID "1.2.840.113556.1.4.7000.187.106"
206 #define ADS_ATTR_SFU20_SHELL_OID "1.2.840.113556.1.4.7000.187.72"
207 #define ADS_ATTR_SFU20_GECOS_OID "1.2.840.113556.1.4.7000.187.97"
208 #define ADS_ATTR_SFU20_UID_OID "1.2.840.113556.1.4.7000.187.102"
211 /* ldap attribute oids (RFC2307) */
212 #define ADS_ATTR_RFC2307_UIDNUMBER_OID "1.3.6.1.1.1.1.0"
213 #define ADS_ATTR_RFC2307_GIDNUMBER_OID "1.3.6.1.1.1.1.1"
214 #define ADS_ATTR_RFC2307_HOMEDIR_OID "1.3.6.1.1.1.1.3"
215 #define ADS_ATTR_RFC2307_SHELL_OID "1.3.6.1.1.1.1.4"
216 #define ADS_ATTR_RFC2307_GECOS_OID "1.3.6.1.1.1.1.2"
217 #define ADS_ATTR_RFC2307_UID_OID "0.9.2342.19200300.100.1.1"
219 /* ldap bitwise searches */
220 #define ADS_LDAP_MATCHING_RULE_BIT_AND "1.2.840.113556.1.4.803"
221 #define ADS_LDAP_MATCHING_RULE_BIT_OR "1.2.840.113556.1.4.804"
223 /* UserFlags for userAccountControl */
224 #define UF_SCRIPT 0x00000001
225 #define UF_ACCOUNTDISABLE 0x00000002
226 #define UF_UNUSED_1 0x00000004
227 #define UF_HOMEDIR_REQUIRED 0x00000008
229 #define UF_LOCKOUT 0x00000010
230 #define UF_PASSWD_NOTREQD 0x00000020
231 #define UF_PASSWD_CANT_CHANGE 0x00000040
232 #define UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED 0x00000080
234 #define UF_TEMP_DUPLICATE_ACCOUNT 0x00000100
235 #define UF_NORMAL_ACCOUNT 0x00000200
236 #define UF_UNUSED_2 0x00000400
237 #define UF_INTERDOMAIN_TRUST_ACCOUNT 0x00000800
239 #define UF_WORKSTATION_TRUST_ACCOUNT 0x00001000
240 #define UF_SERVER_TRUST_ACCOUNT 0x00002000
241 #define UF_UNUSED_3 0x00004000
242 #define UF_UNUSED_4 0x00008000
244 #define UF_DONT_EXPIRE_PASSWD 0x00010000
245 #define UF_MNS_LOGON_ACCOUNT 0x00020000
246 #define UF_SMARTCARD_REQUIRED 0x00040000
247 #define UF_TRUSTED_FOR_DELEGATION 0x00080000
249 #define UF_NOT_DELEGATED 0x00100000
250 #define UF_USE_DES_KEY_ONLY 0x00200000
251 #define UF_DONT_REQUIRE_PREAUTH 0x00400000
252 #define UF_PASSWORD_EXPIRED 0x00800000
254 #define UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION 0x01000000
255 #define UF_NO_AUTH_DATA_REQUIRED 0x02000000
256 #define UF_UNUSED_8 0x04000000
257 #define UF_UNUSED_9 0x08000000
259 #define UF_UNUSED_10 0x10000000
260 #define UF_UNUSED_11 0x20000000
261 #define UF_UNUSED_12 0x40000000
262 #define UF_UNUSED_13 0x80000000
264 #define UF_MACHINE_ACCOUNT_MASK (\
265 UF_INTERDOMAIN_TRUST_ACCOUNT |\
266 UF_WORKSTATION_TRUST_ACCOUNT |\
267 UF_SERVER_TRUST_ACCOUNT \
270 #define UF_ACCOUNT_TYPE_MASK (\
271 UF_TEMP_DUPLICATE_ACCOUNT |\
273 UF_INTERDOMAIN_TRUST_ACCOUNT |\
274 UF_WORKSTATION_TRUST_ACCOUNT |\
275 UF_SERVER_TRUST_ACCOUNT \
278 #define UF_SETTABLE_BITS (\
281 UF_HOMEDIR_REQUIRED |\
284 UF_PASSWD_CANT_CHANGE |\
285 UF_ACCOUNT_TYPE_MASK | \
286 UF_DONT_EXPIRE_PASSWD | \
287 UF_MNS_LOGON_ACCOUNT |\
288 UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED |\
289 UF_SMARTCARD_REQUIRED |\
290 UF_TRUSTED_FOR_DELEGATION |\
292 UF_USE_DES_KEY_ONLY |\
293 UF_DONT_REQUIRE_PREAUTH \
297 #define ATYPE_NORMAL_ACCOUNT 0x30000000 /* 805306368 */
298 #define ATYPE_WORKSTATION_TRUST 0x30000001 /* 805306369 */
299 #define ATYPE_INTERDOMAIN_TRUST 0x30000002 /* 805306370 */
300 #define ATYPE_SECURITY_GLOBAL_GROUP 0x10000000 /* 268435456 */
301 #define ATYPE_DISTRIBUTION_GLOBAL_GROUP 0x10000001 /* 268435457 */
302 #define ATYPE_DISTRIBUTION_UNIVERSAL_GROUP ATYPE_DISTRIBUTION_GLOBAL_GROUP
303 #define ATYPE_SECURITY_LOCAL_GROUP 0x20000000 /* 536870912 */
304 #define ATYPE_DISTRIBUTION_LOCAL_GROUP 0x20000001 /* 536870913 */
306 #define ATYPE_ACCOUNT ATYPE_NORMAL_ACCOUNT /* 0x30000000 805306368 */
307 #define ATYPE_GLOBAL_GROUP ATYPE_SECURITY_GLOBAL_GROUP /* 0x10000000 268435456 */
308 #define ATYPE_LOCAL_GROUP ATYPE_SECURITY_LOCAL_GROUP /* 0x20000000 536870912 */
311 #define GROUP_TYPE_BUILTIN_LOCAL_GROUP 0x00000001
312 #define GROUP_TYPE_ACCOUNT_GROUP 0x00000002
313 #define GROUP_TYPE_RESOURCE_GROUP 0x00000004
314 #define GROUP_TYPE_UNIVERSAL_GROUP 0x00000008
315 #define GROUP_TYPE_APP_BASIC_GROUP 0x00000010
316 #define GROUP_TYPE_APP_QUERY_GROUP 0x00000020
317 #define GROUP_TYPE_SECURITY_ENABLED 0x80000000
319 #define GTYPE_SECURITY_BUILTIN_LOCAL_GROUP ( /* 0x80000005 -2147483643 */ \
320 GROUP_TYPE_BUILTIN_LOCAL_GROUP| \
321 GROUP_TYPE_RESOURCE_GROUP| \
322 GROUP_TYPE_SECURITY_ENABLED \
324 #define GTYPE_SECURITY_DOMAIN_LOCAL_GROUP ( /* 0x80000004 -2147483644 */ \
325 GROUP_TYPE_RESOURCE_GROUP| \
326 GROUP_TYPE_SECURITY_ENABLED \
328 #define GTYPE_SECURITY_GLOBAL_GROUP ( /* 0x80000002 -2147483646 */ \
329 GROUP_TYPE_ACCOUNT_GROUP| \
330 GROUP_TYPE_SECURITY_ENABLED \
332 #define GTYPE_SECURITY_UNIVERSAL_GROUP ( /* 0x80000008 -2147483656 */ \
333 GROUP_TYPE_UNIVERSAL_GROUP| \
334 GROUP_TYPE_SECURITY_ENABLED \
337 #define GTYPE_DISTRIBUTION_GLOBAL_GROUP 0x00000002 /* 2 */
338 #define GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP 0x00000004 /* 4 */
339 #define GTYPE_DISTRIBUTION_UNIVERSAL_GROUP 0x00000008 /* 8 */
341 #define ADS_PINGS 0x0000FFFF /* Ping response */
342 #define ADS_DNS_CONTROLLER 0x20000000 /* DomainControllerName is a DNS name*/
343 #define ADS_DNS_DOMAIN 0x40000000 /* DomainName is a DNS name */
344 #define ADS_DNS_FOREST 0x80000000 /* DnsForestName is a DNS name */
346 /* ads auth control flags */
347 #define ADS_AUTH_DISABLE_KERBEROS 0x0001
348 #define ADS_AUTH_NO_BIND 0x0002
349 #define ADS_AUTH_ANON_BIND 0x0004
350 #define ADS_AUTH_SIMPLE_BIND 0x0008
351 #define ADS_AUTH_ALLOW_NTLMSSP 0x0010
352 #define ADS_AUTH_SASL_SIGN 0x0020
353 #define ADS_AUTH_SASL_SEAL 0x0040
354 #define ADS_AUTH_SASL_FORCE 0x0080
355 #define ADS_AUTH_USER_CREDS 0x0100
357 /* Kerberos environment variable names */
358 #define KRB5_ENV_CCNAME "KRB5CCNAME"
360 #define WELL_KNOWN_GUID_COMPUTERS "AA312825768811D1ADED00C04FD8D5CD"
361 #define WELL_KNOWN_GUID_USERS "A9D1CA15768811D1ADED00C04FD8D5CD"
363 enum ads_extended_dn_flags
{
364 ADS_EXTENDED_DN_HEX_STRING
= 0,
365 ADS_EXTENDED_DN_STRING
= 1 /* not supported on win2k */
368 /* this is probably not very well suited to pass other controls generically but
369 * is good enough for the extended dn control where it is only used for atm */
377 #define ADS_EXTENDED_RIGHT_APPLY_GROUP_POLICY "edacfd8f-ffb3-11d1-b41d-00a0c968f939"
379 #define ADS_IGNORE_PRINCIPAL "not_defined_in_RFC4178@please_ignore"
381 /* Settings for the domainFunctionality attribute in the rootDSE */
383 #define DS_DOMAIN_FUNCTION_2000 0
384 #define DS_DOMAIN_FUCNTION_2003_MIXED 1
385 #define DS_DOMAIN_FUNCTION_2003 2
386 #define DS_DOMAIN_FUNCTION_2008 3
388 #endif /* _INCLUDE_ADS_H_ */