ldap_sys/
lib.rs

1#![allow(non_upper_case_globals)]
2#![allow(non_camel_case_types)]
3#![allow(non_snake_case)]
4#![allow(clippy::unreadable_literal)]
5#![allow(clippy::redundant_static_lifetimes)]
6
7use std::env;
8
9use std::os::raw::{c_char};
10
11include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
12
13#[cfg(feature = "deprecated")]
14mod deprecated {
15	use crate::*;
16	use std::os::raw::{c_int, c_void};
17
18	// Functions (might be deprecated)
19	extern "C" {
20		#[deprecated(note = "Use `ldap_control_create` instead")]
21		pub fn ldap_create_control(
22			requestOID: *const c_char,
23			ber: *mut BerElement,
24			iscritical: c_int,
25			ctrlp: *mut *mut LDAPControl,
26		) -> c_int;
27		#[deprecated(note = "Use `ldap_control_find` instead")]
28		pub fn ldap_find_control(oid: *const c_char, ctrls: *mut *mut LDAPControl) -> c_int;
29
30		#[deprecated(note = "Use `ldap_abandon_ext` instead")]
31		pub fn ldap_abandon(ld: *mut LDAP, msg_id: c_int) -> c_int;
32
33		#[deprecated(note = "Use `ldap_add_ext` instead")]
34		pub fn ldap_add(ld: *mut LDAP, dn: *const c_char, attrs: *mut *mut LDAPMod) -> c_int;
35		#[deprecated(note = "USE `ldap_add_ext_s` instead")]
36		pub fn ldap_add_s(ld: *mut LDAP, dn: *const c_char, attrs: *mut *mut LDAPMod) -> c_int;
37
38		#[deprecated(note = "Use `ldap_sasl_bind` instead")]
39		pub fn ldap_bind(
40			ld: *mut LDAP,
41			who: *const c_char,
42			passwd: *const c_char,
43			authmethod: c_int,
44		) -> c_int;
45		#[deprecated(note = "Use `ldap_sasl_bind_s` instead")]
46		pub fn ldap_bind_s(
47			ld: *mut LDAP,
48			who: *const c_char,
49			passwd: *const c_char,
50			authmethod: c_int,
51		) -> c_int;
52		#[deprecated(note = "Use `ldap_sasl_bind` instead")]
53		pub fn ldap_simple_bind(ld: *mut LDAP, who: *const c_char, passwd: *const c_char) -> c_int;
54		#[deprecated(note = "Use `ldap_sasl_bind_s` instead")]
55		pub fn ldap_simple_bind_s(ld: *mut LDAP, who: *const c_char, passwd: *const c_char) -> c_int;
56
57		#[deprecated(note = "Use `ldap_compare_ext` instead")]
58		pub fn ldap_compare(
59			ld: *mut LDAP,
60			dn: *const c_char,
61			attr: *const c_char,
62			value: *const c_char,
63		) -> c_int;
64		#[deprecated(note = "Use `ldap_compare_ext_s` instead")]
65		pub fn ldap_compare_s(
66			ld: *mut LDAP,
67			dn: *const c_char,
68			attr: *const c_char,
69			value: *const c_char,
70		) -> c_int;
71
72		#[deprecated(note = "Use `ldap_delete_ext` instead")]
73		pub fn ldap_delete(ld: *mut LDAP, dn: *const c_char) -> c_int;
74		#[deprecated(note = "Use `ldap_delete_ext_s` instead")]
75		pub fn ldap_delete_s(ld: *mut LDAP, dn: *const c_char) -> c_int;
76
77		#[deprecated(note = "Use `ldap_parse_result` instead")]
78		pub fn ldap_result2error(ld: *mut LDAP, r: *mut LDAPMessage, freeit: c_int) -> c_int;
79		#[deprecated(note = "Use `ldap_err2string` instead")]
80		pub fn ldap_perror(ld: *mut LDAP, s: *const c_char) -> c_void;
81
82		#[deprecated(note = "Use `ldap_modify_ext` instead")]
83		pub fn ldap_modify(ld: *mut LDAP, dn: *const c_char, mods: *mut *mut LDAPMod) -> c_int;
84		#[deprecated(note = "Use `ldap_modify_ext_s` instead")]
85		pub fn ldap_modify_s(ld: *mut LDAP, dn: *const c_char, mods: *mut *mut LDAPMod) -> c_int;
86
87		#[deprecated(note = "Use `ldap_rename` instead")]
88		pub fn ldap_rename2(
89			ld: *mut LDAP,
90			dn: *const c_char,
91			newrdn: *const c_char,
92			new_superior: *const c_char,
93			deleteoldrdn: c_int,
94		) -> c_int;
95		#[deprecated(note = "Use `ldap_rename_s` instead")]
96		pub fn ldap_rename2_s(
97			ld: *mut LDAP,
98			dn: *const c_char,
99			newrdn: *const c_char,
100			newSuperior: *const c_char,
101			deleteoldrdn: c_int,
102		) -> c_int;
103		#[deprecated(note = "Use `ldap_rename` instead")]
104		pub fn ldap_modrdn(ld: *mut LDAP, dn: *const c_char, newrdn: *const c_char) -> c_int;
105		#[deprecated(note = "Use `ldap_rename_s` instead")]
106		pub fn ldap_modrdn_s(ld: *mut LDAP, dn: *const c_char, newrdn: *const c_char) -> c_int;
107		#[deprecated(note = "Use `ldap_rename` instead")]
108		pub fn ldap_modrdn2(
109			ld: *mut LDAP,
110			dn: *const c_char,
111			newrdn: *const c_char,
112			deleteoldrdn: c_int,
113		) -> c_int;
114		#[deprecated(note = "Use `ldap_rename_s` instead")]
115		pub fn ldap_modrdn2_s(
116			ld: *mut LDAP,
117			dn: *const c_char,
118			newrdn: *const c_char,
119			deleteoldrdn: c_int,
120		) -> c_int;
121
122		#[deprecated(note = "Use `ldap_initialize`")]
123		pub fn ldap_init(host: *const c_char, port: c_int) -> *mut LDAP;
124		#[deprecated(note = "Use `ldap_initialize`")]
125		pub fn ldap_open(host: *const c_char, port: c_int) -> *mut LDAP;
126
127		#[deprecated(note = "Use `ldap_get_values_len` instead")]
128		pub fn ldap_get_values(
129			ld: *mut LDAP,
130			entry: *mut LDAPMessage,
131			target: *const c_char,
132		) -> *mut *mut c_char;
133		#[deprecated(note = "Use `ldap_count_values_len` instead")]
134		pub fn ldap_count_values(vals: *mut *mut c_char) -> c_int;
135
136		#[deprecated(note = "Use `ldap-value_free_len` instead")]
137		pub fn ldap_value_free(vals: *mut *mut c_char);
138
139		#[deprecated(note = "Use `ldap_search_ext` instead")]
140		pub fn ldap_search(
141			ld: *mut LDAP,
142			base: *const c_char,
143			scope: c_int,
144			filter: *const c_char,
145			attrs: *mut *mut c_char,
146			attrsonly: c_int,
147		) -> c_int;
148		#[deprecated(note = "Use `ldap_search_ext_s` instead")]
149		pub fn ldap_search_s(
150			ld: *mut LDAP,
151			base: *const c_char,
152			scope: c_int,
153			filter: *const c_char,
154			attrs: *mut *mut c_char,
155			attrsonly: c_int,
156			res: *mut *mut LDAPMessage,
157		) -> c_int;
158		#[deprecated(note = "Use `ldap_search_ext_s` instead")]
159		pub fn ldap_search_st(
160			ld: *mut LDAP,
161			base: *const c_char,
162			scope: c_int,
163			filter: *const c_char,
164			attrs: *mut *mut c_char,
165			attrsonly: c_int,
166			timeout: *const timeval,
167			res: *mut *mut LDAPMessage,
168		) -> c_int;
169
170		#[deprecated(note = "Use `ldap_unbind_ext` instead")]
171		pub fn ldap_unbind(ld: *mut LDAP) -> c_int;
172		#[deprecated(note = "Use `ldap_unbind_ext_s` instead")]
173		pub fn ldap_unbind_s(ld: *mut LDAP) -> c_int;
174
175		#[deprecated(note = "Use `ldap_parse_pageresponse_control` instead")]
176		pub fn ldap_parse_page_control(ld: *mut LDAP, ctrls: *mut *mut LDAPControl, count: *mut ber_int_t, cookie: *mut *mut berval);
177	}
178
179	#[deprecated]
180	pub type LDAP_SORT_AD_CMP_PROC = extern "C" fn(left: *const c_char, right: *const c_char) -> c_int;
181	#[deprecated]
182	pub type LDAP_SORT_AV_CMP_PROC = extern "C" fn(left: *const c_void, right: *const c_void) -> c_int;
183
184	extern "C" {
185		#[allow(deprecated)]
186		#[deprecated]
187		pub fn ldap_sort_entries(ld: *mut LDAP, vals: *mut *mut c_char, cmp: *mut LDAP_SORT_AV_CMP_PROC) -> c_int;
188	}
189}
190
191#[cfg(feature = "deprecated")]
192pub use crate::deprecated::*;
193
194// Constants and methods BINDGEN does not seem to care about
195
196pub const LDAP_TAG_SYNC_NEW_COOKIE: ber_tag_t = 0x80;
197pub const LDAP_TAG_SYNC_REFRESH_DELETE: ber_tag_t = 0xa1;
198pub const LDAP_TAG_SYNC_REFRESH_PRESENT: ber_tag_t = 0xa2;
199pub const LDAP_TAG_SYNC_ID_SET: ber_tag_t = 0xa3;
200
201pub const LDAP_TAG_SYNC_COOKIE: ber_tag_t = 0x04;
202pub const LDAP_TAG_REFRESHDELETES: ber_tag_t = 0x01;
203pub const LDAP_TAG_REFERESHDONE: ber_tag_t = 0x01;
204pub const LDAP_TAG_RELOAD_HINT: ber_tag_t = 0x01;
205
206pub const LDAP_TAG_EXOP_MODIFY_PASSWD_ID: ber_tag_t = 0x80;
207pub const LDAP_TAG_EXOP_MODIFY_PASSWD_OLD: ber_tag_t = 0x81;
208pub const LDAP_TAG_EXOP_MODIFY_PASSWD_NEW: ber_tag_t = 0x82;
209pub const LDAP_TAG_EXOP_MODIFY_PASSWD_GEN: ber_tag_t = 0x80;
210
211pub const LDAP_TAG_EXOP_REFRESH_REQ_DN: ber_tag_t = 0x80;
212pub const LDAP_TAG_EXOP_REFRESH_REQ_TTL: ber_tag_t = 0x81;
213pub const LDAP_TAG_EXOP_REFRESH_RES_TTL: ber_tag_t = 0x81;
214
215pub const LDAP_TAG_MESSAGE: ber_tag_t = 0x30;
216pub const LDAP_TAG_MSGID: ber_tag_t = 0x02;
217pub const LDAP_TAG_LDAPDN: ber_tag_t = 0x04;
218pub const LDAP_TAG_LDAPCRED: ber_tag_t = 0x04;
219
220pub const LDAP_TAG_CONTROLS: ber_tag_t = 0xa0;
221pub const LDAP_TAG_REFERRAL: ber_tag_t = 0xa3;
222
223pub const LDAP_TAG_NEWSUPERIOR: ber_tag_t = 0x80;
224
225pub const LDAP_TAG_EXOP_REQ_OID: ber_tag_t = 0x80;
226pub const LDAP_TAG_EXOP_REQ_VALUE: ber_tag_t = 0x81;
227pub const LDAP_TAG_EXOP_RES_OID: ber_tag_t = 0x8a;
228pub const LDAP_TAG_EXOP_RES_VALUE: ber_tag_t = 0x8b;
229
230pub const LDAP_TAG_IM_RES_OID: ber_tag_t = 0x80;
231pub const LDAP_TAG_IM_RES_VALUE: ber_tag_t = 0x81;
232
233pub const LDAP_TAG_SASL_RES_CREDS: ber_tag_t = 0x87;
234
235// LDAP Request Message
236pub const LDAP_REQ_BIND: ber_tag_t = 0x60;
237pub const LDAP_REQ_UNBIND: ber_tag_t = 0x42;
238pub const LDAP_REQ_SEARCH: ber_tag_t = 0x63;
239pub const LDAP_REQ_MODIFY: ber_tag_t = 0x66;
240pub const LDAP_REQ_ADD: ber_tag_t = 0x68;
241pub const LDAP_REQ_DELETE: ber_tag_t = 0x4a;
242pub const LDAP_REQ_MODDN: ber_tag_t = 0x6c;
243pub const LDAP_REQ_MODRDN: ber_tag_t = LDAP_REQ_MODDN;
244pub const LDAP_REQ_RENAME: ber_tag_t = LDAP_REQ_MODDN;
245pub const LDAP_REQ_COMPARE: ber_tag_t = 0x6e;
246pub const LDAP_REQ_ABANDON: ber_tag_t = 0x50;
247pub const LDAP_REQ_EXTENDED: ber_tag_t = 0x77;
248
249// LDAP Response Messages
250pub const LDAP_RES_BIND: ber_tag_t = 0x61;
251pub const LDAP_RES_SEARCH_ENTRY: ber_tag_t = 0x64;
252pub const LDAP_RES_SEARCH_REFERENCE: ber_tag_t = 0x73;
253pub const LDAP_RES_SEARCH_RESULT: ber_tag_t = 0x65;
254pub const LDAP_RES_MODIFY: ber_tag_t = 0x67;
255pub const LDAP_RES_ADD: ber_tag_t = 0x69;
256pub const LDAP_RES_DELETE: ber_tag_t = 0x6b;
257pub const LDAP_RES_MODDN: ber_tag_t = 0x6d;
258pub const LDAP_RES_MODRDN: ber_tag_t = LDAP_RES_MODDN;
259pub const LDAP_RES_RENAME: ber_tag_t = LDAP_RES_MODDN;
260pub const LDAP_RES_COMPARE: ber_tag_t = 0x6f;
261pub const LDAP_RES_EXTENDED: ber_tag_t = 0x78;
262pub const LDAP_RES_INTERMEDIATE: ber_tag_t = 0x79;
263
264// sasl methods
265pub const LDAP_SASL_SIMPLE: *const c_char = std::ptr::null();
266
267// authentication methods available
268pub const LDAP_AUTH_NONE: ber_tag_t = 0x00;
269pub const LDAP_AUTH_SIMPLE: ber_tag_t = 0x80;
270pub const LDAP_AUTH_SASL: ber_tag_t = 0xa3;
271pub const LDAP_AUTH_KRBV4: ber_tag_t = 0xff;
272pub const LDAP_AUTH_KRBV41: ber_tag_t = 0x81;
273pub const LDAP_AUTH_KRBV42: ber_tag_t = 0x82;
274
275/// Used by the Windows API but not used on the wire
276pub const LDAP_AUTH_NEGOTIATE: ber_tag_t = 0x04FF;
277
278// Filter types
279pub const LDAP_FILTER_AND: ber_tag_t = 0xa0;
280pub const LDAP_FILTER_OR: ber_tag_t = 0xa1;
281pub const LADP_FILTER_NOT: ber_tag_t = 0xa2;
282pub const LDAP_FILTER_EQUALITY: ber_tag_t = 0xa3;
283pub const LDAP_FILTER_SUBSTRINGS: ber_tag_t = 0xa4;
284pub const LDAP_FILTER_GE: ber_tag_t = 0xa5;
285pub const LDAP_FILTER_LE: ber_tag_t = 0xa6;
286pub const LDAP_FILTER_PRESENT: ber_tag_t = 0x87;
287pub const LDAP_FILTER_APPROX: ber_tag_t = 0xa8;
288pub const LDAP_FILTER_EXT: ber_tag_t = 0xa9;
289
290// Extended filter component types
291pub const LDAP_FILTER_EXT_OID: ber_tag_t = 0x81;
292pub const LDAP_FILTER_EXT_TYPE: ber_tag_t = 0x82;
293pub const LDAP_FILTER_EXT_VALUE: ber_tag_t = 0x83;
294pub const LDAP_FILTER_EXT_DNATTRS: ber_tag_t = 0x84;
295
296// Substring filter component types
297pub const LDAP_SUBSTRING_INITIAL: ber_tag_t = 0x80;
298pub const LDAP_SUBSTRING_ANY: ber_tag_t = 0x81;
299pub const LDAP_SUBSTRING_FINAL: ber_tag_t = 0x82;
300
301// Search scopes
302pub const LDAP_SCOPE_BASE: ber_int_t = 0x0000;
303pub const LDAP_SCOPE_BASEOBJECT: ber_int_t = LDAP_SCOPE_BASE;
304pub const LDAP_SCOPE_ONELEVEL: ber_int_t = 0x0001;
305pub const LDAP_SCOPE_ONE: ber_int_t = LDAP_SCOPE_ONELEVEL;
306pub const LDAP_SCOPE_SUBTREE: ber_int_t = 0x0002;
307pub const LDAP_SCOPE_SUB: ber_int_t = LDAP_SCOPE_SUBTREE;
308pub const LDAP_SCOPE_SUBORDINATE: ber_int_t = 0x0003; // OpenLDAP Extension
309pub const LDAP_SCOPE_CHILDREN: ber_int_t = LDAP_SCOPE_SUBORDINATE;
310pub const LDAP_SCOPE_DEFAULT: ber_int_t = -1; // OpenLDAP Extension