2 Unix SMB/CIFS mplementation.
3 LDAP protocol helper functions for SAMBA
4 Copyright (C) Gerald Carter 2001-2003
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.
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.
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/>.
24 #include "include/smb_ldap.h"
32 * Struct to keep the state for all the ldap stuff
37 typedef int (*smbldap_bind_callback_fn)(LDAP *ldap_struct,
38 struct smbldap_state *ldap_state,
41 /* The following definitions come from lib/smbldap.c */
43 NTSTATUS smbldap_init(TALLOC_CTX *mem_ctx,
44 struct tevent_context *tevent_ctx,
48 const char *bind_secret,
49 struct smbldap_state **smbldap_state);
51 LDAP *smbldap_get_ldap(struct smbldap_state *state);
52 bool smbldap_get_paged_results(struct smbldap_state *state);
53 void smbldap_set_paged_results(struct smbldap_state *state,
56 void smbldap_set_bind_callback(struct smbldap_state *state,
57 smbldap_bind_callback_fn callback,
60 void smbldap_set_mod (LDAPMod *** modlist, int modop, const char *attribute, const char *value);
61 void smbldap_set_mod_blob(LDAPMod *** modlist, int modop, const char *attribute, const DATA_BLOB *newblob);
62 void smbldap_make_mod(LDAP *ldap_struct, LDAPMessage *existing,
64 const char *attribute, const char *newval);
65 void smbldap_make_mod_blob(LDAP *ldap_struct, LDAPMessage *existing,
67 const char *attribute, const DATA_BLOB *newblob);
68 bool smbldap_get_single_attribute (LDAP * ldap_struct, LDAPMessage * entry,
69 const char *attribute, char *value,
71 int smbldap_modify(struct smbldap_state *ldap_state,
74 int smbldap_start_tls(LDAP *ldap_struct, int version);
75 int smbldap_setup_full_conn(LDAP **ldap_struct, const char *uri);
76 int smbldap_search(struct smbldap_state *ldap_state,
77 const char *base, int scope, const char *filter,
78 const char *attrs[], int attrsonly,
80 int smbldap_search_paged(struct smbldap_state *ldap_state,
81 const char *base, int scope, const char *filter,
82 const char **attrs, int attrsonly, int pagesize,
83 LDAPMessage **res, void **cookie);
84 int smbldap_modify(struct smbldap_state *ldap_state, const char *dn, LDAPMod *attrs[]);
85 int smbldap_add(struct smbldap_state *ldap_state, const char *dn, LDAPMod *attrs[]);
86 int smbldap_delete(struct smbldap_state *ldap_state, const char *dn);
87 int smbldap_extended_operation(struct smbldap_state *ldap_state,
88 LDAP_CONST char *reqoid, struct berval *reqdata,
89 LDAPControl **serverctrls, LDAPControl **clientctrls,
90 char **retoidp, struct berval **retdatap);
91 int smbldap_search_suffix (struct smbldap_state *ldap_state,
92 const char *filter, const char **search_attr,
93 LDAPMessage ** result);
94 void smbldap_free_struct(struct smbldap_state **ldap_state) ;
95 bool smbldap_has_control(LDAP *ld, const char *control);
96 bool smbldap_has_extension(LDAP *ld, const char *extension);
97 bool smbldap_has_naming_context(LDAP *ld, const char *naming_context);
98 bool smbldap_set_creds(struct smbldap_state *ldap_state, bool anon, const char *dn, const char *secret);
99 char * smbldap_talloc_single_attribute(LDAP *ldap_struct, LDAPMessage *entry,
100 const char *attribute,
101 TALLOC_CTX *mem_ctx);
102 char * smbldap_talloc_first_attribute(LDAP *ldap_struct, LDAPMessage *entry,
103 const char *attribute,
104 TALLOC_CTX *mem_ctx);
105 char * smbldap_talloc_smallest_attribute(LDAP *ldap_struct, LDAPMessage *entry,
106 const char *attribute,
107 TALLOC_CTX *mem_ctx);
108 bool smbldap_talloc_single_blob(TALLOC_CTX *mem_ctx, LDAP *ld,
109 LDAPMessage *msg, const char *attrib,
111 bool smbldap_pull_sid(LDAP *ld, LDAPMessage *msg, const char *attrib,
112 struct dom_sid *sid);
113 void smbldap_talloc_autofree_ldapmsg(TALLOC_CTX *mem_ctx, LDAPMessage *result);
114 void smbldap_talloc_autofree_ldapmod(TALLOC_CTX *mem_ctx, LDAPMod **mod);
115 char *smbldap_talloc_dn(TALLOC_CTX *mem_ctx, LDAP *ld,
118 #endif /* HAVE_LDAP */
120 #endif /* _SMBLDAP_H */