Make ad2oLschema even simpler, by moving the heavy work into dsdb.
[kai/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
36         WERROR (*drsuapi_to_ldb)(const struct dsdb_schema *schema,
37                                  const struct dsdb_attribute *attr,
38                                  const struct drsuapi_DsReplicaAttribute *in,
39                                  TALLOC_CTX *mem_ctx,
40                                  struct ldb_message_element *out);
41         WERROR (*ldb_to_drsuapi)(const struct dsdb_schema *schema,
42                                  const struct dsdb_attribute *attr,
43                                  const struct ldb_message_element *in,
44                                  TALLOC_CTX *mem_ctx,
45                                  struct drsuapi_DsReplicaAttribute *out);
46 };
47
48 struct dsdb_attribute {
49         struct dsdb_attribute *prev, *next;
50
51         const char *cn;
52         const char *lDAPDisplayName;
53         const char *attributeID_oid;
54         uint32_t attributeID_id;
55         struct GUID schemaIDGUID;
56         uint32_t mAPIID;
57
58         struct GUID attributeSecurityGUID;
59
60         uint32_t searchFlags;
61         uint32_t systemFlags;
62         bool isMemberOfPartialAttributeSet;
63         uint32_t linkID;
64
65         const char *attributeSyntax_oid;
66         uint32_t attributeSyntax_id;
67         uint32_t oMSyntax;
68         struct ldb_val oMObjectClass;
69
70         bool isSingleValued;
71         uint32_t rangeLower;
72         uint32_t rangeUpper;
73         bool extendedCharsAllowed;
74
75         uint32_t schemaFlagsEx;
76         struct ldb_val msDs_Schema_Extensions;
77
78         bool showInAdvancedViewOnly;
79         const char *adminDisplayName;
80         const char *adminDescription;
81         const char *classDisplayName;
82         bool isEphemeral;
83         bool isDefunct;
84         bool systemOnly;
85
86         /* internal stuff */
87         const struct dsdb_syntax *syntax;
88 };
89
90 struct dsdb_class {
91         struct dsdb_class *prev, *next;
92
93         const char *cn;
94         const char *lDAPDisplayName;
95         const char *governsID_oid;
96         uint32_t governsID_id;
97         struct GUID schemaIDGUID;
98
99         uint32_t objectClassCategory;
100         const char *rDNAttID;
101         const char *defaultObjectCategory;
102
103         const char *subClassOf;
104
105         const char **systemAuxiliaryClass;
106         const char **systemPossSuperiors;
107         const char **systemMustContain;
108         const char **systemMayContain;
109
110         const char **auxiliaryClass;
111         const char **possSuperiors;
112         const char **mustContain;
113         const char **mayContain;
114         const char **possibleInferiors;
115
116         const char *defaultSecurityDescriptor;
117
118         uint32_t schemaFlagsEx;
119         struct ldb_val msDs_Schema_Extensions;
120
121         bool showInAdvancedViewOnly;
122         const char *adminDisplayName;
123         const char *adminDescription;
124         const char *classDisplayName;
125         bool defaultHidingValue;
126         bool isDefunct;
127         bool systemOnly;
128 };
129
130 struct dsdb_schema_oid_prefix {
131         uint32_t id;
132         const char *oid;
133         size_t oid_len;
134 };
135
136 struct dsdb_schema {
137         uint32_t num_prefixes;
138         struct dsdb_schema_oid_prefix *prefixes;
139
140         /* 
141          * the last element of the prefix mapping table isn't a oid,
142          * it starts with 0xFF and has 21 bytes and is maybe a schema
143          * version number
144          *
145          * this is the content of the schemaInfo attribute of the
146          * Schema-Partition head object.
147          */
148         const char *schema_info;
149
150         struct dsdb_attribute *attributes;
151         struct dsdb_class *classes;
152
153         struct {
154                 bool we_are_master;
155                 struct ldb_dn *master_dn;
156         } fsmo;
157
158         struct smb_iconv_convenience *iconv_convenience;
159 };
160
161 enum dsdb_attr_list_query {
162         DSDB_SCHEMA_ALL_MAY,
163         DSDB_SCHEMA_ALL_MUST,
164         DSDB_SCHEMA_SYS_MAY,
165         DSDB_SCHEMA_SYS_MUST,
166         DSDB_SCHEMA_MAY,
167         DSDB_SCHEMA_MUST
168 };
169
170 #include "dsdb/schema/proto.h"
171
172 #endif /* _DSDB_SCHEMA_H */