Add tldap paged searches, together with two helper routines
[kai/samba.git] / source3 / include / tldap_util.h
1 /*
2    Unix SMB/CIFS implementation.
3    Infrastructure for async ldap client requests
4    Copyright (C) Volker Lendecke 2009
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef __TLDAP_UTIL_H__
21 #define __TLDAP_UTIL_H__
22
23 #include "includes.h"
24
25 bool tldap_entry_values(struct tldap_message *msg, const char *attribute,
26                         int *num_values, DATA_BLOB **values);
27 bool tldap_get_single_valueblob(struct tldap_message *msg,
28                                 const char *attribute, DATA_BLOB *blob);
29 char *tldap_talloc_single_attribute(struct tldap_message *msg,
30                                     const char *attribute,
31                                     TALLOC_CTX *mem_ctx);
32 bool tldap_pull_binsid(struct tldap_message *msg, const char *attribute,
33                        struct dom_sid *sid);
34 bool tldap_add_mod_blobs(TALLOC_CTX *mem_ctx, struct tldap_mod **pmods,
35                          int mod_op, const char *attrib,
36                          int num_values, DATA_BLOB *values);
37 bool tldap_add_mod_str(TALLOC_CTX *mem_ctx, struct tldap_mod **pmods,
38                        int mod_op, const char *attrib, const char *str);
39 bool tldap_make_mod_blob(struct tldap_message *existing, TALLOC_CTX *mem_ctx,
40                          int *pnum_mods, struct tldap_mod **pmods,
41                          const char *attrib, DATA_BLOB newval);
42 bool tldap_make_mod_fmt(struct tldap_message *existing, TALLOC_CTX *mem_ctx,
43                         int *pnum_mods, struct tldap_mod **pmods,
44                         const char *attrib, const char *fmt, ...);
45
46 const char *tldap_errstr(TALLOC_CTX *mem_ctx, struct tldap_context *ld,
47                          int rc);
48 int tldap_search_fmt(struct tldap_context *ld, const char *base, int scope,
49                      const char *attrs[], int num_attrs, int attrsonly,
50                      TALLOC_CTX *mem_ctx, struct tldap_message ***res,
51                      const char *fmt, ...);
52 bool tldap_pull_uint64(struct tldap_message *msg, const char *attr,
53                        uint64_t *presult);
54 bool tldap_pull_uint32(struct tldap_message *msg, const char *attr,
55                        uint32_t *presult);
56
57 struct tevent_req *tldap_fetch_rootdse_send(TALLOC_CTX *mem_ctx,
58                                             struct tevent_context *ev,
59                                             struct tldap_context *ld);
60 int tldap_fetch_rootdse_recv(struct tevent_req *req);
61 int tldap_fetch_rootdse(struct tldap_context *ld);
62 struct tldap_message *tldap_rootdse(struct tldap_context *ld);
63
64 bool tldap_entry_has_attrvalue(struct tldap_message *msg,
65                                const char *attribute,
66                                const DATA_BLOB blob);
67 bool tldap_supports_control(struct tldap_context *ld, const char *oid);
68
69 struct tldap_control *tldap_add_control(TALLOC_CTX *mem_ctx,
70                                         struct tldap_control *ctrls,
71                                         int num_ctrls,
72                                         struct tldap_control *ctrl);
73 struct tldap_control *tldap_msg_findcontrol(struct tldap_message *msg,
74                                             const char *oid);
75
76 struct tevent_req *tldap_search_paged_send(TALLOC_CTX *mem_ctx,
77                                            struct tevent_context *ev,
78                                            struct tldap_context *ld,
79                                            const char *base, int scope,
80                                            const char *filter,
81                                            const char **attrs,
82                                            int num_attrs,
83                                            int attrsonly,
84                                            struct tldap_control *sctrls,
85                                            int num_sctrls,
86                                            struct tldap_control *cctrls,
87                                            int num_cctrls,
88                                            int timelimit,
89                                            int sizelimit,
90                                            int deref,
91                                            int page_size);
92 int tldap_search_paged_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
93                             struct tldap_message **pmsg);
94
95
96 #endif