1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

s4-dsdb: implement limit on rDN length

w2k8 imposes a limit of 64 characters on the rDN
This commit is contained in:
Andrew Tridgell 2009-10-15 15:54:20 +11:00
parent 144686a838
commit fdeeafb481

View File

@ -330,6 +330,8 @@ static int fix_dn(TALLOC_CTX *mem_ctx,
struct ldb_dn **fixed_dn)
{
char *upper_rdn_attr;
const struct ldb_val *rdn_val;
/* Fix up the DN to be in the standard form, taking particular care to match the parent DN */
*fixed_dn = ldb_dn_copy(mem_ctx, parent_dn);
@ -345,9 +347,15 @@ static int fix_dn(TALLOC_CTX *mem_ctx,
return LDB_ERR_OPERATIONS_ERROR;
}
/* AD doesn't allow the rDN to be longer than 64 characters */
rdn_val = ldb_dn_get_rdn_val(newdn);
if (!rdn_val || rdn_val->length > 64) {
DEBUG(2,(__location__ ": rDN longer than 64 limit for '%s'\n", ldb_dn_get_linearized(newdn)));
return LDB_ERR_CONSTRAINT_VIOLATION;
}
/* And replace it with CN=foo (we need the attribute in upper case */
return ldb_dn_set_component(*fixed_dn, 0, upper_rdn_attr,
*ldb_dn_get_rdn_val(newdn));
return ldb_dn_set_component(*fixed_dn, 0, upper_rdn_attr, *rdn_val);
}
/* Fix all attribute names to be in the correct case, and check they are all valid per the schema */