r17915: Saturn fixes
[Samba/gbeck.git] / source / include / smb_ldap.h
blob144317cc1eb969c14088784ec14c67d472e5a4c8
1 /*
2 Unix SMB/CIFS Implementation.
3 LDAP protocol helper functions for SAMBA
4 Copyright (C) Volker Lendecke 2004
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 2 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, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #ifndef _SMB_LDAP_H
23 #define _SMB_LDAP_H
25 enum ldap_request_tag {
26 LDAP_TAG_BindRequest = 0,
27 LDAP_TAG_BindResponse = 1,
28 LDAP_TAG_UnbindRequest = 2,
29 LDAP_TAG_SearchRequest = 3,
30 LDAP_TAG_SearchResultEntry = 4,
31 LDAP_TAG_SearchResultDone = 5,
32 LDAP_TAG_ModifyRequest = 6,
33 LDAP_TAG_ModifyResponse = 7,
34 LDAP_TAG_AddRequest = 8,
35 LDAP_TAG_AddResponse = 9,
36 LDAP_TAG_DelRequest = 10,
37 LDAP_TAG_DelResponse = 11,
38 LDAP_TAG_ModifyDNRequest = 12,
39 LDAP_TAG_ModifyDNResponse = 13,
40 LDAP_TAG_CompareRequest = 14,
41 LDAP_TAG_CompareResponse = 15,
42 LDAP_TAG_AbandonRequest = 16,
43 LDAP_TAG_SearchResultReference = 19,
44 LDAP_TAG_ExtendedRequest = 23,
45 LDAP_TAG_ExtendedResponse = 24
48 enum ldap_auth_mechanism {
49 LDAP_AUTH_MECH_SIMPLE = 0,
50 LDAP_AUTH_MECH_SASL = 3
53 #ifndef LDAP_SUCCESS
54 enum ldap_result_code {
55 LDAP_SUCCESS = 0,
56 LDAP_SASL_BIND_IN_PROGRESS = 0x0e,
57 LDAP_INVALID_CREDENTIALS = 0x31,
58 LDAP_OTHER = 0x50
60 #endif /* LDAP_SUCCESS */
62 struct ldap_Result {
63 int resultcode;
64 const char *dn;
65 const char *errormessage;
66 const char *referral;
69 struct ldap_attribute {
70 const char *name;
71 int num_values;
72 DATA_BLOB *values;
75 struct ldap_BindRequest {
76 int version;
77 const char *dn;
78 enum ldap_auth_mechanism mechanism;
79 union {
80 const char *password;
81 struct {
82 const char *mechanism;
83 DATA_BLOB secblob;
84 } SASL;
85 } creds;
88 struct ldap_BindResponse {
89 struct ldap_Result response;
90 union {
91 DATA_BLOB secblob;
92 } SASL;
95 struct ldap_UnbindRequest {
96 uint8 __dummy;
99 enum ldap_scope {
100 LDAP_SEARCH_SCOPE_BASE = 0,
101 LDAP_SEARCH_SCOPE_SINGLE = 1,
102 LDAP_SEARCH_SCOPE_SUB = 2
105 enum ldap_deref {
106 LDAP_DEREFERENCE_NEVER = 0,
107 LDAP_DEREFERENCE_IN_SEARCHING = 1,
108 LDAP_DEREFERENCE_FINDING_BASE = 2,
109 LDAP_DEREFERENCE_ALWAYS
112 struct ldap_SearchRequest {
113 const char *basedn;
114 enum ldap_scope scope;
115 enum ldap_deref deref;
116 uint32 timelimit;
117 uint32 sizelimit;
118 BOOL attributesonly;
119 char *filter;
120 int num_attributes;
121 const char **attributes;
124 struct ldap_SearchResEntry {
125 const char *dn;
126 int num_attributes;
127 struct ldap_attribute *attributes;
130 struct ldap_SearchResRef {
131 int num_referrals;
132 const char **referrals;
135 enum ldap_modify_type {
136 LDAP_MODIFY_NONE = -1,
137 LDAP_MODIFY_ADD = 0,
138 LDAP_MODIFY_DELETE = 1,
139 LDAP_MODIFY_REPLACE = 2
142 struct ldap_mod {
143 enum ldap_modify_type type;
144 struct ldap_attribute attrib;
147 struct ldap_ModifyRequest {
148 const char *dn;
149 int num_mods;
150 struct ldap_mod *mods;
153 struct ldap_AddRequest {
154 const char *dn;
155 int num_attributes;
156 struct ldap_attribute *attributes;
159 struct ldap_DelRequest {
160 const char *dn;
163 struct ldap_ModifyDNRequest {
164 const char *dn;
165 const char *newrdn;
166 BOOL deleteolddn;
167 const char *newsuperior;
170 struct ldap_CompareRequest {
171 const char *dn;
172 const char *attribute;
173 const char *value;
176 struct ldap_AbandonRequest {
177 uint32 messageid;
180 struct ldap_ExtendedRequest {
181 const char *oid;
182 DATA_BLOB value;
185 struct ldap_ExtendedResponse {
186 struct ldap_Result response;
187 const char *name;
188 DATA_BLOB value;
191 union ldap_Request {
192 struct ldap_BindRequest BindRequest;
193 struct ldap_BindResponse BindResponse;
194 struct ldap_UnbindRequest UnbindRequest;
195 struct ldap_SearchRequest SearchRequest;
196 struct ldap_SearchResEntry SearchResultEntry;
197 struct ldap_Result SearchResultDone;
198 struct ldap_SearchResRef SearchResultReference;
199 struct ldap_ModifyRequest ModifyRequest;
200 struct ldap_Result ModifyResponse;
201 struct ldap_AddRequest AddRequest;
202 struct ldap_Result AddResponse;
203 struct ldap_DelRequest DelRequest;
204 struct ldap_Result DelResponse;
205 struct ldap_ModifyDNRequest ModifyDNRequest;
206 struct ldap_Result ModifyDNResponse;
207 struct ldap_CompareRequest CompareRequest;
208 struct ldap_Result CompareResponse;
209 struct ldap_AbandonRequest AbandonRequest;
210 struct ldap_ExtendedRequest ExtendedRequest;
211 struct ldap_ExtendedResponse ExtendedResponse;
214 struct ldap_Control {
215 const char *oid;
216 BOOL critical;
217 DATA_BLOB value;
220 struct ldap_message {
221 TALLOC_CTX *mem_ctx;
222 uint32 messageid;
223 uint8 type;
224 union ldap_Request r;
225 int num_controls;
226 struct ldap_Control *controls;
229 struct ldap_queue_entry {
230 struct ldap_queue_entry *next, *prev;
231 int msgid;
232 struct ldap_message *msg;
235 struct ldap_connection {
236 TALLOC_CTX *mem_ctx;
237 int sock;
238 int next_msgid;
239 char *host;
240 uint16 port;
241 BOOL ldaps;
243 const char *auth_dn;
244 const char *simple_pw;
246 /* Current outstanding search entry */
247 int searchid;
249 /* List for incoming search entries */
250 struct ldap_queue_entry *search_entries;
252 /* Outstanding LDAP requests that have not yet been replied to */
253 struct ldap_queue_entry *outstanding;
256 #endif