source: branches/samba-3.5.x/source4/libcli/ldap/ldap_client.h

Last change on this file was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

File size: 4.2 KB
Line 
1/*
2 Unix SMB/CIFS Implementation.
3
4 ldap client side header
5
6 Copyright (C) Andrew Tridgell 2005
7
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.
12
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.
17
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/>.
20*/
21
22
23#include "libcli/ldap/ldap.h"
24
25enum ldap_request_state { LDAP_REQUEST_SEND=1, LDAP_REQUEST_PENDING=2, LDAP_REQUEST_DONE=3, LDAP_REQUEST_ERROR=4 };
26
27/* this is the handle that the caller gets when an async ldap message
28 is sent */
29struct ldap_request {
30 struct ldap_request *next, *prev;
31 struct ldap_connection *conn;
32
33 enum ldap_request_tag type;
34 int messageid;
35 enum ldap_request_state state;
36
37 int num_replies;
38 struct ldap_message **replies;
39
40 NTSTATUS status;
41 DATA_BLOB data;
42 struct {
43 void (*fn)(struct ldap_request *);
44 void *private_data;
45 } async;
46
47 struct tevent_timer *time_event;
48};
49
50
51/* main context for a ldap client connection */
52struct ldap_connection {
53 struct socket_context *sock;
54 struct loadparm_context *lp_ctx;
55
56 char *host;
57 uint16_t port;
58 bool ldaps;
59
60 const char *auth_dn;
61 const char *simple_pw;
62
63 struct {
64 char *url;
65 int max_retries;
66 int retries;
67 time_t previous;
68 } reconnect;
69
70 struct {
71 enum { LDAP_BIND_SIMPLE, LDAP_BIND_SASL } type;
72 void *creds;
73 } bind;
74
75 /* next message id to assign */
76 unsigned next_messageid;
77
78 /* Outstanding LDAP requests that have not yet been replied to */
79 struct ldap_request *pending;
80
81 /* Let's support SASL */
82 struct gensec_security *gensec;
83
84 /* the default timeout for messages */
85 int timeout;
86
87 /* last error message */
88 char *last_error;
89
90 struct {
91 struct tevent_context *event_ctx;
92 struct tevent_fd *fde;
93 } event;
94
95 struct packet_context *packet;
96};
97
98struct ldap_connection *ldap4_new_connection(TALLOC_CTX *mem_ctx,
99 struct loadparm_context *lp_ctx,
100 struct tevent_context *ev);
101
102NTSTATUS ldap_connect(struct ldap_connection *conn, const char *url);
103struct composite_context *ldap_connect_send(struct ldap_connection *conn,
104 const char *url);
105
106NTSTATUS ldap_rebind(struct ldap_connection *conn);
107NTSTATUS ldap_bind_simple(struct ldap_connection *conn,
108 const char *userdn, const char *password);
109NTSTATUS ldap_bind_sasl(struct ldap_connection *conn,
110 struct cli_credentials *creds,
111 struct loadparm_context *lp_ctx);
112struct ldap_request *ldap_request_send(struct ldap_connection *conn,
113 struct ldap_message *msg);
114NTSTATUS ldap_request_wait(struct ldap_request *req);
115struct composite_context;
116NTSTATUS ldap_connect_recv(struct composite_context *ctx);
117NTSTATUS ldap_result_n(struct ldap_request *req, int n, struct ldap_message **msg);
118NTSTATUS ldap_result_one(struct ldap_request *req, struct ldap_message **msg, int type);
119NTSTATUS ldap_transaction(struct ldap_connection *conn, struct ldap_message *msg);
120const char *ldap_errstr(struct ldap_connection *conn,
121 TALLOC_CTX *mem_ctx,
122 NTSTATUS status);
123NTSTATUS ldap_check_response(struct ldap_connection *conn, struct ldap_Result *r);
124void ldap_set_reconn_params(struct ldap_connection *conn, int max_retries);
125int ildap_count_entries(struct ldap_connection *conn, struct ldap_message **res);
126NTSTATUS ildap_search_bytree(struct ldap_connection *conn, const char *basedn,
127 int scope, struct ldb_parse_tree *tree,
128 const char * const *attrs, bool attributesonly,
129 struct ldb_control **control_req,
130 struct ldb_control ***control_res,
131 struct ldap_message ***results);
132NTSTATUS ildap_search(struct ldap_connection *conn, const char *basedn,
133 int scope, const char *expression,
134 const char * const *attrs, bool attributesonly,
135 struct ldb_control **control_req,
136 struct ldb_control ***control_res,
137 struct ldap_message ***results);
138
139
140
Note: See TracBrowser for help on using the repository browser.