r7746: - added TLS support to our ldap server
[tprouty/samba.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 2 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, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include "libcli/ldap/ldap.h"
23
24 struct rw_buffer {
25         uint8_t *data;
26         size_t ofs, length;
27 };
28
29 enum ldapsrv_call_state {
30         LDAPSRV_CALL_STATE_NEW = 0,
31         LDAPSRV_CALL_STATE_BUSY,
32         LDAPSRV_CALL_STATE_ASYNC,
33         LDAPSRV_CALL_STATE_ABORT,
34         LDAPSRV_CALL_STATE_COMPLETE
35 };
36
37 enum ldapsrv_reply_state {
38         LDAPSRV_REPLY_STATE_NEW = 0,
39         LDAPSRV_REPLY_STATE_SEND
40 };
41
42 struct ldapsrv_connection;
43
44 struct ldapsrv_call {
45         struct ldapsrv_call *prev,*next;
46         enum ldapsrv_call_state state;
47
48         struct ldapsrv_connection *conn;
49
50         struct ldap_message *request;
51
52         struct ldapsrv_reply {
53                 struct ldapsrv_reply *prev,*next;
54                 enum ldapsrv_reply_state state;
55                 struct ldap_message *msg;
56         } *replies;
57 };
58
59 struct ldapsrv_service;
60
61 struct ldapsrv_connection {
62         struct stream_connection *connection;
63
64         struct gensec_security *gensec;
65         struct auth_session_info *session_info;
66
67         struct rw_buffer sasl_in_buffer;
68         struct rw_buffer sasl_out_buffer;
69
70         struct rw_buffer in_buffer;
71         struct rw_buffer out_buffer;
72
73         struct ldapsrv_call *calls;
74
75         struct ldapsrv_service *service;
76
77         struct tls_context *tls;
78 };
79
80 struct ldapsrv_partition;
81
82 struct ldapsrv_partition_ops {
83         const char *name;
84         NTSTATUS (*Init)(struct ldapsrv_partition *partition, struct ldapsrv_connection *conn);
85         NTSTATUS (*Search)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_SearchRequest *r);
86         NTSTATUS (*Modify)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_ModifyRequest *r);
87         NTSTATUS (*Add)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_AddRequest *r);
88         NTSTATUS (*Del)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_DelRequest *r);
89         NTSTATUS (*ModifyDN)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_ModifyDNRequest *r);
90         NTSTATUS (*Compare)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_CompareRequest *r);
91         NTSTATUS (*Abandon)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_AbandonRequest *r);
92         NTSTATUS (*Extended)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_ExtendedRequest *r);
93 };
94
95 struct ldapsrv_partition {
96         struct ldapsrv_partition *prev,*next;
97
98         void *private_data;
99         const struct ldapsrv_partition_ops *ops;
100
101         const char *base_dn;
102 };
103
104 struct ldapsrv_service {
105         struct ldapsrv_partition *rootDSE;
106         struct ldapsrv_partition *default_partition;
107         struct ldapsrv_partition *partitions;
108         struct tls_params *tls_params;
109 };