~zulcss/samba/server-dailies-3.4

« back to all changes in this revision

Viewing changes to source3/winbindd/idmap_adex/idmap_adex.h

  • Committer: Chuck Short
  • Date: 2010-09-28 20:38:39 UTC
  • Revision ID: zulcss@ubuntu.com-20100928203839-pgjulytsi9ue63x1
Initial version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * idmap_centeris: Support for Local IDs and Centeris Cell Structure
 
3
 *
 
4
 * Copyright (C) Gerald (Jerry) Carter 2006-2008
 
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 2 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, write to the Free Software
 
18
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
19
 */
 
20
 
 
21
#ifndef _IDMAP_ADEX_H
 
22
#define _IDMAP_ADEX_H
 
23
 
 
24
#include "winbindd/winbindd.h"
 
25
 
 
26
#define ADEX_CELL_RDN             "$LikewiseIdentityCell"
 
27
 
 
28
#define ADEX_OC_USER              "centerisLikewiseUser"
 
29
#define ADEX_OC_GROUP             "centerisLikewiseGroup"
 
30
 
 
31
#define AD_USER                 "User"
 
32
#define AD_GROUP                "Group"
 
33
 
 
34
#define ADEX_OC_POSIX_USER        "posixAccount"
 
35
#define ADEX_OC_POSIX_GROUP       "posixGroup"
 
36
 
 
37
#define ADEX_ATTR_UIDNUM          "uidNumber"
 
38
#define ADEX_ATTR_GIDNUM          "gidNUmber"
 
39
#define ADEX_ATTR_HOMEDIR         "unixHomeDirectory"
 
40
#define ADEX_ATTR_USERPW          "unixUserPassword"
 
41
#define ADEX_ATTR_GROUPALIAS      "groupAlias"  /* Not part of RFC2307 */
 
42
#define ADEX_ATTR_SHELL           "loginShell"
 
43
#define ADEX_ATTR_GECOS           "gecos"
 
44
#define ADEX_ATTR_UID             "uid"
 
45
#define ADEX_ATTR_DISPLAYNAME     "displayName"
 
46
 
 
47
#define MIN_ID_VALUE            100
 
48
 
 
49
#define BAIL_ON_NTSTATUS_ERROR(x)          \
 
50
        do {                               \
 
51
                if (!NT_STATUS_IS_OK(x)) { \
 
52
                        DEBUG(10,("Failed! (%s)\n", nt_errstr(x)));     \
 
53
                        goto done;         \
 
54
                }                          \
 
55
        }                                  \
 
56
        while (0);                         \
 
57
 
 
58
#define WARN_ON_NTSTATUS_ERROR(x)          \
 
59
        do {                               \
 
60
                if (!NT_STATUS_IS_OK(x)) { \
 
61
                        DEBUG(10,("Failure ignored! (%s)\n", nt_errstr(x)));    \
 
62
                }                          \
 
63
        }                                  \
 
64
        while (0);                         \
 
65
 
 
66
#define BAIL_ON_ADS_ERROR(x)               \
 
67
        do {                               \
 
68
                if (!ADS_ERR_OK(x)) {      \
 
69
                        goto done;         \
 
70
                }                          \
 
71
        }                                  \
 
72
        while (0);
 
73
 
 
74
#define BAIL_ON_PTR_ERROR(p, x)                         \
 
75
        do {                                            \
 
76
                if ((p) == NULL ) {                     \
 
77
                        DEBUG(10,("NULL pointer!\n"));  \
 
78
                        x = NT_STATUS_NO_MEMORY;        \
 
79
                        goto done;                      \
 
80
                }                                       \
 
81
        } while (0);
 
82
 
 
83
#define PRINT_NTSTATUS_ERROR(x, hdr, level)                             \
 
84
        do {                                                            \
 
85
                if (!NT_STATUS_IS_OK(x)) {                              \
 
86
                        DEBUG(level,("LWI ("hdr"): %s\n", nt_errstr(x))); \
 
87
                }                                                       \
 
88
        } while(0);
 
