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
9 #include "../libds/common/flags.h"
12 * This should be under the HAVE_KRB5 flag but since they're used
13 * in lp_kerberos_method(), they ned to be always available
15 #define KERBEROS_VERIFY_SECRETS 0
16 #define KERBEROS_VERIFY_SYSTEM_KEYTAB 1
17 #define KERBEROS_VERIFY_DEDICATED_KEYTAB 2
18 #define KERBEROS_VERIFY_SECRETS_AND_KEYTAB 3
21 * If you add any entries to the above, please modify the below expressions
22 * so they remain accurate.
24 #define USE_KERBEROS_KEYTAB (KERBEROS_VERIFY_SECRETS != lp_kerberos_method())
25 #define USE_SYSTEM_KEYTAB \
26 ((KERBEROS_VERIFY_SECRETS_AND_KEYTAB == lp_kerberos_method()) || \
27 (KERBEROS_VERIFY_SYSTEM_KEYTAB == lp_kerberos_method()))
29 #define TOK_ID_KRB_AP_REQ ((const uint8_t *)"\x01\x00")
30 #define TOK_ID_KRB_AP_REP ((const uint8_t *)"\x02\x00")
31 #define TOK_ID_KRB_ERROR ((const uint8_t *)"\x03\x00")
32 #define TOK_ID_GSS_GETMIC ((const uint8_t *)"\x01\x01")
33 #define TOK_ID_GSS_WRAP ((const uint8_t *)"\x02\x01")
35 enum wb_posix_mapping
{
36 WB_POSIX_MAP_UNKNOWN
= -1,
37 WB_POSIX_MAP_TEMPLATE
= 0,
39 WB_POSIX_MAP_SFU20
= 2,
40 WB_POSIX_MAP_RFC2307
= 3,
41 WB_POSIX_MAP_UNIXINFO
= 4
44 /* there are 5 possible types of errors the ads subsystem can produce */
45 enum ads_error_type
{ENUM_ADS_ERROR_KRB5
, ENUM_ADS_ERROR_GSS
,
46 ENUM_ADS_ERROR_LDAP
, ENUM_ADS_ERROR_SYSTEM
, ENUM_ADS_ERROR_NT
};
49 enum ads_error_type error_type
;
54 /* For error_type = ENUM_ADS_ERROR_GSS minor_status describe GSS API error */
55 /* Where rc represents major_status of GSS API error */
61 struct ads_saslwrap_ops
{
63 ADS_STATUS (*wrap
)(struct ads_struct
*, uint8
*buf
, uint32 len
);
64 ADS_STATUS (*unwrap
)(struct ads_struct
*);
65 void (*disconnect
)(struct ads_struct
*);
68 enum ads_saslwrap_type
{
69 ADS_SASLWRAP_TYPE_PLAIN
= 1,
70 ADS_SASLWRAP_TYPE_SIGN
= 2,
71 ADS_SASLWRAP_TYPE_SEAL
= 4
74 typedef struct ads_struct
{
75 int is_mine
; /* do I own this structure's memory? */
77 /* info needed to find the server */
82 int foreign
; /* set to 1 if connecting to a foreign
84 bool gc
; /* Is this a global catalog server? */
87 /* info needed to authenticate */
100 /* info derived from the servers config */
102 uint32 flags
; /* cldap flags identifying the services. */
105 char *ldap_server_name
;
106 char *server_site_name
;
107 char *client_site_name
;
114 /* info about the current LDAP connection */
118 struct sockaddr_storage ss
; /* the ip of the active connection, if any */
119 time_t last_attempt
; /* last attempt to reconnect */
122 enum ads_saslwrap_type wrap_type
;
124 #ifdef HAVE_LDAP_SASL_WRAPPING
125 Sockbuf_IO_Desc
*sbiod
; /* lowlevel state for LDAP wrapping */
126 #endif /* HAVE_LDAP_SASL_WRAPPING */
128 const struct ads_saslwrap_ops
*wrap_ops
;
129 void *wrap_private_data
;
134 #define ADS_SASL_WRAPPING_IN_MAX_WRAPPED 0x0FFFFFFF
143 #define ADS_SASL_WRAPPING_OUT_MAX_WRAPPED 0x00A00000
144 uint32 max_unwrapped
;
150 #endif /* HAVE_LDAP */
153 /* used to remember the names of the posix attributes in AD */
154 /* see the rfc2307 & sfu nss backends */
156 struct posix_schema
{
157 char *posix_homedir_attr
;
158 char *posix_shell_attr
;
159 char *posix_uidnumber_attr
;
160 char *posix_gidnumber_attr
;
161 char *posix_gecos_attr
;
162 char *posix_uid_attr
;
168 typedef LDAPMod
**ADS_MODLIST
;
170 typedef void **ADS_MODLIST
;
173 /* macros to simplify error returning */
174 #define ADS_ERROR(rc) ADS_ERROR_LDAP(rc)
175 #define ADS_ERROR_LDAP(rc) ads_build_error(ENUM_ADS_ERROR_LDAP, rc, 0)
176 #define ADS_ERROR_SYSTEM(rc) ads_build_error(ENUM_ADS_ERROR_SYSTEM, rc?rc:EINVAL, 0)
177 #define ADS_ERROR_KRB5(rc) ads_build_error(ENUM_ADS_ERROR_KRB5, rc, 0)
178 #define ADS_ERROR_GSS(rc, minor) ads_build_error(ENUM_ADS_ERROR_GSS, rc, minor)
179 #define ADS_ERROR_NT(rc) ads_build_nt_error(ENUM_ADS_ERROR_NT,rc)
181 #define ADS_ERR_OK(status) ((status.error_type == ENUM_ADS_ERROR_NT) ? NT_STATUS_IS_OK(status.err.nt_status):(status.err.rc == 0))
182 #define ADS_SUCCESS ADS_ERROR(0)
184 #define ADS_ERROR_HAVE_NO_MEMORY(x) do { \
186 return ADS_ERROR(LDAP_NO_MEMORY);\
191 /* time between reconnect attempts */
192 #define ADS_RECONNECT_TIME 5
194 /* ldap control oids */
195 #define ADS_PAGE_CTL_OID "1.2.840.113556.1.4.319"
196 #define ADS_NO_REFERRALS_OID "1.2.840.113556.1.4.1339"
197 #define ADS_SERVER_SORT_OID "1.2.840.113556.1.4.473"
198 #define ADS_PERMIT_MODIFY_OID "1.2.840.113556.1.4.1413"
199 #define ADS_ASQ_OID "1.2.840.113556.1.4.1504"
200 #define ADS_EXTENDED_DN_OID "1.2.840.113556.1.4.529"
201 #define ADS_SD_FLAGS_OID "1.2.840.113556.1.4.801"
203 /* ldap attribute oids (Services for Unix 3.0, 3.5) */
204 #define ADS_ATTR_SFU_UIDNUMBER_OID "1.2.840.113556.1.6.18.1.310"
205 #define ADS_ATTR_SFU_GIDNUMBER_OID "1.2.840.113556.1.6.18.1.311"
206 #define ADS_ATTR_SFU_HOMEDIR_OID "1.2.840.113556.1.6.18.1.344"
207 #define ADS_ATTR_SFU_SHELL_OID "1.2.840.113556.1.6.18.1.312"
208 #define ADS_ATTR_SFU_GECOS_OID "1.2.840.113556.1.6.18.1.337"
209 #define ADS_ATTR_SFU_UID_OID "1.2.840.113556.1.6.18.1.309"
211 /* ldap attribute oids (Services for Unix 2.0) */
212 #define ADS_ATTR_SFU20_UIDNUMBER_OID "1.2.840.113556.1.4.7000.187.70"
213 #define ADS_ATTR_SFU20_GIDNUMBER_OID "1.2.840.113556.1.4.7000.187.71"
214 #define ADS_ATTR_SFU20_HOMEDIR_OID "1.2.840.113556.1.4.7000.187.106"
215 #define ADS_ATTR_SFU20_SHELL_OID "1.2.840.113556.1.4.7000.187.72"
216 #define ADS_ATTR_SFU20_GECOS_OID "1.2.840.113556.1.4.7000.187.97"
217 #define ADS_ATTR_SFU20_UID_OID "1.2.840.113556.1.4.7000.187.102"
220 /* ldap attribute oids (RFC2307) */
221 #define ADS_ATTR_RFC2307_UIDNUMBER_OID "1.3.6.1.1.1.1.0"
222 #define ADS_ATTR_RFC2307_GIDNUMBER_OID "1.3.6.1.1.1.1.1"
223 #define ADS_ATTR_RFC2307_HOMEDIR_OID "1.3.6.1.1.1.1.3"
224 #define ADS_ATTR_RFC2307_SHELL_OID "1.3.6.1.1.1.1.4"
225 #define ADS_ATTR_RFC2307_GECOS_OID "1.3.6.1.1.1.1.2"
226 #define ADS_ATTR_RFC2307_UID_OID "0.9.2342.19200300.100.1.1"
228 /* ldap bitwise searches */
229 #define ADS_LDAP_MATCHING_RULE_BIT_AND "1.2.840.113556.1.4.803"
230 #define ADS_LDAP_MATCHING_RULE_BIT_OR "1.2.840.113556.1.4.804"
232 #define ADS_PINGS 0x0000FFFF /* Ping response */
233 #define ADS_DNS_CONTROLLER 0x20000000 /* DomainControllerName is a DNS name*/
234 #define ADS_DNS_DOMAIN 0x40000000 /* DomainName is a DNS name */
235 #define ADS_DNS_FOREST 0x80000000 /* DnsForestName is a DNS name */
237 /* ads auth control flags */
238 #define ADS_AUTH_DISABLE_KERBEROS 0x0001
239 #define ADS_AUTH_NO_BIND 0x0002
240 #define ADS_AUTH_ANON_BIND 0x0004
241 #define ADS_AUTH_SIMPLE_BIND 0x0008
242 #define ADS_AUTH_ALLOW_NTLMSSP 0x0010
243 #define ADS_AUTH_SASL_SIGN 0x0020
244 #define ADS_AUTH_SASL_SEAL 0x0040
245 #define ADS_AUTH_SASL_FORCE 0x0080
246 #define ADS_AUTH_USER_CREDS 0x0100
248 /* Kerberos environment variable names */
249 #define KRB5_ENV_CCNAME "KRB5CCNAME"
251 #define WELL_KNOWN_GUID_COMPUTERS "AA312825768811D1ADED00C04FD8D5CD"
252 #define WELL_KNOWN_GUID_USERS "A9D1CA15768811D1ADED00C04FD8D5CD"
254 enum ads_extended_dn_flags
{
255 ADS_EXTENDED_DN_HEX_STRING
= 0,
256 ADS_EXTENDED_DN_STRING
= 1 /* not supported on win2k */
259 /* this is probably not very well suited to pass other controls generically but
260 * is good enough for the extended dn control where it is only used for atm */
268 #define ADS_IGNORE_PRINCIPAL "not_defined_in_RFC4178@please_ignore"
270 #endif /* _INCLUDE_ADS_H_ */