summaryrefslogtreecommitdiff
path: root/source4/utils
diff options
context:
space:
mode:
Diffstat (limited to 'source4/utils')
-rw-r--r--source4/utils/ad2oLschema.c206
-rw-r--r--source4/utils/config.mk6
-rw-r--r--source4/utils/schema_convert.c173
-rw-r--r--source4/utils/schema_convert.h10
4 files changed, 18 insertions, 377 deletions
diff --git a/source4/utils/ad2oLschema.c b/source4/utils/ad2oLschema.c
index 1e6348bc1a..ea5b813e8a 100644
--- a/source4/utils/ad2oLschema.c
+++ b/source4/utils/ad2oLschema.c
@@ -35,7 +35,6 @@
#include "ldb_includes.h"
#include "system/locale.h"
#include "lib/ldb/tools/cmdline.h"
-#include "utils/schema_convert.h"
#include "param/param.h"
#include "lib/cmdline/popt_common.h"
#include "dsdb/samdb/samdb.h"
@@ -45,11 +44,6 @@ struct schema_conv {
int skipped;
int failures;
};
-
-enum convert_target {
- TARGET_OPENLDAP,
- TARGET_FEDORA_DS
-};
static void usage(void)
@@ -122,179 +116,7 @@ static struct ldb_dn *find_schema_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ct
}
-#define IF_NULL_FAIL_RET(x) do { \
- if (!x) { \
- return NULL; \
- } \
- } while (0)
-
-
-static char *schema_attribute_description(TALLOC_CTX *mem_ctx,
- enum convert_target target,
- const char *seperator,
- const char *oid,
- const char *name,
- const char *description,
- struct syntax_map *map,
- const char *syntax,
- bool single_value, bool operational)
-{
- char *schema_entry = talloc_asprintf(mem_ctx,
- "(%s%s%s", seperator, oid, seperator);
-
- schema_entry = talloc_asprintf_append(schema_entry,
- "NAME '%s'%s", name, seperator);
- IF_NULL_FAIL_RET(schema_entry);
-
- if (description) {
-#if 0
- /* Need a way to escape ' characters from the description */
- schema_entry = talloc_asprintf_append(schema_entry,
- "DESC '%s'%s", description, seperator);
- IF_NULL_FAIL_RET(schema_entry);
-#endif
- }
-
- if (map) {
- if (map->equality) {
- schema_entry = talloc_asprintf_append(schema_entry,
- "EQUALITY %s%s", map->equality, seperator);
- IF_NULL_FAIL_RET(schema_entry);
- }
- if (map->substring) {
- schema_entry = talloc_asprintf_append(schema_entry,
- "SUBSTR %s%s", map->substring, seperator);
- IF_NULL_FAIL_RET(schema_entry);
- }
-
- syntax = map->Standard_OID;
- }
-
- schema_entry = talloc_asprintf_append(schema_entry,
- "SYNTAX %s%s", syntax, seperator);
- IF_NULL_FAIL_RET(schema_entry);
-
- if (single_value) {
- schema_entry = talloc_asprintf_append(schema_entry,
- "SINGLE-VALUE%s", seperator);
- IF_NULL_FAIL_RET(schema_entry);
- }
-
- if (operational) {
- schema_entry = talloc_asprintf_append(schema_entry,
- "NO-USER-MODIFICATION%s", seperator);
- IF_NULL_FAIL_RET(schema_entry);
- }
-
- schema_entry = talloc_asprintf_append(schema_entry,
- ")");
- return schema_entry;
-}
-
-static char *schema_class_description(TALLOC_CTX *mem_ctx,
- enum convert_target target,
- const char *seperator,
- const char *oid,
- const char *name,
- const char *description,
- const char *subClassOf,
- int objectClassCategory,
- char **must,
- char **may)
-{
- char *schema_entry = talloc_asprintf(mem_ctx,
- "(%s%s%s", seperator, oid, seperator);
-
- IF_NULL_FAIL_RET(schema_entry);
-
- schema_entry = talloc_asprintf_append(schema_entry,
- "NAME '%s'%s", name, seperator);
- IF_NULL_FAIL_RET(schema_entry);
-
- if (description) {
- schema_entry = talloc_asprintf_append(schema_entry,
- "DESC '%s'%s", description, seperator);
- IF_NULL_FAIL_RET(schema_entry);
- }
-
- if (subClassOf) {
- schema_entry = talloc_asprintf_append(schema_entry,
- "SUP %s%s", subClassOf, seperator);
- IF_NULL_FAIL_RET(schema_entry);
- }
-
- switch (objectClassCategory) {
- case 1:
- schema_entry = talloc_asprintf_append(schema_entry,
- "STRUCTURAL%s", seperator);
- IF_NULL_FAIL_RET(schema_entry);
- break;
- case 2:
- schema_entry = talloc_asprintf_append(schema_entry,
- "ABSTRACT%s", seperator);
- IF_NULL_FAIL_RET(schema_entry);
- break;
- case 3:
- schema_entry = talloc_asprintf_append(schema_entry,
- "AUXILIARY%s", seperator);
- IF_NULL_FAIL_RET(schema_entry);
- break;
- }
-
-#define APPEND_ATTRS(attributes) \
- do { \
- int k; \
- for (k=0; attributes && attributes[k]; k++) { \
- const char *attr_name = attributes[k]; \
- \
- schema_entry = talloc_asprintf_append(schema_entry, \
- "%s ", \
- attr_name); \
- IF_NULL_FAIL_RET(schema_entry); \
- if (attributes[k+1]) { \
- IF_NULL_FAIL_RET(schema_entry); \
- if (target == TARGET_OPENLDAP && ((k+1)%5 == 0)) { \
- schema_entry = talloc_asprintf_append(schema_entry, \
- "$%s ", seperator); \
- IF_NULL_FAIL_RET(schema_entry); \
- } else { \
- schema_entry = talloc_asprintf_append(schema_entry, \
- "$ "); \
- } \
- } \
- } \
- } while (0)
-
- if (must) {
- schema_entry = talloc_asprintf_append(schema_entry,
- "MUST ( ");
- IF_NULL_FAIL_RET(schema_entry);
-
- APPEND_ATTRS(must);
-
- schema_entry = talloc_asprintf_append(schema_entry,
- ")%s", seperator);
- IF_NULL_FAIL_RET(schema_entry);
- }
-
- if (may) {
- schema_entry = talloc_asprintf_append(schema_entry,
- "MAY ( ");
- IF_NULL_FAIL_RET(schema_entry);
-
- APPEND_ATTRS(may);
-
- schema_entry = talloc_asprintf_append(schema_entry,
- ")%s", seperator);
- IF_NULL_FAIL_RET(schema_entry);
- }
-
- schema_entry = talloc_asprintf_append(schema_entry,
- ")");
- return schema_entry;
-}
-
-static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_target target, FILE *in, FILE *out)
+static struct schema_conv process_convert(struct ldb_context *ldb, enum dsdb_schema_convert_target target, FILE *in, FILE *out)
{
/* Read list of attributes to skip, OIDs to map */
TALLOC_CTX *mem_ctx = talloc_new(ldb);
@@ -404,10 +226,10 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
const char *description = attribute->adminDescription;
const char *oid = attribute->attributeID_oid;
const char *syntax = attribute->attributeSyntax_oid;
+ const char *equality = NULL, *substring = NULL;
bool single_value = attribute->isSingleValued;
- const struct syntax_map *const_map = find_syntax_map_by_ad_oid(syntax);
- struct syntax_map map, *map_p = NULL;
+ const struct dsdb_syntax_map *map = find_syntax_map_by_ad_oid(syntax);
char *schema_entry = NULL;
int j;
@@ -425,20 +247,21 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
}
}
- if (const_map) {
- map = *const_map;
-
+ if (map) {
/* We might have been asked to remap this oid,
* due to a conflict, or lack of
* implementation */
- for (j=0; map.Standard_OID && oid_map && oid_map[j].old_oid; j++) {
- if (strcasecmp(map.Standard_OID, oid_map[j].old_oid) == 0) {
- map.Standard_OID = oid_map[j].new_oid;
+ syntax = map->Standard_OID;
+ /* We might have been asked to remap this oid, due to a conflict */
+ for (j=0; syntax && oid_map && oid_map[j].old_oid; j++) {
+ if (strcasecmp(syntax, oid_map[j].old_oid) == 0) {
+ syntax = oid_map[j].new_oid;
break;
}
}
-
- map_p = ↦
+
+ equality = map->equality;
+ substring = map->substring;
}
/* We might have been asked to remap this name, due to a conflict */
@@ -449,7 +272,7 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
}
}
- schema_entry = schema_attribute_description(mem_ctx, target, seperator, oid, name, description, map_p, syntax, single_value, false);
+ schema_entry = schema_attribute_description(mem_ctx, target, seperator, oid, name, description, equality, substring, syntax, single_value, false);
if (schema_entry == NULL) {
ret.failures++;
@@ -534,6 +357,7 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
seperator,
oid,
name,
+ NULL,
description,
subClassOf,
objectClassCategory,
@@ -567,7 +391,7 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
struct ldb_context *ldb;
struct schema_conv ret;
const char *target_str;
- enum convert_target target;
+ enum dsdb_schema_convert_target target;
ctx = talloc_new(NULL);
ldb = ldb_init(ctx, NULL);
diff --git a/source4/utils/config.mk b/source4/utils/config.mk
index 61565807d2..37a19077f1 100644
--- a/source4/utils/config.mk
+++ b/source4/utils/config.mk
@@ -100,12 +100,12 @@ testparm_OBJ_FILES = $(utilssrcdir)/testparm.o
[BINARY::oLschema2ldif]
INSTALLDIR = BINDIR
PRIVATE_DEPENDENCIES = \
- LIBLDB_CMDLINE
+ LIBLDB_CMDLINE SAMDB
# End BINARY oLschema2ldif
################################################
-oLschema2ldif_OBJ_FILES = $(addprefix $(utilssrcdir)/, schema_convert.o oLschema2ldif.o)
+oLschema2ldif_OBJ_FILES = $(addprefix $(utilssrcdir)/, oLschema2ldif.o)
MANPAGES += $(utilssrcdir)/man/oLschema2ldif.1
@@ -118,7 +118,7 @@ PRIVATE_DEPENDENCIES = \
# End BINARY ad2oLschema
################################################
-ad2oLschema_OBJ_FILES = $(addprefix $(utilssrcdir)/, schema_convert.o ad2oLschema.o)
+ad2oLschema_OBJ_FILES = $(addprefix $(utilssrcdir)/, ad2oLschema.o)
MANPAGES += $(utilssrcdir)/man/ad2oLschema.1
diff --git a/source4/utils/schema_convert.c b/source4/utils/schema_convert.c
deleted file mode 100644
index a5d38451d4..0000000000
--- a/source4/utils/schema_convert.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- ldb database library
-
- Copyright (C) Simo Sorce 2005
-
- ** NOTE! The following LGPL license applies to the ldb
- ** library. This does NOT imply that all of Samba is released
- ** under the LGPL
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "schema_convert.h"
-#include "ldb_includes.h"
-
-/* Shared map for converting syntax between formats */
-static const struct syntax_map syntax_map[] = {
- {
- .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.12",
- .AD_OID = "2.5.5.1",
- .equality = "distinguishedNameMatch",
- .comment = "Object(DS-DN) == a DN"
- },
-#if 0
- {
- .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.38",
- .AD_OID = "2.5.5.2",
- .equality = "objectIdentifierMatch",
- .comment = "OID String"
- },
-#else
- {
- .Standard_OID = "1.2.840.113556.1.4.905",
- .AD_OID = "2.5.5.2",
- .equality = "caseIgnoreMatch",
- .comment = "OID as a Case Insensitive String"
- },
-#endif
- {
- .Standard_OID = "1.2.840.113556.1.4.905",
- .AD_OID = "2.5.5.4",
- .equality = "caseIgnoreMatch",
- .substring = "caseIgnoreSubstringsMatch",
- .comment = "Case Insensitive String"
- },
- {
- .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.26",
- .AD_OID = "2.5.5.5",
- .equality = "caseExactIA5Match",
- .comment = "Printable String"
- },
- {
- .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.36",
- .AD_OID = "2.5.5.6",
- .equality = "numericStringMatch",
- .substring = "numericStringSubstringsMatch",
- .comment = "Numeric String"
- },
- {
- .Standard_OID = "1.2.840.113556.1.4.903",
- .AD_OID = "2.5.5.7",
- .equality = "distinguishedNameMatch",
- .comment = "OctetString: Binary+DN"
- },
- {
- .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.7",
- .AD_OID = "2.5.5.8",
- .equality = "booleanMatch",
- .comment = "Boolean"
- },
- {
- .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.27",
- .AD_OID = "2.5.5.9",
- .equality = "integerMatch",
- .comment = "Integer"
- },
- {
- .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.40",
- .AD_OID = "2.5.5.10",
- .equality = "octetStringMatch",
- .comment = "Octet String"
- },
- {
- .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.24",
- .AD_OID = "2.5.5.11",
- .equality = "generalizedTimeMatch",
- .comment = "Generalized Time"
- },
- {
- .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.53",
- .AD_OID = "2.5.5.11",
- .equality = "generalizedTimeMatch",
- .comment = "UTC Time"
- },
- {
- .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.15",
- .AD_OID = "2.5.5.12",
- .equality = "caseIgnoreMatch",
- .substring = "caseIgnoreSubstringsMatch",
- .comment = "Directory String"
- },
- {
- .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.43",
- .AD_OID = "2.5.5.13",
- .comment = "Presentation Address"
- },
- {
- .Standard_OID = "Not Found Yet",
- .AD_OID = "2.5.5.14",
- .equality = "distinguishedNameMatch",
- .comment = "OctetString: String+DN"
- },
- {
- .Standard_OID = "1.2.840.113556.1.4.907",
- .AD_OID = "2.5.5.15",
- .equality = "octetStringMatch",
- .comment = "NT Security Descriptor"
- },
- {
- .Standard_OID = "1.2.840.113556.1.4.906",
- .AD_OID = "2.5.5.16",
- .equality = "integerMatch",
- .comment = "Large Integer"
- },
- {
- .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.40",
- .AD_OID = "2.5.5.17",
- .equality = "octetStringMatch",
- .comment = "Octet String - Security Identifier (SID)"
- },
- {
- .Standard_OID = "1.3.6.1.4.1.1466.115.121.1.26",
- .AD_OID = "2.5.5.5",
- .equality = "caseExactIA5Match",
- .comment = "IA5 String"
- },
- { .Standard_OID = NULL
- }
-};
-
-
-const struct syntax_map *find_syntax_map_by_ad_oid(const char *ad_oid)
-{
- int i;
- for (i=0; syntax_map[i].Standard_OID; i++) {
- if (strcasecmp(ad_oid, syntax_map[i].AD_OID) == 0) {
- return &syntax_map[i];
- }
- }
- return NULL;
-}
-
-const struct syntax_map *find_syntax_map_by_standard_oid(const char *standard_oid)
-{
- int i;
- for (i=0; syntax_map[i].Standard_OID; i++) {
- if (strcasecmp(standard_oid, syntax_map[i].Standard_OID) == 0) {
- return &syntax_map[i];
- }
- }
- return NULL;
-}
diff --git a/source4/utils/schema_convert.h b/source4/utils/schema_convert.h
deleted file mode 100644
index de379343a6..0000000000
--- a/source4/utils/schema_convert.h
+++ /dev/null
@@ -1,10 +0,0 @@
-struct syntax_map {
- const char *Standard_OID;
- const char *AD_OID;
- const char *equality;
- const char *substring;
- const char *comment;
-};
-
-const struct syntax_map *find_syntax_map_by_ad_oid(const char *ad_oid);
-const struct syntax_map *find_syntax_map_by_standard_oid(const char *standard_oid);