89
/*
 
90
 * Cell Provider API
 
91
 */
 
92
 
 
93
struct cell_provider_api {
 
94
        NTSTATUS(*get_sid_from_id) (DOM_SID * sid,
 
95
                                    uint32_t id, enum id_type type);
 
96
        NTSTATUS(*get_id_from_sid) (uint32_t * id,
 
97
                                    enum id_type * type, const DOM_SID * sid);
 
98
        NTSTATUS(*get_nss_info) (const DOM_SID * sid,
 
99
                                 TALLOC_CTX * ctx,
 
100
                                 char **homedir,
 
101
                                 char **shell, char **gecos, gid_t * p_gid);
 
102
        NTSTATUS(*map_to_alias) (TALLOC_CTX * mem_ctx,
 
103
                                 const char *domain,
 
104
                                 const char *name, char **alias);
 
105
        NTSTATUS(*map_from_alias) (TALLOC_CTX * mem_ctx,
 
106
                                   const char *domain,
 
107
                                   const char *alias, char **name);
 
108
};
 
109
 
 
110
/* registered providers */
 
111
 
 
112
extern struct cell_provider_api ccp_unified;
 
113
extern struct cell_provider_api ccp_local;
 
114
 
 
115
#define LWCELL_FLAG_USE_RFC2307_ATTRS     0x00000001
 
116
#define LWCELL_FLAG_SEARCH_FOREST         0x00000002
 
117
#define LWCELL_FLAG_GC_CELL               0x00000004
 
118
#define LWCELL_FLAG_LOCAL_MODE            0x00000008
 
119
 
 
120
struct likewise_cell {
 
121
        struct likewise_cell *prev, *next;
 
122
        ADS_STRUCT *conn;
 
123
        struct likewise_cell *gc_search_cell;
 
124
        DOM_SID domain_sid;
 
125
        char *dns_domain;
 
126
        char *forest_name;
 
127
        char *dn;
 
128
        struct GUID *links;        /* only held by owning cell */
 
129
        size_t num_links;
 
130
        uint32_t flags;
 
131
        struct cell_provider_api *provider;
 
132
};
 
133
 
 
134
/* Search flags used for Global Catalog API */
 
135
 
 
136
#define ADEX_GC_SEARCH_CHECK_UNIQUE        0x00000001
 
137
 
 
138
struct gc_info {
 
139
        struct gc_info *prev, *next;
 
140
        char *forest_name;
 
141
        char *search_base;
 
142
        struct likewise_cell *forest_cell;
 
143
};
 
144
 
 
145
/* Available functions outside of idmap_lwidentity.c */
 
146
 
 
147
/* cell_util.c */
 
148
 
 
149
char *find_attr_string(char **list, size_t num_lines, const char *substr);
 
150
bool is_object_class(char **list, size_t num_lines, const char *substr);
 
151
int min_id_value(void);
 
152
char *cell_dn_to_dns(const char *dn);
 
153
NTSTATUS get_sid_type(ADS_STRUCT *ads,
 
154
                      LDAPMessage *msg,
 
155
                      enum lsa_SidType *type);
 
156
 
 
157
NTSTATUS cell_locate_membership(ADS_STRUCT * ads);
 
158
NTSTATUS cell_lookup_settings(struct likewise_cell * cell);
 
159
NTSTATUS cell_follow_links(struct likewise_cell *cell);
 
160
NTSTATUS cell_set_local_provider(void);
 
161
 
 
162
/* likewise_cell.c */
 
163
 
 
164
struct likewise_cell *cell_new(void);
 
165
struct likewise_cell *cell_list_head(void);
 
166
 
 
167
bool cell_list_add(struct likewise_cell *cell);
 
168
bool cell_list_remove(struct likewise_cell * cell);
 
169
 
 
170
void cell_list_destroy(void);
 
171
void cell_destroy(struct likewise_cell *c);
 
