source: vendor/current/source3/include/tldap.h

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 9.3 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 Infrastructure for async ldap client requests
4 Copyright (C) Volker Lendecke 2009
5
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.
10
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.
15
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/>.
18*/
19
20#ifndef __TLDAP_H__
21#define __TLDAP_H__
22
23#include <talloc.h>
24#include <tevent.h>
25#include "lib/util/data_blob.h"
26
27struct tldap_context;
28struct tldap_message;
29
30struct tldap_control {
31 const char *oid;
32 DATA_BLOB value;
33 bool critical;
34};
35
36struct tldap_attribute {
37 char *name;
38 int num_values;
39 DATA_BLOB *values;
40};
41
42struct tldap_mod {
43 int mod_op;
44 char *attribute;
45 int num_values;
46 DATA_BLOB *values;
47};
48
49bool tevent_req_is_ldap_error(struct tevent_req *req, int *perr);
50
51struct tldap_context *tldap_context_create(TALLOC_CTX *mem_ctx, int fd);
52bool tldap_connection_ok(struct tldap_context *ld);
53bool tldap_context_setattr(struct tldap_context *ld,
54 const char *name, const void *pptr);
55void *tldap_context_getattr(struct tldap_context *ld, const char *name);
56
57struct tevent_req *tldap_sasl_bind_send(TALLOC_CTX *mem_ctx,
58 struct tevent_context *ev,
59 struct tldap_context *ld,
60 const char *dn,
61 const char *mechanism,
62 DATA_BLOB *creds,
63 struct tldap_control *sctrls,
64 int num_sctrls,
65 struct tldap_control *cctrls,
66 int num_cctrls);
67int tldap_sasl_bind_recv(struct tevent_req *req);
68int tldap_sasl_bind(struct tldap_context *ldap,
69 const char *dn,
70 const char *mechanism,
71 DATA_BLOB *creds,
72 struct tldap_control *sctrls,
73 int num_sctrls,
74 struct tldap_control *cctrls,
75 int num_ctrls);
76
77struct tevent_req *tldap_simple_bind_send(TALLOC_CTX *mem_ctx,
78 struct tevent_context *ev,
79 struct tldap_context *ldap,
80 const char *dn,
81 const char *passwd);
82int tldap_simple_bind_recv(struct tevent_req *req);
83int tldap_simple_bind(struct tldap_context *ldap, const char *dn,
84 const char *passwd);
85
86struct tevent_req *tldap_search_send(TALLOC_CTX *mem_ctx,
87 struct tevent_context *ev,
88 struct tldap_context *ld,
89 const char *base, int scope,
90 const char *filter,
91 const char **attrs,
92 int num_attrs,
93 int attrsonly,
94 struct tldap_control *sctrls,
95 int num_sctrls,
96 struct tldap_control *cctrls,
97 int num_cctrls,
98 int timelimit,
99 int sizelimit,
100 int deref);
101int tldap_search_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
102 struct tldap_message **pmsg);
103int tldap_search(struct tldap_context *ld,
104 const char *base, int scope, const char *filter,
105 const char **attrs, int num_attrs, int attrsonly,
106 struct tldap_control *sctrls, int num_sctrls,
107 struct tldap_control *cctrls, int num_cctrls,
108 int timelimit, int sizelimit, int deref,
109 TALLOC_CTX *mem_ctx, struct tldap_message ***entries,
110 struct tldap_message ***refs);
111bool tldap_entry_dn(struct tldap_message *msg, char **dn);
112bool tldap_entry_attributes(struct tldap_message *msg,
113 struct tldap_attribute **attributes,
114 int *num_attributes);
115
116struct tevent_req *tldap_add_send(TALLOC_CTX *mem_ctx,
117 struct tevent_context *ev,
118 struct tldap_context *ld,
119 const char *dn,
120 struct tldap_mod *attributes,
121 int num_attributes,
122 struct tldap_control *sctrls,
123 int num_sctrls,
124 struct tldap_control *cctrls,
125 int num_cctrls);
126int tldap_add_recv(struct tevent_req *req);
127int tldap_add(struct tldap_context *ld, const char *dn,
128 struct tldap_mod *attributes, int num_attributes,
129 struct tldap_control *sctrls, int num_sctrls,
130 struct tldap_control *cctrls, int num_cctrls);
131
132struct tevent_req *tldap_modify_send(TALLOC_CTX *mem_ctx,
133 struct tevent_context *ev,
134 struct tldap_context *ld,
135 const char *dn,
136 struct tldap_mod *mods, int num_mods,
137 struct tldap_control *sctrls,
138 int num_sctrls,
139 struct tldap_control *cctrls,
140 int num_cctrls);
141int tldap_modify_recv(struct tevent_req *req);
142int tldap_modify(struct tldap_context *ld, const char *dn,
143 struct tldap_mod *mods, int num_mods,
144 struct tldap_control *sctrls, int num_sctrls,
145 struct tldap_control *cctrls, int num_cctrls);
146
147struct tevent_req *tldap_delete_send(TALLOC_CTX *mem_ctx,
148 struct tevent_context *ev,
149 struct tldap_context *ld,
150 const char *dn,
151 struct tldap_control *sctrls,
152 int num_sctrls,
153 struct tldap_control *cctrls,
154 int num_cctrls);
155int tldap_delete_recv(struct tevent_req *req);
156int tldap_delete(struct tldap_context *ld, const char *dn,
157 struct tldap_control *sctrls, int num_sctrls,
158 struct tldap_control *cctrls, int num_cctrls);
159
160int tldap_msg_id(const struct tldap_message *msg);
161int tldap_msg_type(const struct tldap_message *msg);
162const char *tldap_msg_matcheddn(struct tldap_message *msg);
163const char *tldap_msg_diagnosticmessage(struct tldap_message *msg);
164const char *tldap_msg_referral(struct tldap_message *msg);
165void tldap_msg_sctrls(struct tldap_message *msg, int *num_sctrls,
166 struct tldap_control **sctrls);
167struct tldap_message *tldap_ctx_lastmsg(struct tldap_context *ld);
168const char *tldap_err2string(int rc);
169
170/* DEBUG */
171enum tldap_debug_level {
172 TLDAP_DEBUG_FATAL,
173 TLDAP_DEBUG_ERROR,
174 TLDAP_DEBUG_WARNING,
175 TLDAP_DEBUG_TRACE
176};
177
178void tldap_set_debug(struct tldap_context *ld,
179 void (*log_fn)(void *log_private,
180 enum tldap_debug_level level,
181 const char *fmt,
182 va_list ap) PRINTF_ATTRIBUTE(3,0),
183 void *log_private);
184
185/*
186 * "+ 0x60" is from ASN1_APPLICATION
187 */
188#define TLDAP_REQ_BIND (0 + 0x60)
189#define TLDAP_RES_BIND (1 + 0x60)
190#define TLDAP_REQ_UNBIND (2 + 0x60)
191#define TLDAP_REQ_SEARCH (3 + 0x60)
192#define TLDAP_RES_SEARCH_ENTRY (4 + 0x60)
193#define TLDAP_RES_SEARCH_RESULT (5 + 0x60)
194#define TLDAP_REQ_MODIFY (6 + 0x60)
195#define TLDAP_RES_MODIFY (7 + 0x60)
196#define TLDAP_REQ_ADD (8 + 0x60)
197#define TLDAP_RES_ADD (9 + 0x60)
198/* ASN1_APPLICATION_SIMPLE instead of ASN1_APPLICATION */
199#define TLDAP_REQ_DELETE (10 + 0x40)
200#define TLDAP_RES_DELETE (11 + 0x60)
201#define TLDAP_REQ_MODDN (12 + 0x60)
202#define TLDAP_RES_MODDN (13 + 0x60)
203#define TLDAP_REQ_COMPARE (14 + 0x60)
204#define TLDAP_RES_COMPARE (15 + 0x60)
205/* ASN1_APPLICATION_SIMPLE instead of ASN1_APPLICATION */
206#define TLDAP_REQ_ABANDON (16 + 0x40)
207#define TLDAP_RES_SEARCH_REFERENCE (19 + 0x60)
208#define TLDAP_REQ_EXTENDED (23 + 0x60)
209#define TLDAP_RES_EXTENDED (24 + 0x60)
210#define TLDAP_RES_INTERMEDIATE (25 + 0x60)
211
212#define TLDAP_SUCCESS (0x00)
213#define TLDAP_OPERATIONS_ERROR (0x01)
214#define TLDAP_PROTOCOL_ERROR (0x02)
215#define TLDAP_TIMELIMIT_EXCEEDED (0x03)
216#define TLDAP_SIZELIMIT_EXCEEDED (0x04)
217#define TLDAP_COMPARE_FALSE (0x05)
218#define TLDAP_COMPARE_TRUE (0x06)
219#define TLDAP_STRONG_AUTH_NOT_SUPPORTED (0x07)
220#define TLDAP_STRONG_AUTH_REQUIRED (0x08)
221#define TLDAP_REFERRAL (0x0a)
222#define TLDAP_ADMINLIMIT_EXCEEDED (0x0b)
223#define TLDAP_UNAVAILABLE_CRITICAL_EXTENSION (0x0c)
224#define TLDAP_CONFIDENTIALITY_REQUIRED (0x0d)
225#define TLDAP_SASL_BIND_IN_PROGRESS (0x0e)
226#define TLDAP_NO_SUCH_ATTRIBUTE (0x10)
227#define TLDAP_UNDEFINED_TYPE (0x11)
228#define TLDAP_INAPPROPRIATE_MATCHING (0x12)
229#define TLDAP_CONSTRAINT_VIOLATION (0x13)
230#define TLDAP_TYPE_OR_VALUE_EXISTS (0x14)
231#define TLDAP_INVALID_SYNTAX (0x15)
232#define TLDAP_NO_SUCH_OBJECT (0x20)
233#define TLDAP_ALIAS_PROBLEM (0x21)
234#define TLDAP_INVALID_DN_SYNTAX (0x22)
235#define TLDAP_IS_LEAF (0x23)
236#define TLDAP_ALIAS_DEREF_PROBLEM (0x24)
237#define TLDAP_INAPPROPRIATE_AUTH (0x30)
238#define TLDAP_INVALID_CREDENTIALS (0x31)
239#define TLDAP_INSUFFICIENT_ACCESS (0x32)
240#define TLDAP_BUSY (0x33)
241#define TLDAP_UNAVAILABLE (0x34)
242#define TLDAP_UNWILLING_TO_PERFORM (0x35)
243#define TLDAP_LOOP_DETECT (0x36)
244#define TLDAP_NAMING_VIOLATION (0x40)
245#define TLDAP_OBJECT_CLASS_VIOLATION (0x41)
246#define TLDAP_NOT_ALLOWED_ON_NONLEAF (0x42)
247#define TLDAP_NOT_ALLOWED_ON_RDN (0x43)
248#define TLDAP_ALREADY_EXISTS (0x44)
249#define TLDAP_NO_OBJECT_CLASS_MODS (0x45)
250#define TLDAP_RESULTS_TOO_LARGE (0x46)
251#define TLDAP_AFFECTS_MULTIPLE_DSAS (0x47)
252#define TLDAP_OTHER (0x50)
253#define TLDAP_SERVER_DOWN (0x51)
254#define TLDAP_LOCAL_ERROR (0x52)
255#define TLDAP_ENCODING_ERROR (0x53)
256#define TLDAP_DECODING_ERROR (0x54)
257#define TLDAP_TIMEOUT (0x55)
258#define TLDAP_AUTH_UNKNOWN (0x56)
259#define TLDAP_FILTER_ERROR (0x57)
260#define TLDAP_USER_CANCELLED (0x58)
261#define TLDAP_PARAM_ERROR (0x59)
262#define TLDAP_NO_MEMORY (0x5a)
263#define TLDAP_CONNECT_ERROR (0x5b)
264#define TLDAP_NOT_SUPPORTED (0x5c)
265#define TLDAP_CONTROL_NOT_FOUND (0x5d)
266#define TLDAP_NO_RESULTS_RETURNED (0x5e)
267#define TLDAP_MORE_RESULTS_TO_RETURN (0x5f)
268#define TLDAP_CLIENT_LOOP (0x60)
269#define TLDAP_REFERRAL_LIMIT_EXCEEDED (0x61)
270
271#define TLDAP_MOD_ADD (0)
272#define TLDAP_MOD_DELETE (1)
273#define TLDAP_MOD_REPLACE (2)
274
275#define TLDAP_SCOPE_BASE (0)
276#define TLDAP_SCOPE_ONE (1)
277#define TLDAP_SCOPE_SUB (2)
278
279#define TLDAP_CONTROL_PAGEDRESULTS "1.2.840.113556.1.4.319"
280
281#endif
Note: See TracBrowser for help on using the repository browser.