s4:libcli/ldap: use const char * const *attributes as in all other places
[Samba/gbeck.git] / source4 / libcli / ldap / ldap.h
blob3d99d6f47d1d88556626e81d4a71786b01b0d327
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 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/>.
21 #ifndef _SMB_LDAP_H_
22 #define _SMB_LDAP_H_
24 #include "libcli/ldap/ldap_errors.h"
25 #include "lib/ldb/include/ldb.h"
26 #include "librpc/gen_ndr/misc.h"
28 enum ldap_request_tag {
29 LDAP_TAG_BindRequest = 0,
30 LDAP_TAG_BindResponse = 1,
31 LDAP_TAG_UnbindRequest = 2,
32 LDAP_TAG_SearchRequest = 3,
33 LDAP_TAG_SearchResultEntry = 4,
34 LDAP_TAG_SearchResultDone = 5,
35 LDAP_TAG_ModifyRequest = 6,
36 LDAP_TAG_ModifyResponse = 7,
37 LDAP_TAG_AddRequest = 8,
38 LDAP_TAG_AddResponse = 9,
39 LDAP_TAG_DelRequest = 10,
40 LDAP_TAG_DelResponse = 11,
41 LDAP_TAG_ModifyDNRequest = 12,
42 LDAP_TAG_ModifyDNResponse = 13,
43 LDAP_TAG_CompareRequest = 14,
44 LDAP_TAG_CompareResponse = 15,
45 LDAP_TAG_AbandonRequest = 16,
46 LDAP_TAG_SearchResultReference = 19,
47 LDAP_TAG_ExtendedRequest = 23,
48 LDAP_TAG_ExtendedResponse = 24
51 enum ldap_auth_mechanism {
52 LDAP_AUTH_MECH_SIMPLE = 0,
53 LDAP_AUTH_MECH_SASL = 3
56 struct ldap_Result {
57 int resultcode;
58 const char *dn;
59 const char *errormessage;
60 const char *referral;
63 struct ldap_BindRequest {
64 int version;
65 const char *dn;
66 enum ldap_auth_mechanism mechanism;
67 union {
68 const char *password;
69 struct {
70 const char *mechanism;
71 DATA_BLOB *secblob;/* optional */
72 } SASL;
73 } creds;
76 struct ldap_BindResponse {
77 struct ldap_Result response;
78 union {
79 DATA_BLOB *secblob;/* optional */
80 } SASL;
83 struct ldap_UnbindRequest {
84 uint8_t __dummy;
87 enum ldap_scope {
88 LDAP_SEARCH_SCOPE_BASE = 0,
89 LDAP_SEARCH_SCOPE_SINGLE = 1,
90 LDAP_SEARCH_SCOPE_SUB = 2
93 enum ldap_deref {
94 LDAP_DEREFERENCE_NEVER = 0,
95 LDAP_DEREFERENCE_IN_SEARCHING = 1,
96 LDAP_DEREFERENCE_FINDING_BASE = 2,
97 LDAP_DEREFERENCE_ALWAYS
100 struct ldap_SearchRequest {
101 const char *basedn;
102 enum ldap_scope scope;
103 enum ldap_deref deref;
104 uint32_t timelimit;
105 uint32_t sizelimit;
106 bool attributesonly;
107 struct ldb_parse_tree *tree;
108 int num_attributes;
109 const char * const *attributes;
112 struct ldap_SearchResEntry {
113 const char *dn;
114 int num_attributes;
115 struct ldb_message_element *attributes;
118 struct ldap_SearchResRef {
119 const char *referral;
122 enum ldap_modify_type {
123 LDAP_MODIFY_NONE = -1,
124 LDAP_MODIFY_ADD = 0,
125 LDAP_MODIFY_DELETE = 1,
126 LDAP_MODIFY_REPLACE = 2
129 struct ldap_mod {
130 enum ldap_modify_type type;
131 struct ldb_message_element attrib;
134 struct ldap_ModifyRequest {
135 const char *dn;
136 int num_mods;
137 struct ldap_mod *mods;
140 struct ldap_AddRequest {
141 const char *dn;
142 int num_attributes;
143 struct ldb_message_element *attributes;
146 struct ldap_DelRequest {
147 const char *dn;
150 struct ldap_ModifyDNRequest {
151 const char *dn;
152 const char *newrdn;
153 bool deleteolddn;
154 const char *newsuperior;/* optional */
157 struct ldap_CompareRequest {
158 const char *dn;
159 const char *attribute;
160 DATA_BLOB value;
163 struct ldap_AbandonRequest {
164 uint32_t messageid;
167 struct ldap_ExtendedRequest {
168 const char *oid;
169 DATA_BLOB *value;/* optional */
172 struct ldap_ExtendedResponse {
173 struct ldap_Result response;
174 const char *oid;/* optional */
175 DATA_BLOB *value;/* optional */
178 union ldap_Request {
179 struct ldap_Result GeneralResult;
180 struct ldap_BindRequest BindRequest;
181 struct ldap_BindResponse BindResponse;
182 struct ldap_UnbindRequest UnbindRequest;
183 struct ldap_SearchRequest SearchRequest;
184 struct ldap_SearchResEntry SearchResultEntry;
185 struct ldap_Result SearchResultDone;
186 struct ldap_SearchResRef SearchResultReference;
187 struct ldap_ModifyRequest ModifyRequest;
188 struct ldap_Result ModifyResponse;
189 struct ldap_AddRequest AddRequest;
190 struct ldap_Result AddResponse;
191 struct ldap_DelRequest DelRequest;
192 struct ldap_Result DelResponse;
193 struct ldap_ModifyDNRequest ModifyDNRequest;
194 struct ldap_Result ModifyDNResponse;
195 struct ldap_CompareRequest CompareRequest;
196 struct ldap_Result CompareResponse;
197 struct ldap_AbandonRequest AbandonRequest;
198 struct ldap_ExtendedRequest ExtendedRequest;
199 struct ldap_ExtendedResponse ExtendedResponse;
203 struct ldap_message {
204 int messageid;
205 enum ldap_request_tag type;
206 union ldap_Request r;
207 struct ldb_control **controls;
208 bool *controls_decoded;
211 struct tevent_context;
212 struct cli_credentials;
213 struct dom_sid;
214 struct asn1_data;
216 struct ldap_message *new_ldap_message(TALLOC_CTX *mem_ctx);
217 NTSTATUS ldap_decode(struct asn1_data *data, struct ldap_message *msg);
218 bool ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ctx);
220 #endif