r24712: No longer expose the 'BOOL' data type in any interfaces.
[metze/samba/wip.git] / source4 / libcli / ldap / ldap.h
1 /* 
2    Unix SMB/CIFS Implementation.
3    LDAP protocol helper functions for SAMBA
4    Copyright (C) Volker Lendecke 2004
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
21 #ifndef _SMB_LDAP_H
22 #define _SMB_LDAP_H
23
24 #include "lib/ldb/include/ldb.h"
25
26 enum ldap_request_tag {
27         LDAP_TAG_BindRequest = 0,
28         LDAP_TAG_BindResponse = 1,
29         LDAP_TAG_UnbindRequest = 2,
30         LDAP_TAG_SearchRequest = 3,
31         LDAP_TAG_SearchResultEntry = 4,
32         LDAP_TAG_SearchResultDone = 5,
33         LDAP_TAG_ModifyRequest = 6,
34         LDAP_TAG_ModifyResponse = 7,
35         LDAP_TAG_AddRequest = 8,
36         LDAP_TAG_AddResponse = 9,
37         LDAP_TAG_DelRequest = 10,
38         LDAP_TAG_DelResponse = 11,
39         LDAP_TAG_ModifyDNRequest = 12,
40         LDAP_TAG_ModifyDNResponse = 13,
41         LDAP_TAG_CompareRequest = 14,
42         LDAP_TAG_CompareResponse = 15,
43         LDAP_TAG_AbandonRequest = 16,
44         LDAP_TAG_SearchResultReference = 19,
45         LDAP_TAG_ExtendedRequest = 23,
46         LDAP_TAG_ExtendedResponse = 24
47 };
48
49 enum ldap_auth_mechanism {
50         LDAP_AUTH_MECH_SIMPLE = 0,
51         LDAP_AUTH_MECH_SASL = 3
52 };
53
54 enum ldap_result_code {
55         LDAP_SUCCESS                            = 0,
56         LDAP_OPERATIONS_ERROR                   = 1,
57         LDAP_PROTOCOL_ERROR                     = 2,
58         LDAP_TIME_LIMIT_EXCEEDED                = 3,
59         LDAP_SIZE_LIMIT_EXCEEDED                = 4,
60         LDAP_COMPARE_FALSE                      = 5,
61         LDAP_COMPARE_TRUE                       = 6,
62         LDAP_AUTH_METHOD_NOT_SUPPORTED          = 7,
63         LDAP_STRONG_AUTH_REQUIRED               = 8,
64         LDAP_REFERRAL                           = 10,
65         LDAP_ADMIN_LIMIT_EXCEEDED               = 11,
66         LDAP_UNAVAILABLE_CRITICAL_EXTENSION     = 12,
67         LDAP_CONFIDENTIALITY_REQUIRED           = 13,
68         LDAP_SASL_BIND_IN_PROGRESS              = 14,
69         LDAP_NO_SUCH_ATTRIBUTE                  = 16,
70         LDAP_UNDEFINED_ATTRIBUTE_TYPE           = 17,
71         LDAP_INAPPROPRIATE_MATCHING             = 18,
72         LDAP_CONSTRAINT_VIOLATION               = 19,
73         LDAP_ATTRIBUTE_OR_VALUE_EXISTS          = 20,
74         LDAP_INVALID_ATTRIBUTE_SYNTAX           = 21,
75         LDAP_NO_SUCH_OBJECT                     = 32,
76         LDAP_ALIAS_PROBLEM                      = 33,
77         LDAP_INVALID_DN_SYNTAX                  = 34,
78         LDAP_ALIAS_DEREFERENCING_PROBLEM        = 36,
79         LDAP_INAPPROPRIATE_AUTHENTICATION       = 48,
80         LDAP_INVALID_CREDENTIALS                = 49,
81         LDAP_INSUFFICIENT_ACCESS_RIGHTS         = 50,
82         LDAP_BUSY                               = 51,
83         LDAP_UNAVAILABLE                        = 52,
84         LDAP_UNWILLING_TO_PERFORM               = 53,
85         LDAP_LOOP_DETECT                        = 54,
86         LDAP_NAMING_VIOLATION                   = 64,
87         LDAP_OBJECT_CLASS_VIOLATION             = 65,
88         LDAP_NOT_ALLOWED_ON_NON_LEAF            = 66,
89         LDAP_NOT_ALLOWED_ON_RDN                 = 67,
90         LDAP_ENTRY_ALREADY_EXISTS               = 68,
91         LDAP_OBJECT_CLASS_MODS_PROHIBITED       = 69,
92         LDAP_AFFECTS_MULTIPLE_DSAS              = 71,
93         LDAP_OTHER                              = 80
94 };
95
96 struct ldap_Result {
97         int resultcode;
98         const char *dn;
99         const char *errormessage;
100         const char *referral;
101 };
102
103 struct ldap_BindRequest {
104         int version;
105         const char *dn;
106         enum ldap_auth_mechanism mechanism;
107         union {
108                 const char *password;
109                 struct {
110                         const char *mechanism;
111                         DATA_BLOB *secblob;/* optional */
112                 } SASL;
113         } creds;
114 };
115
116 struct ldap_BindResponse {
117         struct ldap_Result response;
118         union {
119                 DATA_BLOB *secblob;/* optional */
120         } SASL;
121 };
122
123 struct ldap_UnbindRequest {
124         uint8_t __dummy;
125 };
126
127 enum ldap_scope {
128         LDAP_SEARCH_SCOPE_BASE = 0,
129         LDAP_SEARCH_SCOPE_SINGLE = 1,
130         LDAP_SEARCH_SCOPE_SUB = 2
131 };
132
133 enum ldap_deref {
134         LDAP_DEREFERENCE_NEVER = 0,
135         LDAP_DEREFERENCE_IN_SEARCHING = 1,
136         LDAP_DEREFERENCE_FINDING_BASE = 2,
137         LDAP_DEREFERENCE_ALWAYS
138 };
139
140 struct ldap_SearchRequest {
141         const char *basedn;
142         enum ldap_scope scope;
143         enum ldap_deref deref;
144         uint32_t timelimit;
145         uint32_t sizelimit;
146         bool attributesonly;
147         struct ldb_parse_tree *tree;
148         int num_attributes;
149         const char **attributes;
150 };
151
152 struct ldap_SearchResEntry {
153         const char *dn;
154         int num_attributes;
155         struct ldb_message_element *attributes;
156 };
157
158 struct ldap_SearchResRef {
159         const char *referral;
160 };
161
162 enum ldap_modify_type {
163         LDAP_MODIFY_NONE = -1,
164         LDAP_MODIFY_ADD = 0,
165         LDAP_MODIFY_DELETE = 1,
166         LDAP_MODIFY_REPLACE = 2
167 };
168
169 struct ldap_mod {
170         enum ldap_modify_type type;
171         struct ldb_message_element attrib;
172 };
173
174 struct ldap_ModifyRequest {
175         const char *dn;
176         int num_mods;
177         struct ldap_mod *mods;
178 };
179
180 struct ldap_AddRequest {
181         const char *dn;
182         int num_attributes;
183         struct ldb_message_element *attributes;
184 };
185
186 struct ldap_DelRequest {
187         const char *dn;
188 };
189
190 struct ldap_ModifyDNRequest {
191         const char *dn;
192         const char *newrdn;
193         bool deleteolddn;
194         const char *newsuperior;/* optional */
195 };
196
197 struct ldap_CompareRequest {
198         const char *dn;
199         const char *attribute;
200         DATA_BLOB value;
201 };
202
203 struct ldap_AbandonRequest {
204         uint32_t messageid;
205 };
206
207 struct ldap_ExtendedRequest {
208         const char *oid;
209         DATA_BLOB *value;/* optional */
210 };
211
212 struct ldap_ExtendedResponse {
213         struct ldap_Result response;
214         const char *oid;/* optional */
215         DATA_BLOB *value;/* optional */
216 };
217
218 union ldap_Request {
219         struct ldap_Result              GeneralResult;
220         struct ldap_BindRequest         BindRequest;
221         struct ldap_BindResponse        BindResponse;
222         struct ldap_UnbindRequest       UnbindRequest;
223         struct ldap_SearchRequest       SearchRequest;
224         struct ldap_SearchResEntry      SearchResultEntry;
225         struct ldap_Result              SearchResultDone;
226         struct ldap_SearchResRef        SearchResultReference;
227         struct ldap_ModifyRequest       ModifyRequest;
228         struct ldap_Result              ModifyResponse;
229         struct ldap_AddRequest          AddRequest;
230         struct ldap_Result              AddResponse;
231         struct ldap_DelRequest          DelRequest;
232         struct ldap_Result              DelResponse;
233         struct ldap_ModifyDNRequest     ModifyDNRequest;
234         struct ldap_Result              ModifyDNResponse;
235         struct ldap_CompareRequest      CompareRequest;
236         struct ldap_Result              CompareResponse;
237         struct ldap_AbandonRequest      AbandonRequest;
238         struct ldap_ExtendedRequest     ExtendedRequest;
239         struct ldap_ExtendedResponse    ExtendedResponse;
240 };
241
242 struct ldap_message {
243         int                     messageid;
244         enum ldap_request_tag   type;
245         union ldap_Request      r;
246         struct ldb_control    **controls;
247 };
248
249 struct event_context;
250 struct cli_credentials;
251 struct dom_sid;
252 struct asn1_data;
253
254 #include "libcli/ldap/ldap_proto.h"
255
256 #endif