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