s3: Fix Coverity ID 2100, BAD_SIZEOF
[Samba.git] / source3 / include / ads.h
blobee6e5b8649b6366d23fe0c6e5576065de7d6466b
1 #ifndef _INCLUDE_ADS_H_
2 #define _INCLUDE_ADS_H_
3 /*
4 header for ads (active directory) library routines
6 basically this is a wrapper around ldap
7 */
9 #include "smb_ldap.h"
11 struct ads_struct;
13 struct ads_saslwrap_ops {
14 const char *name;
15 ADS_STATUS (*wrap)(struct ads_struct *, uint8 *buf, uint32 len);
16 ADS_STATUS (*unwrap)(struct ads_struct *);
17 void (*disconnect)(struct ads_struct *);
20 enum ads_saslwrap_type {
21 ADS_SASLWRAP_TYPE_PLAIN = 1,
22 ADS_SASLWRAP_TYPE_SIGN = 2,
23 ADS_SASLWRAP_TYPE_SEAL = 4
26 typedef struct ads_struct {
27 int is_mine; /* do I own this structure's memory? */
29 /* info needed to find the server */
30 struct {
31 char *realm;
32 char *workgroup;
33 char *ldap_server;
34 int foreign; /* set to 1 if connecting to a foreign
35 * realm */
36 bool gc; /* Is this a global catalog server? */
37 } server;
39 /* info needed to authenticate */
40 struct {
41 char *realm;
42 char *password;
43 char *user_name;
44 char *kdc_server;
45 unsigned flags;
46 int time_offset;
47 time_t tgt_expire;
48 time_t tgs_expire;
49 time_t renewable;
50 } auth;
52 /* info derived from the servers config */
53 struct {
54 uint32 flags; /* cldap flags identifying the services. */
55 char *realm;
56 char *bind_path;
57 char *ldap_server_name;
58 char *server_site_name;
59 char *client_site_name;
60 time_t current_time;
61 char *schema_path;
62 char *config_path;
63 } config;
65 /* info about the current LDAP connection */
66 #ifdef HAVE_LDAP
67 struct {
68 LDAP *ld;
69 struct sockaddr_storage ss; /* the ip of the active connection, if any */
70 time_t last_attempt; /* last attempt to reconnect, monotonic clock */
71 int port;
73 enum ads_saslwrap_type wrap_type;
75 #ifdef HAVE_LDAP_SASL_WRAPPING
76 Sockbuf_IO_Desc *sbiod; /* lowlevel state for LDAP wrapping */
77 #endif /* HAVE_LDAP_SASL_WRAPPING */
78 TALLOC_CTX *mem_ctx;
79 const struct ads_saslwrap_ops *wrap_ops;
80 void *wrap_private_data;
81 struct {
82 uint32 ofs;
83 uint32 needed;
84 uint32 left;
85 #define ADS_SASL_WRAPPING_IN_MAX_WRAPPED 0x0FFFFFFF
86 uint32 max_wrapped;
87 uint32 min_wrapped;
88 uint32 size;
89 uint8 *buf;
90 } in;
91 struct {
92 uint32 ofs;
93 uint32 left;
94 #define ADS_SASL_WRAPPING_OUT_MAX_WRAPPED 0x00A00000
95 uint32 max_unwrapped;
96 uint32 sig_size;
97 uint32 size;
98 uint8 *buf;
99 } out;
100 } ldap;
101 #endif /* HAVE_LDAP */
102 } ADS_STRUCT;
104 #ifdef HAVE_ADS
105 typedef LDAPMod **ADS_MODLIST;
106 #else
107 typedef void **ADS_MODLIST;
108 #endif
110 /* time between reconnect attempts */
111 #define ADS_RECONNECT_TIME 5
113 /* ldap control oids */
114 #define ADS_PAGE_CTL_OID "1.2.840.113556.1.4.319"
115 #define ADS_NO_REFERRALS_OID "1.2.840.113556.1.4.1339"
116 #define ADS_SERVER_SORT_OID "1.2.840.113556.1.4.473"
117 #define ADS_PERMIT_MODIFY_OID "1.2.840.113556.1.4.1413"
118 #define ADS_ASQ_OID "1.2.840.113556.1.4.1504"
119 #define ADS_EXTENDED_DN_OID "1.2.840.113556.1.4.529"
120 #define ADS_SD_FLAGS_OID "1.2.840.113556.1.4.801"
122 /* ldap bitwise searches */
123 #define ADS_LDAP_MATCHING_RULE_BIT_AND "1.2.840.113556.1.4.803"
124 #define ADS_LDAP_MATCHING_RULE_BIT_OR "1.2.840.113556.1.4.804"
126 #define ADS_PINGS 0x0000FFFF /* Ping response */
128 /* ads auth control flags */
129 #define ADS_AUTH_DISABLE_KERBEROS 0x0001
130 #define ADS_AUTH_NO_BIND 0x0002
131 #define ADS_AUTH_ANON_BIND 0x0004
132 #define ADS_AUTH_SIMPLE_BIND 0x0008
133 #define ADS_AUTH_ALLOW_NTLMSSP 0x0010
134 #define ADS_AUTH_SASL_SIGN 0x0020
135 #define ADS_AUTH_SASL_SEAL 0x0040
136 #define ADS_AUTH_SASL_FORCE 0x0080
137 #define ADS_AUTH_USER_CREDS 0x0100
139 enum ads_extended_dn_flags {
140 ADS_EXTENDED_DN_HEX_STRING = 0,
141 ADS_EXTENDED_DN_STRING = 1 /* not supported on win2k */
144 /* this is probably not very well suited to pass other controls generically but
145 * is good enough for the extended dn control where it is only used for atm */
147 typedef struct {
148 const char *control;
149 int val;
150 int critical;
151 } ads_control;
153 #include "libads/ads_proto.h"
155 #ifdef HAVE_LDAP
156 #include "libads/ads_ldap_protos.h"
157 #endif
159 #include "libads/kerberos_proto.h"
161 #endif /* _INCLUDE_ADS_H_ */