2 Unix SMB/CIFS Implementation.
4 ldap client side header
6 Copyright (C) Andrew Tridgell 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "system/network.h" /* for struct iovec */
24 #include "libcli/ldap/libcli_ldap.h"
26 enum ldap_request_state
{ LDAP_REQUEST_SEND
=1, LDAP_REQUEST_PENDING
=2, LDAP_REQUEST_DONE
=3, LDAP_REQUEST_ERROR
=4 };
28 /* this is the handle that the caller gets when an async ldap message
31 struct ldap_request
*next
, *prev
;
32 struct ldap_connection
*conn
;
34 enum ldap_request_tag type
;
36 enum ldap_request_state state
;
39 struct ldap_message
**replies
;
43 struct iovec write_iov
;
46 void (*fn
)(struct ldap_request
*);
50 struct tevent_timer
*time_event
;
54 /* main context for a ldap client connection */
55 struct ldap_connection
{
57 struct tstream_context
*raw
;
58 struct tstream_context
*tls
;
59 struct tstream_context
*sasl
;
60 struct tstream_context
*active
;
62 struct tevent_queue
*send_queue
;
63 struct tevent_req
*recv_subreq
;
66 struct loadparm_context
*lp_ctx
;
74 const char *simple_pw
;
84 enum { LDAP_BIND_SIMPLE
, LDAP_BIND_SASL
} type
;
88 /* next message id to assign */
89 unsigned next_messageid
;
91 /* Outstanding LDAP requests that have not yet been replied to */
92 struct ldap_request
*pending
;
94 /* Let's support SASL */
95 struct gensec_security
*gensec
;
97 /* the default timeout for messages */
100 /* last error message */
104 struct tevent_context
*event_ctx
;
108 struct ldap_connection
*ldap4_new_connection(TALLOC_CTX
*mem_ctx
,
109 struct loadparm_context
*lp_ctx
,
110 struct tevent_context
*ev
);
112 NTSTATUS
ldap_connect(struct ldap_connection
*conn
, const char *url
);
113 struct composite_context
*ldap_connect_send(struct ldap_connection
*conn
,
116 NTSTATUS
ldap_rebind(struct ldap_connection
*conn
);
117 NTSTATUS
ldap_bind_simple(struct ldap_connection
*conn
,
118 const char *userdn
, const char *password
);
119 NTSTATUS
ldap_bind_sasl(struct ldap_connection
*conn
,
120 struct cli_credentials
*creds
,
121 struct loadparm_context
*lp_ctx
);
122 struct ldap_request
*ldap_request_send(struct ldap_connection
*conn
,
123 struct ldap_message
*msg
);
124 NTSTATUS
ldap_request_wait(struct ldap_request
*req
);
125 struct composite_context
;
126 NTSTATUS
ldap_connect_recv(struct composite_context
*ctx
);
127 NTSTATUS
ldap_result_n(struct ldap_request
*req
, int n
, struct ldap_message
**msg
);
128 NTSTATUS
ldap_result_one(struct ldap_request
*req
, struct ldap_message
**msg
, int type
);
129 NTSTATUS
ldap_transaction(struct ldap_connection
*conn
, struct ldap_message
*msg
);
130 const char *ldap_errstr(struct ldap_connection
*conn
,
133 NTSTATUS
ldap_check_response(struct ldap_connection
*conn
, struct ldap_Result
*r
);
134 void ldap_set_reconn_params(struct ldap_connection
*conn
, int max_retries
);
135 int ildap_count_entries(struct ldap_connection
*conn
, struct ldap_message
**res
);
136 NTSTATUS
ildap_search_bytree(struct ldap_connection
*conn
, const char *basedn
,
137 int scope
, struct ldb_parse_tree
*tree
,
138 const char * const *attrs
, bool attributesonly
,
139 struct ldb_control
**control_req
,
140 struct ldb_control
***control_res
,
141 struct ldap_message
***results
);
142 NTSTATUS
ildap_search(struct ldap_connection
*conn
, const char *basedn
,
143 int scope
, const char *expression
,
144 const char * const *attrs
, bool attributesonly
,
145 struct ldb_control
**control_req
,
146 struct ldb_control
***control_res
,
147 struct ldap_message
***results
);