75c8adcb5efd056c0eb92a9cb318897e911b0383
[metze/samba/wip.git] / source4 / ldap_server / ldap_server.h
1 /* 
2    Unix SMB/CIFS implementation.
3    LDAP server
4    Copyright (C) Volker Lendecke 2004
5    Copyright (C) Stefan Metzmacher 2004
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "libcli/ldap/libcli_ldap.h"
22 #include "lib/socket/socket.h"
23 #include "lib/stream/packet.h"
24 #include "system/network.h"
25 #include "lib/param/loadparm.h"
26
27 struct ldapsrv_connection {
28         struct ldapsrv_connection *next, *prev;
29         struct loadparm_context *lp_ctx;
30         struct stream_connection *connection;
31         struct gensec_security *gensec;
32         struct auth_session_info *session_info;
33         struct ldapsrv_service *service;
34         struct cli_credentials *server_credentials;
35         struct ldb_context *ldb;
36
37         struct {
38                 struct tevent_queue *send_queue;
39                 struct tevent_req *read_req;
40                 struct tstream_context *raw;
41                 struct tstream_context *tls;
42                 struct tstream_context *sasl;
43                 struct tstream_context *active;
44         } sockets;
45
46         bool global_catalog;
47         bool is_privileged;
48         enum ldap_server_require_strong_auth require_strong_auth;
49         bool authz_logged;
50
51         struct {
52                 int initial_timeout;
53                 int conn_idle_time;
54                 int max_page_size;
55                 int max_notifications;
56                 int search_timeout;
57                 struct timeval endtime;
58                 const char *reason;
59         } limits;
60
61         struct tevent_req *active_call;
62
63         struct ldapsrv_call *pending_calls;
64 };
65
66 struct ldapsrv_call {
67         struct ldapsrv_call *prev, *next;
68         struct ldapsrv_connection *conn;
69         struct ldap_message *request;
70         struct ldapsrv_reply {
71                 struct ldapsrv_reply *prev, *next;
72                 struct ldap_message *msg;
73                 DATA_BLOB blob;
74         } *replies;
75         struct iovec *out_iov;
76         size_t iov_count;
77
78         struct tevent_req *(*wait_send)(TALLOC_CTX *mem_ctx,
79                                         struct tevent_context *ev,
80                                         void *private_data);
81         NTSTATUS (*wait_recv)(struct tevent_req *req);
82         void *wait_private;
83
84         struct tevent_req *(*postprocess_send)(TALLOC_CTX *mem_ctx,
85                                                struct tevent_context *ev,
86                                                void *private_data);
87         NTSTATUS (*postprocess_recv)(struct tevent_req *req);
88         void *postprocess_private;
89
90         struct {
91                 bool busy;
92                 uint64_t generation;
93         } notification;
94 };
95
96 struct ldapsrv_service {
97         struct tstream_tls_params *tls_params;
98         struct task_server *task;
99         struct tevent_queue *call_queue;
100         struct ldapsrv_connection *connections;
101         struct {
102                 uint64_t generation;
103                 struct tevent_req *retry;
104         } notification;
105
106         struct ldb_context *sam_ctx;
107 };
108
109 #include "ldap_server/proto.h"