svn commit: samba r22497 - in branches/SAMBA_4_0/source:
dsdb/samdb/ldb_modules lib/ldb/tools setup
abartlet at samba.org
abartlet at samba.org
Tue Apr 24 05:57:58 GMT 2007
Author: abartlet
Date: 2007-04-24 05:57:56 +0000 (Tue, 24 Apr 2007)
New Revision: 22497
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22497
Log:
Support renaming objectclasses and attributes for the LDAP backend.
OpenLDAP is fussy about operational attributes in user-supplied
schema.
Andrew Bartlett
Modified:
branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/entryUUID.c
branches/SAMBA_4_0/source/lib/ldb/tools/ad2oLschema.c
branches/SAMBA_4_0/source/setup/schema-map-openldap-2.3
branches/SAMBA_4_0/source/setup/schema_samba4.ldif
Changeset:
Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/entryUUID.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/entryUUID.c 2007-04-24 00:12:28 UTC (rev 22496)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/entryUUID.c 2007-04-24 05:57:56 UTC (rev 22497)
@@ -352,6 +352,15 @@
}
},
{
+ .local_name = "objectClasses",
+ .type = MAP_RENAME,
+ .u = {
+ .rename = {
+ .remote_name = "sambaObjectClasses"
+ }
+ }
+ },
+ {
.local_name = "sambaPassword",
.type = MAP_RENAME,
.u = {
@@ -446,9 +455,21 @@
}
};
+/* This objectClass conflicts with builtin classes on OpenLDAP */
+const struct ldb_map_objectclass entryUUID_objectclasses[] =
+{
+ {
+ .local_name = "subSchema",
+ .remote_name = "samba4SubSchema"
+ },
+ {
+ .local_name = NULL
+ }
+};
+
/* These things do not show up in wildcard searches in OpenLDAP, but
* we need them to show up in the AD-like view */
-const char * const wildcard_attributes[] = {
+const char * const entryUUID_wildcard_attributes[] = {
"objectGUID",
"whenCreated",
"whenChanged",
@@ -471,7 +492,7 @@
},
},
},
- /* objectSid */
+ /* objectSid */
{
.local_name = "objectSid",
.type = MAP_CONVERT,
@@ -751,7 +772,7 @@
struct entryUUID_private *entryUUID_private;
struct ldb_dn *schema_dn;
- ret = ldb_map_init(module, entryUUID_attributes, NULL, wildcard_attributes, NULL);
+ ret = ldb_map_init(module, entryUUID_attributes, entryUUID_objectclasses, entryUUID_wildcard_attributes, NULL);
if (ret != LDB_SUCCESS)
return ret;
Modified: branches/SAMBA_4_0/source/lib/ldb/tools/ad2oLschema.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/tools/ad2oLschema.c 2007-04-24 00:12:28 UTC (rev 22496)
+++ branches/SAMBA_4_0/source/lib/ldb/tools/ad2oLschema.c 2007-04-24 05:57:56 UTC (rev 22497)
@@ -246,7 +246,12 @@
char *old_oid;
char *new_oid;
} *oid_map = NULL;
- int num_maps = 0;
+ int num_oid_maps = 0;
+ struct attr_map {
+ char *old_attr;
+ char *new_attr;
+ } *attr_map = NULL;
+ int num_attr_maps = 0;
struct ldb_result *attrs_res, *objectclasses_res;
struct ldb_dn *schemadn;
struct schema_conv ret;
@@ -269,25 +274,36 @@
if (isdigit(line[0])) {
char *p = strchr(line, ':');
IF_NULL_FAIL_RET(p);
- if (!p) {
- ret.failures = 1;
- return ret;
- }
p[0] = '\0';
p++;
- oid_map = talloc_realloc(mem_ctx, oid_map, struct oid_map, num_maps + 2);
+ oid_map = talloc_realloc(mem_ctx, oid_map, struct oid_map, num_oid_maps + 2);
trim_string(line, " ", " ");
- oid_map[num_maps].old_oid = talloc_move(oid_map, &line);
+ oid_map[num_oid_maps].old_oid = talloc_move(oid_map, &line);
trim_string(p, " ", " ");
- oid_map[num_maps].new_oid = p;
- num_maps++;
- oid_map[num_maps].old_oid = NULL;
+ oid_map[num_oid_maps].new_oid = p;
+ num_oid_maps++;
+ oid_map[num_oid_maps].old_oid = NULL;
} else {
- attrs_skip = talloc_realloc(mem_ctx, attrs_skip, const char *, num_skip + 2);
- trim_string(line, " ", " ");
- attrs_skip[num_skip] = talloc_move(attrs_skip, &line);
- num_skip++;
- attrs_skip[num_skip] = NULL;
+ char *p = strchr(line, ':');
+ if (p) {
+ /* remap attribute/objectClass */
+ p[0] = '\0';
+ p++;
+ attr_map = talloc_realloc(mem_ctx, attr_map, struct attr_map, num_attr_maps + 2);
+ trim_string(line, " ", " ");
+ attr_map[num_attr_maps].old_attr = talloc_move(attr_map, &line);
+ trim_string(p, " ", " ");
+ attr_map[num_attr_maps].new_attr = p;
+ num_attr_maps++;
+ attr_map[num_attr_maps].old_attr = NULL;
+ } else {
+ /* skip attribute/objectClass */
+ attrs_skip = talloc_realloc(mem_ctx, attrs_skip, const char *, num_skip + 2);
+ trim_string(line, " ", " ");
+ attrs_skip[num_skip] = talloc_move(attrs_skip, &line);
+ num_skip++;
+ attrs_skip[num_skip] = NULL;
+ }
}
}
@@ -327,7 +343,7 @@
if (!name) {
printf("Failed to find lDAPDisplayName for schema DN: %s\n", ldb_dn_get_linearized(msg->dn));
- ret.failures = 1;
+ ret.failures++;
continue;
}
@@ -359,6 +375,14 @@
}
IF_NULL_FAIL_RET(schema_entry);
+ /* We might have been asked to remap this name, due to a conflict */
+ for (j=0; name && attr_map && attr_map[j].old_attr; j++) {
+ if (strcmp(name, attr_map[j].old_attr) == 0) {
+ name = attr_map[j].new_attr;
+ break;
+ }
+ }
+
schema_entry = talloc_asprintf_append(schema_entry,
" NAME '%s'\n", name);
IF_NULL_FAIL_RET(schema_entry);
@@ -437,6 +461,12 @@
char *schema_entry = NULL;
int j;
+ if (!name) {
+ printf("Failed to find lDAPDisplayName for schema DN: %s\n", ldb_dn_get_linearized(msg->dn));
+ ret.failures++;
+ continue;
+ }
+
/* We have been asked to skip some attributes/objectClasses */
if (attrs_skip && str_list_check_ci(attrs_skip, name)) {
ret.skipped++;
@@ -469,6 +499,14 @@
break;
}
+ /* We might have been asked to remap this name, due to a conflict */
+ for (j=0; name && attr_map && attr_map[j].old_attr; j++) {
+ if (strcmp(name, attr_map[j].old_attr) == 0) {
+ name = attr_map[j].new_attr;
+ break;
+ }
+ }
+
schema_entry = talloc_asprintf_append(schema_entry,
" NAME '%s'\n", name);
IF_NULL_FAIL_RET(schema_entry);
@@ -509,9 +547,19 @@
do { \
int k; \
for (k=0; attributes && k < attributes->num_values; k++) { \
+ int attr_idx; \
+ const char *attr_name = (const char *)attributes->values[k].data; \
+ /* We might have been asked to remap this name, due to a conflict */ \
+ for (attr_idx=0; attr_name && attr_map && attr_map[attr_idx].old_attr; attr_idx++) { \
+ if (strcmp(attr_name, attr_map[attr_idx].old_attr) == 0) { \
+ attr_name = attr_map[attr_idx].new_attr; \
+ break; \
+ } \
+ } \
+ \
schema_entry = talloc_asprintf_append(schema_entry, \
" %s", \
- (const char *)attributes->values[k].data); \
+ attr_name); \
IF_NULL_FAIL_RET(schema_entry); \
if (k != (attributes->num_values - 1)) { \
schema_entry = talloc_asprintf_append(schema_entry, \
Modified: branches/SAMBA_4_0/source/setup/schema-map-openldap-2.3
===================================================================
--- branches/SAMBA_4_0/source/setup/schema-map-openldap-2.3 2007-04-24 00:12:28 UTC (rev 22496)
+++ branches/SAMBA_4_0/source/setup/schema-map-openldap-2.3 2007-04-24 05:57:56 UTC (rev 22497)
@@ -1,7 +1,6 @@
#Standard OpenLDAP attributes
name
labeledURI
-objectClasses
createTimeStamp
attributeTypes
objectClass
@@ -10,7 +9,6 @@
uid
subSchemaSubEntry
structuralObjectClass
-modifyTimeStamp
distinguishedName
description
cn
@@ -18,8 +16,14 @@
top
#This shouldn't make it to the ldap server
sambaPassword
-#Skip ObjectClasses
-subSchema
+#These conflict with OpenLDAP builtins
+objectClasses:samba4ObjectClasses
+2.5.21.6:1.3.6.1.4.1.7165.4.255.5
+subSchema:samba4SubSchema
+2.5.20.1:1.3.6.1.4.1.7165.4.255.4
+#Remap these so that we don't put operational attributes in a schema MAY
+modifyTimeStamp:samba4ModifyTimestamp
+2.5.18.2:1.3.6.1.4.1.7165.4.255.3
#MiddleName has a conflicting OID
2.16.840.1.113730.3.1.34:1.3.6.1.4.1.7165.4.255.1
#defaultGroup has a conflicting OID
Modified: branches/SAMBA_4_0/source/setup/schema_samba4.ldif
===================================================================
--- branches/SAMBA_4_0/source/setup/schema_samba4.ldif 2007-04-24 00:12:28 UTC (rev 22496)
+++ branches/SAMBA_4_0/source/setup/schema_samba4.ldif 2007-04-24 05:57:56 UTC (rev 22497)
@@ -165,3 +165,7 @@
#Allocated: (middleName) attributeID: 1.3.6.1.4.1.7165.4.255.1
#Allocated: (defaultGroup) attributeID: 1.3.6.1.4.1.7165.4.255.2
+
+#Allocated: (modifyTimestamp) samba4ModifyTimestamp: 1.3.6.1.4.1.7165.4.255.3
+#Allocated: (subSchema) samba4SubSchema: 1.3.6.1.4.1.7165.4.255.4
+#Allocated: (objectClasses) samba4ObjectClasses: 1.3.6.1.4.1.7165.4.255.5
More information about the samba-cvs
mailing list