172
void cell_set_forest_searches(struct likewise_cell *c,
 
173
                                bool search);
 
174
void cell_set_dns_domain(struct likewise_cell *c,
 
175
                           const char *dns_domain);
 
176
void cell_set_connection(struct likewise_cell *c,
 
177
                           ADS_STRUCT *ads);
 
178
void cell_set_dn(struct likewise_cell *c,
 
179
                   const char *dn);
 
180
void cell_set_domain_sid(struct likewise_cell *c,
 
181
                           DOM_SID *sid);
 
182
void cell_set_flags(struct likewise_cell *c, uint32_t flags);
 
183
void cell_clear_flags(struct likewise_cell *c, uint32_t flags);
 
184
 
 
185
const char* cell_search_base(struct likewise_cell *c);
 
186
const char *cell_dns_domain(struct likewise_cell *c);
 
187
ADS_STRUCT *cell_connection(struct likewise_cell *c);
 
188
bool cell_search_forest(struct likewise_cell *c);
 
189
ADS_STATUS cell_do_search(struct likewise_cell *c,
 
190
                          const char *search_base,
 
191
                          int scope,
 
192
                          const char *expr,
 
193
                          const char **attrs,
 
194
                          LDAPMessage ** msg);
 
195
uint32_t cell_flags(struct likewise_cell *c);
 
196
 
 
197
NTSTATUS cell_connect_dn(struct likewise_cell **c,
 
198
                         const char *dn);
 
199
NTSTATUS cell_connect(struct likewise_cell *c);
 
200
 
 
201
 
 
202
/* gc_util.c */
 
203
 
 
204
NTSTATUS gc_init_list(void);
 
205
 
 
206
NTSTATUS gc_find_forest_root(struct gc_info *gc,
 
207
                             const char *domain);
 
208
 
 
209
struct gc_info *gc_search_start(void);
 
210
 
 
211
NTSTATUS gc_search_forest(struct gc_info *gc,
 
212
                          LDAPMessage **msg,
 
213
                          const char *filter);
 
214
 
 
215
NTSTATUS gc_search_all_forests(const char *filter,
 
216
                               ADS_STRUCT ***ads_list,
 
217
                               LDAPMessage ***msg_list,
 
218
                               int *num_resp, uint32_t flags);
 
219
 
 
220
NTSTATUS gc_search_all_forests_unique(const char *filter,
 
221
                                      ADS_STRUCT **ads,
 
222
                                      LDAPMessage **msg);
 
223
 
 
224
NTSTATUS gc_name_to_sid(const char *domain,
 
225
                        const char *name,
 
226
                        DOM_SID *sid,
 
227
                        enum lsa_SidType *sid_type);
 
228
 
 
229
NTSTATUS gc_sid_to_name(const DOM_SID *sid,
 
230
                        char **name,
 
231
                        enum lsa_SidType *sid_type);
 
232
 
 
233
NTSTATUS add_ads_result_to_array(ADS_STRUCT *ads,
 
234
                                 LDAPMessage *msg,
 
235
                                 ADS_STRUCT ***ads_list,
 
236
                                 LDAPMessage ***msg_list,
 
237
                                 int *size);
 
238
 
 
239
void free_result_array(ADS_STRUCT **ads_list,
 
240
                       LDAPMessage **msg_list,
 
241
                       int num_resp);
 
242
 
 
243
NTSTATUS check_result_unique(ADS_STRUCT *ads,
 
244
                             LDAPMessage *msg);
 
245
 
 
246
 
 
247
/* domain_util.c */
 
248
 
 
249
NTSTATUS domain_init_list(void);
 
250
 
 
251
NTSTATUS dc_search_domains(struct likewise_cell **cell,
 
252
                           LDAPMessage **msg,
 
253
                           const char *dn,
 
254
                           const DOM_SID *user_sid);
 
255
 
 
256
 
 
257
#endif  /* _IDMAP_ADEX_H */