a5d38451d41eae012c420757e590dda80db6a942
[kai/samba-autobuild/.git] / source4 / utils / schema_convert.c
1 /* 
2    ldb database library
3
4    Copyright (C) Simo Sorce 2005
5
6      ** NOTE! The following LGPL license applies to the ldb
7      ** library. This does NOT imply that all of Samba is released
8      ** under the LGPL
9    
10    This library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Lesser General Public
12    License as published by the Free Software Foundation; either
13    version 3 of the License, or (at your option) any later version.
14
15    This library is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    Lesser General Public License for more details.
19
20    You should have received a copy of the GNU Lesser General Public
21    License along with this library; if not, see <http://www.gnu.org/licenses/>.
22 */
23
24 #include "schema_convert.h"
25 #include "ldb_includes.h"
26
27 /* Shared map for converting syntax between formats */
28 static const struct syntax_map syntax_map[] = {
29         { 
30                 .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.12", 
31                 .AD_OID = "2.5.5.1", 
32                 .equality = "distinguishedNameMatch",
33                 .comment = "Object(DS-DN) == a DN" 
34         },
35 #if 0
36         {
37                 .Standard_OID =  "1.3.6.1.4.1.1466.115.121.1.38",
38                 .AD_OID =  "2.5.5.2",
39                 .equality = "objectIdentifierMatch",
40                 .comment =  "OID String"
41         },
42 #else 
43         { 
44                 .Standard_OID =  "1.2.840.113556.1.4.905", 
45                 .AD_OID =  "2.5.5.2",
46                 .equality = "caseIgnoreMatch",
47                 .comment =   "OID as a Case Insensitive String" 
48         },
49 #endif
50         { 
51                 .Standard_OID =  "1.2.840.113556.1.4.905", 
52                 .AD_OID =  "2.5.5.4",
53                 .equality = "caseIgnoreMatch",
54                 .substring = "caseIgnoreSubstringsMatch",
55                 .comment =   "Case Insensitive String" 
56         },
57         {
58                 .Standard_OID =  "1.3.6.1.4.1.1466.115.121.1.26",
59                 .AD_OID =   "2.5.5.5",
60                 .equality = "caseExactIA5Match",
61                 .comment = "Printable String"
62         },
63         {
64                 .Standard_OID =  "1.3.6.1.4.1.1466.115.121.1.36",
65                 .AD_OID =   "2.5.5.6", 
66                 .equality = "numericStringMatch",
67                 .substring = "numericStringSubstringsMatch",
68                 .comment = "Numeric String" 
69         },
70         { 
71                 .Standard_OID =  "1.2.840.113556.1.4.903", 
72                 .AD_OID =  "2.5.5.7", 
73                 .equality = "distinguishedNameMatch",
74                 .comment = "OctetString: Binary+DN" 
75         },
76         { 
77                 .Standard_OID =  "1.3.6.1.4.1.1466.115.121.1.7",
78                 .AD_OID =   "2.5.5.8", 
79                 .equality = "booleanMatch",
80                 .comment = "Boolean" 
81         },
82         { 
83                 .Standard_OID =  "1.3.6.1.4.1.1466.115.121.1.27",
84                 .AD_OID =   "2.5.5.9", 
85                 .equality = "integerMatch",
86                 .comment = "Integer" 
87         },
88         { 
89                 .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.40",
90                 .AD_OID       = "2.5.5.10",
91                 .equality     = "octetStringMatch",
92                 .comment      =  "Octet String"
93         },
94         {
95                 .Standard_OID =  "1.3.6.1.4.1.1466.115.121.1.24",
96                 .AD_OID =   "2.5.5.11", 
97                 .equality = "generalizedTimeMatch",
98                 .comment = "Generalized Time"
99         },
100         { 
101                 .Standard_OID =  "1.3.6.1.4.1.1466.115.121.1.53",
102                 .AD_OID =   "2.5.5.11", 
103                 .equality = "generalizedTimeMatch",
104                 .comment = "UTC Time" 
105         },
106         { 
107                 .Standard_OID =  "1.3.6.1.4.1.1466.115.121.1.15",
108                 .AD_OID =   "2.5.5.12", 
109                 .equality = "caseIgnoreMatch",
110                 .substring = "caseIgnoreSubstringsMatch",
111                 .comment = "Directory String"
112         },
113         {
114                 .Standard_OID =  "1.3.6.1.4.1.1466.115.121.1.43",
115                 .AD_OID =   "2.5.5.13", 
116                 .comment = "Presentation Address" 
117         },
118         {
119                 .Standard_OID =   "Not Found Yet", 
120                 .AD_OID =  "2.5.5.14", 
121                 .equality = "distinguishedNameMatch",
122                 .comment = "OctetString: String+DN" 
123         },
124         {
125                 .Standard_OID =  "1.2.840.113556.1.4.907",
126                 .AD_OID =   "2.5.5.15", 
127                 .equality     = "octetStringMatch",
128                 .comment = "NT Security Descriptor"
129         },
130         { 
131                 .Standard_OID =  "1.2.840.113556.1.4.906", 
132                 .AD_OID =  "2.5.5.16", 
133                 .equality = "integerMatch",
134                 .comment = "Large Integer" 
135         },
136         {
137                 .Standard_OID =  "1.3.6.1.4.1.1466.115.121.1.40",
138                 .AD_OID =   "2.5.5.17",
139                 .equality     = "octetStringMatch",
140                 .comment =  "Octet String - Security Identifier (SID)" 
141         },
142         { 
143                 .Standard_OID =  "1.3.6.1.4.1.1466.115.121.1.26", 
144                 .AD_OID =  "2.5.5.5", 
145                 .equality = "caseExactIA5Match",
146                 .comment = "IA5 String" 
147         },
148         {       .Standard_OID = NULL
149         }
150 };
151
152
153 const struct syntax_map *find_syntax_map_by_ad_oid(const char *ad_oid) 
154 {
155         int i;
156         for (i=0; syntax_map[i].Standard_OID; i++) {
157                 if (strcasecmp(ad_oid, syntax_map[i].AD_OID) == 0) {
158                         return &syntax_map[i];
159                 }
160         }
161         return NULL;
162 }
163
164 const struct syntax_map *find_syntax_map_by_standard_oid(const char *standard_oid) 
165 {
166         int i;
167         for (i=0; syntax_map[i].Standard_OID; i++) {
168                 if (strcasecmp(standard_oid, syntax_map[i].Standard_OID) == 0) {
169                         return &syntax_map[i];
170                 }
171         }
172         return NULL;
173 }