r23792: convert Samba4 to GPLv3
[tprouty/samba.git] / source4 / libcli / ldap / ldap_client.h
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
25 enum 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 */
29 struct 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 timed_event *time_event;
48 };
49
50
51 /* main context for a ldap client connection */
52 struct ldap_connection {
53         struct socket_context *sock;
54         char *host;
55         uint16_t port;
56         BOOL ldaps;
57
58         const char *auth_dn;
59         const char *simple_pw;
60
61         struct {
62                 char *url;
63                 int max_retries;
64                 int retries;
65                 time_t previous;
66         } reconnect;
67
68         struct {
69                 enum { LDAP_BIND_SIMPLE, LDAP_BIND_SASL } type;
70                 void *creds;
71         } bind;
72
73         /* next message id to assign */
74         unsigned next_messageid;
75
76         /* Outstanding LDAP requests that have not yet been replied to */
77         struct ldap_request *pending;
78
79         /* Let's support SASL */
80         struct gensec_security *gensec;
81
82         /* the default timeout for messages */
83         int timeout;
84
85         /* last error message */
86         char *last_error;
87
88         struct {
89                 struct event_context *event_ctx;
90                 struct fd_event *fde;
91         } event;
92
93         struct packet_context *packet;
94 };