r12199: grabbing some low risk fixes from 3.0
[Samba.git] / source / include / ads.h
blobdecb823ea99a56f4c3f9911a2aa01dfcda742330
1 /*
2 header for ads (active directory) library routines
4 basically this is a wrapper around ldap
5 */
7 typedef struct {
8 void *ld; /* the active ldap structure */
9 struct in_addr ldap_ip; /* the ip of the active connection, if any */
10 time_t last_attempt; /* last attempt to reconnect */
11 int ldap_port;
13 int is_mine; /* do I own this structure's memory? */
15 /* info needed to find the server */
16 struct {
17 char *realm;
18 char *workgroup;
19 char *ldap_server;
20 char *ldap_uri;
21 int foreign; /* set to 1 if connecting to a foreign realm */
22 } server;
24 /* info needed to authenticate */
25 struct {
26 char *realm;
27 char *password;
28 char *user_name;
29 char *kdc_server;
30 unsigned flags;
31 int time_offset;
32 time_t expire;
33 } auth;
35 /* info derived from the servers config */
36 struct {
37 char *realm;
38 char *bind_path;
39 char *schema_path;
40 char *ldap_server_name;
41 time_t current_time;
42 } config;
44 /* info derived from the servers schema */
45 struct {
46 char *sfu_homedir_attr;
47 char *sfu_shell_attr;
48 char *sfu_uidnumber_attr;
49 char *sfu_gidnumber_attr;
50 } schema;
52 } ADS_STRUCT;
54 /* there are 5 possible types of errors the ads subsystem can produce */
55 enum ads_error_type {ENUM_ADS_ERROR_KRB5, ENUM_ADS_ERROR_GSS,
56 ENUM_ADS_ERROR_LDAP, ENUM_ADS_ERROR_SYSTEM, ENUM_ADS_ERROR_NT};
58 typedef struct {
59 enum ads_error_type error_type;
60 union err_state{
61 int rc;
62 NTSTATUS nt_status;
63 } err;
64 /* For error_type = ENUM_ADS_ERROR_GSS minor_status describe GSS API error */
65 /* Where rc represents major_status of GSS API error */
66 int minor_status;
67 } ADS_STATUS;
69 #ifdef HAVE_ADS
70 typedef LDAPMod **ADS_MODLIST;
71 #else
72 typedef void **ADS_MODLIST;
73 #endif
75 /* macros to simplify error returning */
76 #define ADS_ERROR(rc) ADS_ERROR_LDAP(rc)
77 #define ADS_ERROR_LDAP(rc) ads_build_error(ENUM_ADS_ERROR_LDAP, rc, 0)
78 #define ADS_ERROR_SYSTEM(rc) ads_build_error(ENUM_ADS_ERROR_SYSTEM, rc?rc:EINVAL, 0)
79 #define ADS_ERROR_KRB5(rc) ads_build_error(ENUM_ADS_ERROR_KRB5, rc, 0)
80 #define ADS_ERROR_GSS(rc, minor) ads_build_error(ENUM_ADS_ERROR_GSS, rc, minor)
81 #define ADS_ERROR_NT(rc) ads_build_nt_error(ENUM_ADS_ERROR_NT,rc)
83 #define ADS_ERR_OK(status) ((status.error_type == ENUM_ADS_ERROR_NT) ? NT_STATUS_IS_OK(status.err.nt_status):(status.err.rc == 0))
84 #define ADS_SUCCESS ADS_ERROR(0)
86 /* time between reconnect attempts */
87 #define ADS_RECONNECT_TIME 5
89 /* ldap control oids */
90 #define ADS_PAGE_CTL_OID "1.2.840.113556.1.4.319"
91 #define ADS_NO_REFERRALS_OID "1.2.840.113556.1.4.1339"
92 #define ADS_SERVER_SORT_OID "1.2.840.113556.1.4.473"
93 #define ADS_PERMIT_MODIFY_OID "1.2.840.113556.1.4.1413"
95 /* ldap attribute oids (Services for Unix) */
96 #define ADS_ATTR_SFU_UIDNUMBER_OID "1.2.840.113556.1.6.18.1.310"
97 #define ADS_ATTR_SFU_GIDNUMBER_OID "1.2.840.113556.1.6.18.1.311"
98 #define ADS_ATTR_SFU_HOMEDIR_OID "1.2.840.113556.1.6.18.1.344"
99 #define ADS_ATTR_SFU_SHELL_OID "1.2.840.113556.1.6.18.1.312"
101 /* ldap bitwise searches */
102 #define ADS_LDAP_MATCHING_RULE_BIT_AND "1.2.840.113556.1.4.803"
103 #define ADS_LDAP_MATCHING_RULE_BIT_OR "1.2.840.113556.1.4.804"
105 /* UserFlags for userAccountControl */
106 #define UF_SCRIPT 0x00000001
107 #define UF_ACCOUNTDISABLE 0x00000002
108 #define UF_UNUSED_1 0x00000004
109 #define UF_HOMEDIR_REQUIRED 0x00000008
111 #define UF_LOCKOUT 0x00000010
112 #define UF_PASSWD_NOTREQD 0x00000020
113 #define UF_PASSWD_CANT_CHANGE 0x00000040
114 #define UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED 0x00000080
116 #define UF_TEMP_DUPLICATE_ACCOUNT 0x00000100
117 #define UF_NORMAL_ACCOUNT 0x00000200
118 #define UF_UNUSED_2 0x00000400
119 #define UF_INTERDOMAIN_TRUST_ACCOUNT 0x00000800
121 #define UF_WORKSTATION_TRUST_ACCOUNT 0x00001000
122 #define UF_SERVER_TRUST_ACCOUNT 0x00002000
123 #define UF_UNUSED_3 0x00004000
124 #define UF_UNUSED_4 0x00008000
126 #define UF_DONT_EXPIRE_PASSWD 0x00010000
127 #define UF_MNS_LOGON_ACCOUNT 0x00020000
128 #define UF_SMARTCARD_REQUIRED 0x00040000
129 #define UF_TRUSTED_FOR_DELEGATION 0x00080000
131 #define UF_NOT_DELEGATED 0x00100000
132 #define UF_USE_DES_KEY_ONLY 0x00200000
133 #define UF_DONT_REQUIRE_PREAUTH 0x00400000
134 #define UF_UNUSED_5 0x00800000
136 #define UF_UNUSED_6 0x01000000
137 #define UF_NO_AUTH_DATA_REQUIRED 0x02000000
138 #define UF_UNUSED_8 0x04000000
139 #define UF_UNUSED_9 0x08000000
141 #define UF_UNUSED_10 0x10000000
142 #define UF_UNUSED_11 0x20000000
143 #define UF_UNUSED_12 0x40000000
144 #define UF_UNUSED_13 0x80000000
146 #define UF_MACHINE_ACCOUNT_MASK (\
147 UF_INTERDOMAIN_TRUST_ACCOUNT |\
148 UF_WORKSTATION_TRUST_ACCOUNT |\
149 UF_SERVER_TRUST_ACCOUNT \
152 #define UF_ACCOUNT_TYPE_MASK (\
153 UF_TEMP_DUPLICATE_ACCOUNT |\
154 UF_NORMAL_ACCOUNT |\
155 UF_INTERDOMAIN_TRUST_ACCOUNT |\
156 UF_WORKSTATION_TRUST_ACCOUNT |\
157 UF_SERVER_TRUST_ACCOUNT \
160 #define UF_SETTABLE_BITS (\
161 UF_SCRIPT |\
162 UF_ACCOUNTDISABLE |\
163 UF_HOMEDIR_REQUIRED |\
164 UF_LOCKOUT |\
165 UF_PASSWD_NOTREQD |\
166 UF_PASSWD_CANT_CHANGE |\
167 UF_ACCOUNT_TYPE_MASK | \
168 UF_DONT_EXPIRE_PASSWD | \
169 UF_MNS_LOGON_ACCOUNT |\
170 UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED |\
171 UF_SMARTCARD_REQUIRED |\
172 UF_TRUSTED_FOR_DELEGATION |\
173 UF_NOT_DELEGATED |\
174 UF_USE_DES_KEY_ONLY |\
175 UF_DONT_REQUIRE_PREAUTH \
178 /* sAMAccountType */
179 #define ATYPE_NORMAL_ACCOUNT 0x30000000 /* 805306368 */
180 #define ATYPE_WORKSTATION_TRUST 0x30000001 /* 805306369 */
181 #define ATYPE_INTERDOMAIN_TRUST 0x30000002 /* 805306370 */
182 #define ATYPE_SECURITY_GLOBAL_GROUP 0x10000000 /* 268435456 */
183 #define ATYPE_DISTRIBUTION_GLOBAL_GROUP 0x10000001 /* 268435457 */
184 #define ATYPE_DISTRIBUTION_UNIVERSAL_GROUP ATYPE_DISTRIBUTION_GLOBAL_GROUP
185 #define ATYPE_SECURITY_LOCAL_GROUP 0x20000000 /* 536870912 */
186 #define ATYPE_DISTRIBUTION_LOCAL_GROUP 0x20000001 /* 536870913 */
188 #define ATYPE_ACCOUNT ATYPE_NORMAL_ACCOUNT /* 0x30000000 805306368 */
189 #define ATYPE_GLOBAL_GROUP ATYPE_SECURITY_GLOBAL_GROUP /* 0x10000000 268435456 */
190 #define ATYPE_LOCAL_GROUP ATYPE_SECURITY_LOCAL_GROUP /* 0x20000000 536870912 */
192 /* groupType */
193 #define GROUP_TYPE_BUILTIN_LOCAL_GROUP 0x00000001
194 #define GROUP_TYPE_ACCOUNT_GROUP 0x00000002
195 #define GROUP_TYPE_RESOURCE_GROUP 0x00000004
196 #define GROUP_TYPE_UNIVERSAL_GROUP 0x00000008
197 #define GROUP_TYPE_APP_BASIC_GROUP 0x00000010
198 #define GROUP_TYPE_APP_QUERY_GROUP 0x00000020
199 #define GROUP_TYPE_SECURITY_ENABLED 0x80000000
201 #define GTYPE_SECURITY_BUILTIN_LOCAL_GROUP ( /* 0x80000005 -2147483643 */ \
202 GROUP_TYPE_BUILTIN_LOCAL_GROUP| \
203 GROUP_TYPE_RESOURCE_GROUP| \
204 GROUP_TYPE_SECURITY_ENABLED \
206 #define GTYPE_SECURITY_DOMAIN_LOCAL_GROUP ( /* 0x80000004 -2147483644 */ \
207 GROUP_TYPE_RESOURCE_GROUP| \
208 GROUP_TYPE_SECURITY_ENABLED \
210 #define GTYPE_SECURITY_GLOBAL_GROUP ( /* 0x80000002 -2147483646 */ \
211 GROUP_TYPE_ACCOUNT_GROUP| \
212 GROUP_TYPE_SECURITY_ENABLED \
214 #define GTYPE_DISTRIBUTION_GLOBAL_GROUP 0x00000002 /* 2 */
215 #define GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP 0x00000004 /* 4 */
216 #define GTYPE_DISTRIBUTION_UNIVERSAL_GROUP 0x00000008 /* 8 */
218 /* Mailslot or cldap getdcname response flags */
219 #define ADS_PDC 0x00000001 /* DC is PDC */
220 #define ADS_GC 0x00000004 /* DC is a GC of forest */
221 #define ADS_LDAP 0x00000008 /* DC is an LDAP server */
222 #define ADS_DS 0x00000010 /* DC supports DS */
223 #define ADS_KDC 0x00000020 /* DC is running KDC */
224 #define ADS_TIMESERV 0x00000040 /* DC is running time services */
225 #define ADS_CLOSEST 0x00000080 /* DC is closest to client */
226 #define ADS_WRITABLE 0x00000100 /* DC has writable DS */
227 #define ADS_GOOD_TIMESERV 0x00000200 /* DC has hardware clock
228 (and running time) */
229 #define ADS_NDNC 0x00000400 /* DomainName is non-domain NC serviced
230 by LDAP server */
231 #define ADS_PINGS 0x0000FFFF /* Ping response */
232 #define ADS_DNS_CONTROLLER 0x20000000 /* DomainControllerName is a DNS name*/
233 #define ADS_DNS_DOMAIN 0x40000000 /* DomainName is a DNS name */
234 #define ADS_DNS_FOREST 0x80000000 /* DnsForestName is a DNS name */
236 /* DomainCntrollerAddressType */
237 #define ADS_INET_ADDRESS 0x00000001
238 #define ADS_NETBIOS_ADDRESS 0x00000002
241 /* ads auth control flags */
242 #define ADS_AUTH_DISABLE_KERBEROS 0x01
243 #define ADS_AUTH_NO_BIND 0x02
244 #define ADS_AUTH_ANON_BIND 0x04
245 #define ADS_AUTH_SIMPLE_BIND 0x08
246 #define ADS_AUTH_ALLOW_NTLMSSP 0x10
248 /* Kerberos environment variable names */
249 #define KRB5_ENV_CCNAME "KRB5CCNAME"
251 /* Heimdal uses a slightly different name */
252 #if defined(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5)
253 #define ENCTYPE_ARCFOUR_HMAC ENCTYPE_ARCFOUR_HMAC_MD5
254 #endif
256 /* The older versions of heimdal that don't have this
257 define don't seem to use it anyway. I'm told they
258 always use a subkey */
259 #ifndef HAVE_AP_OPTS_USE_SUBKEY
260 #define AP_OPTS_USE_SUBKEY 0
261 #endif
263 #define WELL_KNOWN_GUID_COMPUTERS "AA312825768811D1ADED00C04FD8D5CD"
264 #define WELL_KNOWN_GUID_USERS "A9D1CA15768811D1ADED00C04FD8D5CD"