Make the schema_inferiors generation code to compile
[jra/samba/.git] / source4 / dsdb / schema / schema.h
1 /* 
2    Unix SMB/CIFS mplementation.
3    DSDB schema header
4    
5    Copyright (C) Stefan Metzmacher <metze@samba.org> 2006
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 3 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, see <http://www.gnu.org/licenses/>.
19    
20 */
21
22 #ifndef _DSDB_SCHEMA_H
23 #define _DSDB_SCHEMA_H
24
25 struct dsdb_attribute;
26 struct dsdb_class;
27 struct dsdb_schema;
28
29 struct dsdb_syntax {
30         const char *name;
31         const char *ldap_oid;
32         uint32_t oMSyntax;
33         struct ldb_val oMObjectClass;
34         const char *attributeSyntax_oid;
35         const char *equality;
36         const char *substring;
37         const char *comment;
38         const char *ldb_syntax;
39
40         WERROR (*drsuapi_to_ldb)(struct ldb_context *ldb, 
41                                  const struct dsdb_schema *schema,
42                                  const struct dsdb_attribute *attr,
43                                  const struct drsuapi_DsReplicaAttribute *in,
44                                  TALLOC_CTX *mem_ctx,
45                                  struct ldb_message_element *out);
46         WERROR (*ldb_to_drsuapi)(struct ldb_context *ldb, 
47                                  const struct dsdb_schema *schema,
48                                  const struct dsdb_attribute *attr,
49                                  const struct ldb_message_element *in,
50                                  TALLOC_CTX *mem_ctx,
51                                  struct drsuapi_DsReplicaAttribute *out);
52 };
53
54 struct dsdb_attribute {
55         struct dsdb_attribute *prev, *next;
56
57         const char *cn;
58         const char *lDAPDisplayName;
59         const char *attributeID_oid;
60         uint32_t attributeID_id;
61         struct GUID schemaIDGUID;
62         uint32_t mAPIID;
63
64         struct GUID attributeSecurityGUID;
65
66         uint32_t searchFlags;
67         uint32_t systemFlags;
68         bool isMemberOfPartialAttributeSet;
69         uint32_t linkID;
70
71         const char *attributeSyntax_oid;
72         uint32_t attributeSyntax_id;
73         uint32_t oMSyntax;
74         struct ldb_val oMObjectClass;
75
76         bool isSingleValued;
77         uint32_t *rangeLower;
78         uint32_t *rangeUpper;
79         bool extendedCharsAllowed;
80
81         uint32_t schemaFlagsEx;
82         struct ldb_val msDs_Schema_Extensions;
83
84         bool showInAdvancedViewOnly;
85         const char *adminDisplayName;
86         const char *adminDescription;
87         const char *classDisplayName;
88         bool isEphemeral;
89         bool isDefunct;
90         bool systemOnly;
91
92         /* internal stuff */
93         const struct dsdb_syntax *syntax;
94         const struct ldb_schema_attribute *ldb_schema_attribute;
95 };
96
97 struct dsdb_class {
98         struct dsdb_class *prev, *next;
99
100         const char *cn;
101         const char *lDAPDisplayName;
102         const char *governsID_oid;
103         uint32_t governsID_id;
104         struct GUID schemaIDGUID;
105
106         uint32_t objectClassCategory;
107         const char *rDNAttID;
108         const char *defaultObjectCategory;
109
110         const char *subClassOf;
111
112         const char **systemAuxiliaryClass;
113         const char **systemPossSuperiors;
114         const char **systemMustContain;
115         const char **systemMayContain;
116
117         const char **auxiliaryClass;
118         const char **possSuperiors;
119         const char **mustContain;
120         const char **mayContain;
121         const char **possibleInferiors;
122
123         const char *defaultSecurityDescriptor;
124
125         uint32_t schemaFlagsEx;
126         struct ldb_val msDs_Schema_Extensions;
127
128         bool showInAdvancedViewOnly;
129         const char *adminDisplayName;
130         const char *adminDescription;
131         const char *classDisplayName;
132         bool defaultHidingValue;
133         bool isDefunct;
134         bool systemOnly;
135
136         char **supclasses;
137         char **subclasses;
138         char **subclasses_direct;
139         char **posssuperiors;
140         char **possible_inferiors;
141 };
142
143 struct dsdb_schema_oid_prefix {
144         uint32_t id;
145         const char *oid;
146         size_t oid_len;
147 };
148
149 struct dsdb_schema {
150         uint32_t num_prefixes;
151         struct dsdb_schema_oid_prefix *prefixes;
152
153         /* 
154          * the last element of the prefix mapping table isn't a oid,
155          * it starts with 0xFF and has 21 bytes and is maybe a schema
156          * version number
157          *
158          * this is the content of the schemaInfo attribute of the
159          * Schema-Partition head object.
160          */
161         const char *schema_info;
162
163         struct dsdb_attribute *attributes;
164         struct dsdb_class *classes;
165
166         /* lists of classes sorted by various attributes, for faster
167            access */
168         uint32_t num_classes;
169         struct dsdb_class **classes_by_lDAPDisplayName;
170         struct dsdb_class **classes_by_governsID_id;
171         struct dsdb_class **classes_by_governsID_oid;
172         struct dsdb_class **classes_by_cn;
173
174         /* lists of attributes sorted by various fields */
175         uint32_t num_attributes;
176         struct dsdb_attribute **attributes_by_lDAPDisplayName;
177         struct dsdb_attribute **attributes_by_attributeID_id;
178         struct dsdb_attribute **attributes_by_attributeID_oid;
179         struct dsdb_attribute **attributes_by_linkID;
180
181         struct {
182                 bool we_are_master;
183                 struct ldb_dn *master_dn;
184         } fsmo;
185
186         struct smb_iconv_convenience *iconv_convenience;
187 };
188
189 enum dsdb_attr_list_query {
190         DSDB_SCHEMA_ALL_MAY,
191         DSDB_SCHEMA_ALL_MUST,
192         DSDB_SCHEMA_SYS_MAY,
193         DSDB_SCHEMA_SYS_MUST,
194         DSDB_SCHEMA_MAY,
195         DSDB_SCHEMA_MUST,
196         DSDB_SCHEMA_ALL
197 };
198
199 enum dsdb_schema_convert_target {
200         TARGET_OPENLDAP,
201         TARGET_FEDORA_DS,
202         TARGET_AD_SCHEMA_SUBENTRY
203 };
204
205 #include "dsdb/schema/proto.h"
206
207 #endif /* _DSDB_SCHEMA_H */