6c9ec96dfe4894df64f56838ddd03fe1a630f239
[ira/wip.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 #include "prefixmap.h"
26
27 struct dsdb_attribute;
28 struct dsdb_class;
29 struct dsdb_schema;
30
31 struct dsdb_syntax {
32         const char *name;
33         const char *ldap_oid;
34         uint32_t oMSyntax;
35         struct ldb_val oMObjectClass;
36         const char *attributeSyntax_oid;
37         const char *equality;
38         const char *substring;
39         const char *comment;
40         const char *ldb_syntax;
41
42         WERROR (*drsuapi_to_ldb)(struct ldb_context *ldb, 
43                                  const struct dsdb_schema *schema,
44                                  const struct dsdb_attribute *attr,
45                                  const struct drsuapi_DsReplicaAttribute *in,
46                                  TALLOC_CTX *mem_ctx,
47                                  struct ldb_message_element *out);
48         WERROR (*ldb_to_drsuapi)(struct ldb_context *ldb, 
49                                  const struct dsdb_schema *schema,
50                                  const struct dsdb_attribute *attr,
51                                  const struct ldb_message_element *in,
52                                  TALLOC_CTX *mem_ctx,
53                                  struct drsuapi_DsReplicaAttribute *out);
54 };
55
56 struct dsdb_attribute {
57         struct dsdb_attribute *prev, *next;
58
59         const char *cn;
60         const char *lDAPDisplayName;
61         const char *attributeID_oid;
62         uint32_t attributeID_id;
63         struct GUID schemaIDGUID;
64         uint32_t mAPIID;
65
66         struct GUID attributeSecurityGUID;
67
68         uint32_t searchFlags;
69         uint32_t systemFlags;
70         bool isMemberOfPartialAttributeSet;
71         uint32_t linkID;
72
73         const char *attributeSyntax_oid;
74         uint32_t attributeSyntax_id;
75         uint32_t oMSyntax;
76         struct ldb_val oMObjectClass;
77
78         bool isSingleValued;
79         uint32_t *rangeLower;
80         uint32_t *rangeUpper;
81         bool extendedCharsAllowed;
82
83         uint32_t schemaFlagsEx;
84         struct ldb_val msDs_Schema_Extensions;
85
86         bool showInAdvancedViewOnly;
87         const char *adminDisplayName;
88         const char *adminDescription;
89         const char *classDisplayName;
90         bool isEphemeral;
91         bool isDefunct;
92         bool systemOnly;
93
94         /* internal stuff */
95         const struct dsdb_syntax *syntax;
96         const struct ldb_schema_attribute *ldb_schema_attribute;
97 };
98
99 struct dsdb_class {
100         struct dsdb_class *prev, *next;
101
102         const char *cn;
103         const char *lDAPDisplayName;
104         const char *governsID_oid;
105         uint32_t governsID_id;
106         struct GUID schemaIDGUID;
107
108         uint32_t objectClassCategory;
109         const char *rDNAttID;
110         const char *defaultObjectCategory;
111
112         const char *subClassOf;
113
114         const char **systemAuxiliaryClass;
115         const char **systemPossSuperiors;
116         const char **systemMustContain;
117         const char **systemMayContain;
118
119         const char **auxiliaryClass;
120         const char **possSuperiors;
121         const char **mustContain;
122         const char **mayContain;
123         const char **possibleInferiors;
124         const char **systemPossibleInferiors;
125
126         const char *defaultSecurityDescriptor;
127
128         uint32_t schemaFlagsEx;
129         struct ldb_val msDs_Schema_Extensions;
130
131         bool showInAdvancedViewOnly;
132         const char *adminDisplayName;
133         const char *adminDescription;
134         const char *classDisplayName;
135         bool defaultHidingValue;
136         bool isDefunct;
137         bool systemOnly;
138
139         char **supclasses;
140         char **subclasses;
141         char **subclasses_direct;
142         char **posssuperiors;
143         uint32_t subClassOf_id;
144         uint32_t *systemAuxiliaryClass_ids;
145         uint32_t *auxiliaryClass_ids;
146         uint32_t *systemMayContain_ids;
147         uint32_t *systemMustContain_ids;
148         uint32_t *possSuperiors_ids;
149         uint32_t *mustContain_ids;
150         uint32_t *mayContain_ids;
151         uint32_t *systemPossSuperiors_ids;
152
153         /* An ordered index showing how this subClass fits into the
154          * subClass tree.  that is, an objectclass that is not
155          * subClassOf anything is 0 (just in case), and top is 1, and
156          * subClasses of top are 2, subclasses of those classes are
157          * 3 */ 
158         uint32_t subClass_order;
159 };
160
161 struct dsdb_schema_oid_prefix {
162         uint32_t id;
163         const char *oid;
164         size_t oid_len;
165 };
166
167 struct dsdb_schema {
168         uint32_t num_prefixes;
169         struct dsdb_schema_oid_prefix *prefixes;
170
171         struct dsdb_schema_prefixmap *prefixmap;
172
173         /* 
174          * the last element of the prefix mapping table isn't a oid,
175          * it starts with 0xFF and has 21 bytes and is maybe a schema
176          * version number
177          *
178          * this is the content of the schemaInfo attribute of the
179          * Schema-Partition head object.
180          */
181         const char *schema_info;
182
183         struct dsdb_attribute *attributes;
184         struct dsdb_class *classes;
185
186         /* lists of classes sorted by various attributes, for faster
187            access */
188         uint32_t num_classes;
189         struct dsdb_class **classes_by_lDAPDisplayName;
190         struct dsdb_class **classes_by_governsID_id;
191         struct dsdb_class **classes_by_governsID_oid;
192         struct dsdb_class **classes_by_cn;
193
194         /* lists of attributes sorted by various fields */
195         uint32_t num_attributes;
196         struct dsdb_attribute **attributes_by_lDAPDisplayName;
197         struct dsdb_attribute **attributes_by_attributeID_id;
198         struct dsdb_attribute **attributes_by_attributeID_oid;
199         struct dsdb_attribute **attributes_by_linkID;
200
201         struct {
202                 bool we_are_master;
203                 struct ldb_dn *master_dn;
204         } fsmo;
205
206         struct smb_iconv_convenience *iconv_convenience;
207 };
208
209 enum dsdb_attr_list_query {
210         DSDB_SCHEMA_ALL_MAY,
211         DSDB_SCHEMA_ALL_MUST,
212         DSDB_SCHEMA_SYS_MAY,
213         DSDB_SCHEMA_SYS_MUST,
214         DSDB_SCHEMA_MAY,
215         DSDB_SCHEMA_MUST,
216         DSDB_SCHEMA_ALL
217 };
218
219 enum dsdb_schema_convert_target {
220         TARGET_OPENLDAP,
221         TARGET_FEDORA_DS,
222         TARGET_AD_SCHEMA_SUBENTRY
223 };
224
225 #include "dsdb/schema/proto.h"
226
227 #endif /* _DSDB_SCHEMA_H */