source: vendor/current/source3/include/smbldap.h

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 5.4 KB
Line 
1/*
2 Unix SMB/CIFS mplementation.
3 LDAP protocol helper functions for SAMBA
4 Copyright (C) Gerald Carter 2001-2003
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
21#ifndef _SMBLDAP_H
22#define _SMBLDAP_H
23
24#include "include/smb_ldap.h"
25
26#ifdef HAVE_LDAP
27
28#include <talloc.h>
29#include <tevent.h>
30
31/**
32 * Struct to keep the state for all the ldap stuff
33 *
34 */
35
36struct smbldap_state {
37 LDAP *ldap_struct;
38 pid_t pid;
39 time_t last_ping; /* monotonic */
40 /* retrive-once info */
41 const char *uri;
42
43 /* credentials */
44 bool anonymous;
45 char *bind_dn;
46 char *bind_secret;
47 int (*bind_callback)(LDAP *ldap_struct, struct smbldap_state *ldap_state, void *data);
48 void *bind_callback_data;
49
50 bool paged_results;
51
52 unsigned int num_failures;
53
54 time_t last_use; /* monotonic */
55 struct tevent_context *tevent_context;
56 struct tevent_timer *idle_event;
57
58 struct timeval last_rebind; /* monotonic */
59};
60
61/* struct used by both pdb_ldap.c and pdb_nds.c */
62
63struct ipasam_privates;
64
65struct ldapsam_privates {
66 struct smbldap_state *smbldap_state;
67
68 /* Former statics */
69 LDAPMessage *result;
70 LDAPMessage *entry;
71 int index;
72
73 const char *domain_name;
74 struct dom_sid domain_sid;
75
76 /* configuration items */
77 int schema_ver;
78
79 char *domain_dn;
80
81 /* Is this NDS ldap? */
82 int is_nds_ldap;
83
84 /* Is this IPA ldap? */
85 int is_ipa_ldap;
86 struct ipasam_privates *ipasam_privates;
87
88 /* ldap server location parameter */
89 char *location;
90
91 struct {
92 char *filter;
93 LDAPMessage *result;
94 } search_cache;
95};
96
97/* The following definitions come from lib/smbldap.c */
98
99NTSTATUS smbldap_init(TALLOC_CTX *mem_ctx,
100 struct tevent_context *tevent_ctx,
101 const char *location,
102 bool anon,
103 const char *bind_dn,
104 const char *bind_secret,
105 struct smbldap_state **smbldap_state);
106
107void smbldap_set_mod (LDAPMod *** modlist, int modop, const char *attribute, const char *value);
108void smbldap_set_mod_blob(LDAPMod *** modlist, int modop, const char *attribute, const DATA_BLOB *newblob);
109void smbldap_make_mod(LDAP *ldap_struct, LDAPMessage *existing,
110 LDAPMod ***mods,
111 const char *attribute, const char *newval);
112void smbldap_make_mod_blob(LDAP *ldap_struct, LDAPMessage *existing,
113 LDAPMod ***mods,
114 const char *attribute, const DATA_BLOB *newblob);
115bool smbldap_get_single_attribute (LDAP * ldap_struct, LDAPMessage * entry,
116 const char *attribute, char *value,
117 int max_len);
118int smbldap_modify(struct smbldap_state *ldap_state,
119 const char *dn,
120 LDAPMod *attrs[]);
121int smbldap_start_tls(LDAP *ldap_struct, int version);
122int smbldap_setup_full_conn(LDAP **ldap_struct, const char *uri);
123int smbldap_search(struct smbldap_state *ldap_state,
124 const char *base, int scope, const char *filter,
125 const char *attrs[], int attrsonly,
126 LDAPMessage **res);
127int smbldap_search_paged(struct smbldap_state *ldap_state,
128 const char *base, int scope, const char *filter,
129 const char **attrs, int attrsonly, int pagesize,
130 LDAPMessage **res, void **cookie);
131int smbldap_modify(struct smbldap_state *ldap_state, const char *dn, LDAPMod *attrs[]);
132int smbldap_add(struct smbldap_state *ldap_state, const char *dn, LDAPMod *attrs[]);
133int smbldap_delete(struct smbldap_state *ldap_state, const char *dn);
134int smbldap_extended_operation(struct smbldap_state *ldap_state,
135 LDAP_CONST char *reqoid, struct berval *reqdata,
136 LDAPControl **serverctrls, LDAPControl **clientctrls,
137 char **retoidp, struct berval **retdatap);
138int smbldap_search_suffix (struct smbldap_state *ldap_state,
139 const char *filter, const char **search_attr,
140 LDAPMessage ** result);
141void smbldap_free_struct(struct smbldap_state **ldap_state) ;
142bool smbldap_has_control(LDAP *ld, const char *control);
143bool smbldap_has_extension(LDAP *ld, const char *extension);
144bool smbldap_has_naming_context(LDAP *ld, const char *naming_context);
145bool smbldap_set_creds(struct smbldap_state *ldap_state, bool anon, const char *dn, const char *secret);
146char * smbldap_talloc_single_attribute(LDAP *ldap_struct, LDAPMessage *entry,
147 const char *attribute,
148 TALLOC_CTX *mem_ctx);
149char * smbldap_talloc_first_attribute(LDAP *ldap_struct, LDAPMessage *entry,
150 const char *attribute,
151 TALLOC_CTX *mem_ctx);
152char * smbldap_talloc_smallest_attribute(LDAP *ldap_struct, LDAPMessage *entry,
153 const char *attribute,
154 TALLOC_CTX *mem_ctx);
155bool smbldap_talloc_single_blob(TALLOC_CTX *mem_ctx, LDAP *ld,
156 LDAPMessage *msg, const char *attrib,
157 DATA_BLOB *blob);
158bool smbldap_pull_sid(LDAP *ld, LDAPMessage *msg, const char *attrib,
159 struct dom_sid *sid);
160void smbldap_talloc_autofree_ldapmsg(TALLOC_CTX *mem_ctx, LDAPMessage *result);
161void smbldap_talloc_autofree_ldapmod(TALLOC_CTX *mem_ctx, LDAPMod **mod);
162char *smbldap_talloc_dn(TALLOC_CTX *mem_ctx, LDAP *ld,
163 LDAPMessage *entry);
164
165#endif /* HAVE_LDAP */
166
167#endif /* _SMBLDAP_H */
Note: See TracBrowser for help on using the repository browser.