Fix after making tldap independent of ldap.h
[Samba.git] / source3 / include / tldap.h
blob9ce5c8bfa8e3afdd249e6503d574ca45f3b2500a
1 /*
2 Unix SMB/CIFS implementation.
3 Infrastructure for async ldap client requests
4 Copyright (C) Volker Lendecke 2009
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef __TLDAP_H__
21 #define __TLDAP_H__
23 #include <talloc.h>
24 #include <tevent.h>
26 struct tldap_context;
27 struct tldap_message;
29 struct tldap_control {
30 const char *oid;
31 DATA_BLOB value;
32 bool iscritical;
35 struct tldap_attribute {
36 char *name;
37 int num_values;
38 DATA_BLOB *values;
41 struct tldap_mod {
42 int mod_op;
43 char *attribute;
44 int num_values;
45 DATA_BLOB *values;
48 struct tldap_context *tldap_context_create(TALLOC_CTX *mem_ctx, int fd);
50 struct tevent_req *tldap_sasl_bind_send(TALLOC_CTX *mem_ctx,
51 struct tevent_context *ev,
52 struct tldap_context *ld,
53 const char *dn,
54 const char *mechanism,
55 DATA_BLOB *creds,
56 struct tldap_control **sctrls,
57 struct tldap_control **cctrls);
58 int tldap_sasl_bind_recv(struct tevent_req *req);
59 int tldap_sasl_bind(struct tldap_context *ldap,
60 const char *dn,
61 const char *mechanism,
62 DATA_BLOB *creds,
63 struct tldap_control **sctrls,
64 struct tldap_control **cctrls);
66 struct tevent_req *tldap_simple_bind_send(TALLOC_CTX *mem_ctx,
67 struct tevent_context *ev,
68 struct tldap_context *ldap,
69 const char *dn,
70 const char *passwd);
71 int tldap_simple_bind_recv(struct tevent_req *req);
72 int tldap_simple_bind(struct tldap_context *ldap, const char *dn,
73 const char *passwd);
75 struct tevent_req *tldap_search_send(TALLOC_CTX *mem_ctx,
76 struct tevent_context *ev,
77 struct tldap_context *ld,
78 const char *base, int scope,
79 const char *filter,
80 const char **attrs,
81 int num_attrs,
82 int attrsonly,
83 struct tldap_control **sctrls,
84 struct tldap_control **cctrls,
85 int timelimit,
86 int sizelimit,
87 int deref);
88 int tldap_search_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
89 struct tldap_message **pmsg);
90 int tldap_search(struct tldap_context *ld,
91 const char *base, int scope, const char *filter,
92 const char **attrs, int num_attrs, int attrsonly,
93 struct tldap_control **sctrls, struct tldap_control **cctrls,
94 int timelimit, int sizelimit, int deref,
95 TALLOC_CTX *mem_ctx, struct tldap_message ***pentries,
96 struct tldap_message ***refs);
97 bool tldap_entry_dn(struct tldap_message *msg, char **dn);
98 bool tldap_entry_attributes(struct tldap_message *msg, int *num_attributes,
99 struct tldap_attribute **attributes);
101 struct tevent_req *tldap_add_send(TALLOC_CTX *mem_ctx,
102 struct tevent_context *ev,
103 struct tldap_context *ld,
104 const char *dn,
105 int num_attributes,
106 struct tldap_mod *attributes,
107 struct tldap_control **sctrls,
108 struct tldap_control **cctrls);
109 int tldap_add_recv(struct tevent_req *req);
110 int tldap_add(struct tldap_context *ld, const char *dn,
111 int num_attributes, struct tldap_mod *attributes,
112 struct tldap_control **sctrls, struct tldap_control **cctrls);
114 struct tevent_req *tldap_modify_send(TALLOC_CTX *mem_ctx,
115 struct tevent_context *ev,
116 struct tldap_context *ld,
117 const char *dn,
118 int num_mods, struct tldap_mod *mods,
119 struct tldap_control **sctrls,
120 struct tldap_control **cctrls);
121 int tldap_modify_recv(struct tevent_req *req);
122 int tldap_modify(struct tldap_context *ld, const char *dn,
123 int num_mods, struct tldap_mod *mods,
124 struct tldap_control **sctrls, struct tldap_control **cctrls);
127 struct tevent_req *tldap_delete_send(TALLOC_CTX *mem_ctx,
128 struct tevent_context *ev,
129 struct tldap_context *ld,
130 const char *dn,
131 struct tldap_control **sctrls,
132 struct tldap_control **cctrls);
133 int tldap_delete_recv(struct tevent_req *req);
134 int tldap_delete(struct tldap_context *ld, const char *dn,
135 struct tldap_control **sctrls, struct tldap_control **cctrls);
138 int tldap_msg_id(const struct tldap_message *msg);
139 int tldap_msg_type(const struct tldap_message *msg);
140 const char *tldap_req_matcheddn(struct tevent_req *req);
141 const char *tldap_req_diagnosticmessage(struct tevent_req *req);
142 const char *tldap_req_referral(struct tevent_req *req);
143 const char *tldap_ctx_matcheddn(struct tldap_context *ctx);
144 const char *tldap_ctx_diagnosticmessage(struct tldap_context *ctx);
145 const char *tldap_ctx_referral(struct tldap_context *ctx);
146 const char *tldap_err2string(int rc);
149 * "+ 0x60" is from ASN1_APPLICATION
151 #define TLDAP_REQ_BIND (0 + 0x60)
152 #define TLDAP_RES_BIND (1 + 0x60)
153 #define TLDAP_REQ_UNBIND (2 + 0x60)
154 #define TLDAP_REQ_SEARCH (3 + 0x60)
155 #define TLDAP_RES_SEARCH_ENTRY (4 + 0x60)
156 #define TLDAP_RES_SEARCH_RESULT (5 + 0x60)
157 #define TLDAP_REQ_MODIFY (6 + 0x60)
158 #define TLDAP_RES_MODIFY (7 + 0x60)
159 #define TLDAP_REQ_ADD (8 + 0x60)
160 #define TLDAP_RES_ADD (9 + 0x60)
161 #define TLDAP_REQ_DELETE (10 + 0x60)
162 #define TLDAP_RES_DELETE (11 + 0x60)
163 #define TLDAP_REQ_MODDN (12 + 0x60)
164 #define TLDAP_RES_MODDN (13 + 0x60)
165 #define TLDAP_REQ_COMPARE (14 + 0x60)
166 #define TLDAP_RES_COMPARE (15 + 0x60)
167 #define TLDAP_REQ_ABANDON (16 + 0x60)
168 #define TLDAP_RES_SEARCH_REFERENCE (19 + 0x60)
169 #define TLDAP_REQ_EXTENDED (23 + 0x60)
170 #define TLDAP_RES_EXTENDED (24 + 0x60)
171 #define TLDAP_RES_INTERMEDIATE (25 + 0x60)
173 #define TLDAP_SUCCESS (0x00)
174 #define TLDAP_OPERATIONS_ERROR (0x01)
175 #define TLDAP_PROTOCOL_ERROR (0x02)
176 #define TLDAP_TIMELIMIT_EXCEEDED (0x03)
177 #define TLDAP_SIZELIMIT_EXCEEDED (0x04)
178 #define TLDAP_COMPARE_FALSE (0x05)
179 #define TLDAP_COMPARE_TRUE (0x06)
180 #define TLDAP_STRONG_AUTH_NOT_SUPPORTED (0x07)
181 #define TLDAP_STRONG_AUTH_REQUIRED (0x08)
182 #define TLDAP_REFERRAL (0x0a)
183 #define TLDAP_ADMINLIMIT_EXCEEDED (0x0b)
184 #define TLDAP_UNAVAILABLE_CRITICAL_EXTENSION (0x0c)
185 #define TLDAP_CONFIDENTIALITY_REQUIRED (0x0d)
186 #define TLDAP_SASL_BIND_IN_PROGRESS (0x0e)
187 #define TLDAP_NO_SUCH_ATTRIBUTE (0x10)
188 #define TLDAP_UNDEFINED_TYPE (0x11)
189 #define TLDAP_INAPPROPRIATE_MATCHING (0x12)
190 #define TLDAP_CONSTRAINT_VIOLATION (0x13)
191 #define TLDAP_TYPE_OR_VALUE_EXISTS (0x14)
192 #define TLDAP_INVALID_SYNTAX (0x15)
193 #define TLDAP_NO_SUCH_OBJECT (0x20)
194 #define TLDAP_ALIAS_PROBLEM (0x21)
195 #define TLDAP_INVALID_DN_SYNTAX (0x22)
196 #define TLDAP_IS_LEAF (0x23)
197 #define TLDAP_ALIAS_DEREF_PROBLEM (0x24)
198 #define TLDAP_INAPPROPRIATE_AUTH (0x30)
199 #define TLDAP_INVALID_CREDENTIALS (0x31)
200 #define TLDAP_INSUFFICIENT_ACCESS (0x32)
201 #define TLDAP_BUSY (0x33)
202 #define TLDAP_UNAVAILABLE (0x34)
203 #define TLDAP_UNWILLING_TO_PERFORM (0x35)
204 #define TLDAP_LOOP_DETECT (0x36)
205 #define TLDAP_NAMING_VIOLATION (0x40)
206 #define TLDAP_OBJECT_CLASS_VIOLATION (0x41)
207 #define TLDAP_NOT_ALLOWED_ON_NONLEAF (0x42)
208 #define TLDAP_NOT_ALLOWED_ON_RDN (0x43)
209 #define TLDAP_ALREADY_EXISTS (0x44)
210 #define TLDAP_NO_OBJECT_CLASS_MODS (0x45)
211 #define TLDAP_RESULTS_TOO_LARGE (0x46)
212 #define TLDAP_AFFECTS_MULTIPLE_DSAS (0x47)
213 #define TLDAP_OTHER (0x50)
214 #define TLDAP_SERVER_DOWN (0x51)
215 #define TLDAP_LOCAL_ERROR (0x52)
216 #define TLDAP_ENCODING_ERROR (0x53)
217 #define TLDAP_DECODING_ERROR (0x54)
218 #define TLDAP_TIMEOUT (0x55)
219 #define TLDAP_AUTH_UNKNOWN (0x56)
220 #define TLDAP_FILTER_ERROR (0x57)
221 #define TLDAP_USER_CANCELLED (0x58)
222 #define TLDAP_PARAM_ERROR (0x59)
223 #define TLDAP_NO_MEMORY (0x5a)
224 #define TLDAP_CONNECT_ERROR (0x5b)
225 #define TLDAP_NOT_SUPPORTED (0x5c)
226 #define TLDAP_CONTROL_NOT_FOUND (0x5d)
227 #define TLDAP_NO_RESULTS_RETURNED (0x5e)
228 #define TLDAP_MORE_RESULTS_TO_RETURN (0x5f)
229 #define TLDAP_CLIENT_LOOP (0x60)
230 #define TLDAP_REFERRAL_LIMIT_EXCEEDED (0x61)
232 #define TLDAP_MOD_ADD (0)
233 #define TLDAP_MOD_DELETE (1)
234 #define TLDAP_MOD_REPLACE (2)
236 #define TLDAP_SCOPE_BASE (0)
237 #define TLDAP_SCOPE_ONE (1)
238 #define TLDAP_SCOPE_SUB (2)
240 #endif