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