r7747: - simplified the ldap server buffer handling
[mat/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 ldapsrv_connection {
25         struct stream_connection *connection;
26         struct gensec_security *gensec;
27         struct auth_session_info *session_info;
28         struct ldapsrv_service *service;
29         struct tls_context *tls;
30
31         /* partially received request */
32         DATA_BLOB partial;
33
34         /* are we using gensec wrapping? */
35         BOOL enable_wrap;
36
37         /* reply send queue */
38         struct ldapsrv_send {
39                 struct ldapsrv_send *next, *prev;
40                 DATA_BLOB data;
41         } *send_queue;
42 };
43
44 struct ldapsrv_call {
45         struct ldapsrv_connection *conn;
46         struct ldap_message *request;
47         struct ldapsrv_reply {
48                 struct ldapsrv_reply *prev, *next;
49                 struct ldap_message *msg;
50         } *replies;
51 };
52
53 struct ldapsrv_service;
54 struct ldapsrv_partition;
55
56 struct ldapsrv_partition_ops {
57         const char *name;
58         NTSTATUS (*Init)(struct ldapsrv_partition *partition, struct ldapsrv_connection *conn);
59         NTSTATUS (*Search)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_SearchRequest *r);
60         NTSTATUS (*Modify)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_ModifyRequest *r);
61         NTSTATUS (*Add)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_AddRequest *r);
62         NTSTATUS (*Del)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_DelRequest *r);
63         NTSTATUS (*ModifyDN)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_ModifyDNRequest *r);
64         NTSTATUS (*Compare)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_CompareRequest *r);
65         NTSTATUS (*Abandon)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_AbandonRequest *r);
66         NTSTATUS (*Extended)(struct ldapsrv_partition *partition, struct ldapsrv_call *call, struct ldap_ExtendedRequest *r);
67 };
68
69 struct ldapsrv_partition {
70         struct ldapsrv_partition *prev,*next;
71
72         void *private_data;
73         const struct ldapsrv_partition_ops *ops;
74
75         const char *base_dn;
76 };
77
78 struct ldapsrv_service {
79         struct ldapsrv_partition *rootDSE;
80         struct ldapsrv_partition *default_partition;
81         struct ldapsrv_partition *partitions;
82         struct tls_params *tls_params;
83 };