Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into manpage
(This used to be commit eff27744d3
)
@ -203,17 +203,6 @@ INIT_FUNCTION = LDB_MODULE(partition)
|
||||
|
||||
ldb_partition_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/partition.o
|
||||
|
||||
################################################
|
||||
# Start MODULE ldb_schema
|
||||
[MODULE::ldb_schema]
|
||||
SUBSYSTEM = LIBLDB
|
||||
PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBLDB
|
||||
INIT_FUNCTION = LDB_MODULE(schema)
|
||||
# End MODULE ldb_schema
|
||||
################################################
|
||||
|
||||
ldb_schema_OBJ_FILES = $(addprefix $(dsdbsrcdir)/samdb/ldb_modules/, schema.o schema_syntax.o)
|
||||
|
||||
################################################
|
||||
# Start MODULE ldb_update_kt
|
||||
[MODULE::ldb_update_keytab]
|
||||
|
@ -1,469 +0,0 @@
|
||||
/*
|
||||
ldb database library
|
||||
|
||||
Copyright (C) Simo Sorce 2004-2006
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Name: ldb
|
||||
*
|
||||
* Component: ldb schema module
|
||||
*
|
||||
* Description: add schema syntax functionality
|
||||
*
|
||||
* Author: Simo Sorce
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "ldb/include/ldb.h"
|
||||
#include "ldb/include/ldb_errors.h"
|
||||
#include "schema_syntax.h"
|
||||
|
||||
int map_schema_syntax(uint32_t om_syntax, const char *attr_syntax, const struct ldb_val *om_class, enum schema_internal_syntax *syntax)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = LDB_SUCCESS;
|
||||
|
||||
switch(om_syntax) {
|
||||
case 1:
|
||||
*syntax = SCHEMA_AS_BOOLEAN;
|
||||
break;
|
||||
case 2:
|
||||
*syntax = SCHEMA_AS_INTEGER;
|
||||
break;
|
||||
case 4:
|
||||
if (strcmp(attr_syntax, "2.5.5.10") == 0) {
|
||||
*syntax = SCHEMA_AS_OCTET_STRING;
|
||||
break;
|
||||
}
|
||||
if (strcmp(attr_syntax, "2.5.5.17") == 0) {
|
||||
*syntax = SCHEMA_AS_SID;
|
||||
break;
|
||||
}
|
||||
ret = LDB_ERR_OPERATIONS_ERROR;
|
||||
break;
|
||||
case 6:
|
||||
*syntax = SCHEMA_AS_OID;
|
||||
break;
|
||||
case 10:
|
||||
*syntax = SCHEMA_AS_ENUMERATION;
|
||||
break;
|
||||
case 18:
|
||||
*syntax = SCHEMA_AS_NUMERIC_STRING;
|
||||
break;
|
||||
case 19:
|
||||
*syntax = SCHEMA_AS_PRINTABLE_STRING;
|
||||
break;
|
||||
case 20:
|
||||
*syntax = SCHEMA_AS_CASE_IGNORE_STRING;
|
||||
break;
|
||||
case 22:
|
||||
*syntax = SCHEMA_AS_IA5_STRING;
|
||||
break;
|
||||
case 23:
|
||||
*syntax = SCHEMA_AS_UTC_TIME;
|
||||
break;
|
||||
case 24:
|
||||
*syntax = SCHEMA_AS_GENERALIZED_TIME;
|
||||
break;
|
||||
case 27:
|
||||
*syntax = SCHEMA_AS_CASE_SENSITIVE_STRING;
|
||||
break;
|
||||
case 64:
|
||||
*syntax = SCHEMA_AS_DIRECTORY_STRING;
|
||||
break;
|
||||
case 65:
|
||||
*syntax = SCHEMA_AS_LARGE_INTEGER;
|
||||
break;
|
||||
case 66:
|
||||
*syntax = SCHEMA_AS_OBJECT_SECURITY_DESCRIPTOR;
|
||||
break;
|
||||
case 127:
|
||||
if (!om_class) {
|
||||
ret = LDB_ERR_OPERATIONS_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if (memcmp(om_class->data, "\x2b\x0c\x02\x87\x73\x1c\x00\x85\x4a\x00", MIN(om_class->length, 10)) == 0) {
|
||||
*syntax = SCHEMA_AS_DN;
|
||||
break;
|
||||
}
|
||||
if (memcmp(om_class->data, "\x2a\x86\x48\x86\xf7\x14\x01\x01\x01\x0b", MIN(om_class->length, 10)) == 0) {
|
||||
*syntax = SCHEMA_AS_DN_BINARY;
|
||||
break;
|
||||
}
|
||||
if (memcmp(om_class->data, "\x56\x06\x01\x02\x05\x0b\x1d\x00\x00\x00", MIN(om_class->length, 10)) == 0) {
|
||||
*syntax = SCHEMA_AS_OR_NAME;
|
||||
break;
|
||||
}
|
||||
if (memcmp(om_class->data, "\x2a\x86\x48\x86\xf7\x14\x01\x01\x01\x06", MIN(om_class->length, 10)) == 0) {
|
||||
*syntax = SCHEMA_AS_REPLICA_LINK;
|
||||
break;
|
||||
}
|
||||
if (memcmp(om_class->data, "\x2b\x0c\x02\x87\x73\x1c\x00\x85\x5c\x00", MIN(om_class->length, 10)) == 0) {
|
||||
*syntax = SCHEMA_AS_PRESENTATION_ADDRESS;
|
||||
break;
|
||||
}
|
||||
if (memcmp(om_class->data, "\x2b\x0c\x02\x87\x73\x1c\x00\x85\x3e\x00", MIN(om_class->length, 10)) == 0) {
|
||||
*syntax = SCHEMA_AS_ACCESS_POINT;
|
||||
break;
|
||||
}
|
||||
if (memcmp(om_class->data, "\x2a\x86\x48\x86\xf7\x14\x01\x01\x01\x0c", MIN(om_class->length, 10)) == 0) {
|
||||
*syntax = SCHEMA_AS_DN_STRING;
|
||||
break;
|
||||
}
|
||||
/* not found will error in default: */
|
||||
default:
|
||||
ret = LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int schema_validate_boolean(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
|
||||
if ((strncmp("TRUE", (const char *)val->data, val->length) != 0) &&
|
||||
(strncmp("FALSE", (const char *)val->data, val->length) != 0)) {
|
||||
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
}
|
||||
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_integer(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
int value;
|
||||
char *endptr;
|
||||
|
||||
errno = 0;
|
||||
value = strtol((const char *)val->data, &endptr, 0);
|
||||
if (errno) return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
if (endptr[0] != '\0') return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
if ((min > INT_MIN) && (value < min)) return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
if ((max < INT_MAX) && (value > max)) return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_binary_blob(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
/* is there anythign we should check in a binary blob ? */
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_sid(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
/* TODO: validate binary form of objectSid */
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_oid(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
if (strspn((const char *)val->data, "0123456789.") != val->length)
|
||||
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_numeric_string(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
if (strspn((const char *)val->data, "0123456789") != val->length)
|
||||
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_printable_string(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
/* TODO: find out what constitutes the printable character set */
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_teletext_string(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
/* TODO: find out what constitutes the teletext character set */
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_ia5_string(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
/* TODO: find out what constitutes the IA5 character set */
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_utc_time(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
/* TODO: validate syntax of UTC Time string */
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_generalized_time(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
/* TODO: validate syntax of Generalized Time string */
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
/* NOTE: not a single attribute has this syntax in the basic w2k3 schema */
|
||||
static int schema_validate_sensitive_string(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
/* TODO: find out what constitutes a "case sensitive string" */
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_unicode_string(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
/* TODO: validate utf8 string */
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_large_integer(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
/* TODO: validate large integer/interval */
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_object_sd(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
/* TODO: validate object Security Descriptor */
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_dn(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
struct ldb_dn *dn;
|
||||
int ret = LDB_SUCCESS;
|
||||
|
||||
dn = ldb_dn_from_ldb_val(ldb, ldb, val);
|
||||
if ( ! ldb_dn_validate(dn)) {
|
||||
ret = LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
}
|
||||
|
||||
talloc_free(dn);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int schema_validate_binary_plus_dn(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
int ret = LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
TALLOC_CTX *memctx;
|
||||
struct ldb_dn *dn;
|
||||
char *str, *p;
|
||||
char *endptr;
|
||||
int num;
|
||||
|
||||
memctx = talloc_new(NULL);
|
||||
if (!memctx) return LDB_ERR_OPERATIONS_ERROR;
|
||||
|
||||
str = talloc_strdup(memctx, (const char *)val->data);
|
||||
if (!str) {
|
||||
ret = LDB_ERR_OPERATIONS_ERROR;
|
||||
goto done;
|
||||
}
|
||||
if (strncasecmp(str, "B:", 2) != 0) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* point at the number of chars in the string */
|
||||
str = strchr(&str[2], ':');
|
||||
if (!str) {
|
||||
goto done;
|
||||
}
|
||||
str++;
|
||||
|
||||
errno = 0;
|
||||
num = strtol(str, &endptr, 0);
|
||||
if (errno) return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
if (endptr[0] != ':') return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
if ((min > INT_MIN) && (num < min)) return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
if ((max < INT_MAX) && (num > max)) return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
|
||||
/* point at the string */
|
||||
str = strchr(str, ':');
|
||||
if (!str) {
|
||||
goto done;
|
||||
}
|
||||
str++;
|
||||
|
||||
/* terminate the string */
|
||||
p = strchr(str, ':');
|
||||
if (!p) {
|
||||
goto done;
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
if (strlen(str) != 2*num) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
str = p + 1;
|
||||
|
||||
dn = ldb_dn_new(memctx, ldb, str);
|
||||
if (ldb_dn_validate(dn)) {
|
||||
ret = LDB_SUCCESS;
|
||||
}
|
||||
|
||||
done:
|
||||
talloc_free(memctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int schema_validate_x400_or_name(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
/* TODO: find out what is the syntax of an X400 OR NAME */
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_presentation_address(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
/* TODO: find out what is the syntax of a presentation address */
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int schema_validate_x400_access_point(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
/* TODO: find out what is the syntax of an X400 Access Point */
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
/* NOTE: seem there isn't a single attribute defined like this in the base w2k3 schema */
|
||||
static int schema_validate_string_plus_dn(struct ldb_context *ldb, struct ldb_val *val, int min, int max)
|
||||
{
|
||||
int ret = LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
TALLOC_CTX *memctx;
|
||||
struct ldb_dn *dn;
|
||||
char *str, *p;
|
||||
char *endptr;
|
||||
int num;
|
||||
|
||||
memctx = talloc_new(NULL);
|
||||
if (!memctx) return LDB_ERR_OPERATIONS_ERROR;
|
||||
|
||||
str = talloc_strdup(memctx, (const char *)val->data);
|
||||
if (!str) {
|
||||
ret = LDB_ERR_OPERATIONS_ERROR;
|
||||
goto done;
|
||||
}
|
||||
if (strncasecmp(str, "S:", 2) != 0) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* point at the number of chars in the string */
|
||||
str = strchr(&str[2], ':');
|
||||
if (!str) {
|
||||
goto done;
|
||||
}
|
||||
str++;
|
||||
|
||||
errno = 0;
|
||||
num = strtol(str, &endptr, 0);
|
||||
if (errno) return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
if (endptr[0] != ':') return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
if ((min > INT_MIN) && (num < min)) return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
if ((max < INT_MAX) && (num > max)) return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
|
||||
/* point at the string */
|
||||
str = strchr(str, ':');
|
||||
if (!str) {
|
||||
goto done;
|
||||
}
|
||||
str++;
|
||||
|
||||
/* terminate the string */
|
||||
p = strchr(str, ':');
|
||||
if (!p) {
|
||||
goto done;
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
if (strlen(str) != num) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
str = p + 1;
|
||||
|
||||
dn = ldb_dn_new(memctx, ldb, str);
|
||||
if (ldb_dn_validate(dn)) {
|
||||
ret = LDB_SUCCESS;
|
||||
}
|
||||
|
||||
done:
|
||||
talloc_free(memctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct schema_syntax_validator {
|
||||
enum schema_internal_syntax type;
|
||||
int (*validate)(struct ldb_context *ldb, struct ldb_val *, int, int);
|
||||
};
|
||||
|
||||
struct schema_syntax_validator schema_syntax_validators[] = {
|
||||
{ SCHEMA_AS_BOOLEAN, schema_validate_boolean },
|
||||
{ SCHEMA_AS_INTEGER, schema_validate_integer },
|
||||
{ SCHEMA_AS_OCTET_STRING, schema_validate_binary_blob },
|
||||
{ SCHEMA_AS_SID, schema_validate_sid },
|
||||
{ SCHEMA_AS_OID, schema_validate_oid },
|
||||
{ SCHEMA_AS_ENUMERATION, schema_validate_integer },
|
||||
{ SCHEMA_AS_NUMERIC_STRING, schema_validate_numeric_string },
|
||||
{ SCHEMA_AS_PRINTABLE_STRING, schema_validate_printable_string },
|
||||
{ SCHEMA_AS_CASE_IGNORE_STRING, schema_validate_teletext_string },
|
||||
{ SCHEMA_AS_IA5_STRING, schema_validate_ia5_string },
|
||||
{ SCHEMA_AS_UTC_TIME, schema_validate_utc_time },
|
||||
{ SCHEMA_AS_GENERALIZED_TIME, schema_validate_generalized_time },
|
||||
{ SCHEMA_AS_CASE_SENSITIVE_STRING, schema_validate_sensitive_string },
|
||||
{ SCHEMA_AS_DIRECTORY_STRING, schema_validate_unicode_string },
|
||||
{ SCHEMA_AS_LARGE_INTEGER, schema_validate_large_integer },
|
||||
{ SCHEMA_AS_OBJECT_SECURITY_DESCRIPTOR, schema_validate_object_sd },
|
||||
{ SCHEMA_AS_DN, schema_validate_dn },
|
||||
{ SCHEMA_AS_DN_BINARY, schema_validate_binary_plus_dn },
|
||||
{ SCHEMA_AS_OR_NAME, schema_validate_x400_or_name },
|
||||
{ SCHEMA_AS_REPLICA_LINK, schema_validate_binary_blob },
|
||||
{ SCHEMA_AS_PRESENTATION_ADDRESS, schema_validate_presentation_address }, /* see rfc1278 ? */
|
||||
{ SCHEMA_AS_ACCESS_POINT, schema_validate_x400_access_point },
|
||||
{ SCHEMA_AS_DN_STRING, schema_validate_string_plus_dn },
|
||||
{ -1, NULL }
|
||||
};
|
||||
|
||||
int schema_validate(struct ldb_context *ldb,
|
||||
struct ldb_message_element *el,
|
||||
enum schema_internal_syntax type,
|
||||
bool single, int min, int max)
|
||||
{
|
||||
struct schema_syntax_validator *v;
|
||||
int i, ret;
|
||||
|
||||
if (single && (el->num_values > 1)) {
|
||||
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
|
||||
}
|
||||
|
||||
for (i = 0; schema_syntax_validators[i].type != 0; i++) {
|
||||
if (schema_syntax_validators[i].type == type)
|
||||
break;
|
||||
}
|
||||
if (schema_syntax_validators[i].type == 0) {
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
v = &schema_syntax_validators[i];
|
||||
|
||||
for (i = 0; i < el->num_values; i++) {
|
||||
ret = v->validate(ldb, &el->values[i], min, max);
|
||||
}
|
||||
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
ldb database library
|
||||
|
||||
Copyright (C) Simo Sorce 2004-2006
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Name: ldb
|
||||
*
|
||||
* Component: ldb schema module
|
||||
*
|
||||
* Description: add schema syntax functionality
|
||||
*
|
||||
* Author: Simo Sorce
|
||||
*/
|
||||
|
||||
|
||||
/* Syntax-Table
|
||||
|
||||
see ldap_server/devdocs/AD-syntaxes.txt
|
||||
*/
|
||||
|
||||
enum schema_internal_syntax {
|
||||
SCHEMA_AS_BOOLEAN = 1,
|
||||
SCHEMA_AS_INTEGER = 2,
|
||||
SCHEMA_AS_OCTET_STRING = 3,
|
||||
SCHEMA_AS_SID = 4,
|
||||
SCHEMA_AS_OID = 5,
|
||||
SCHEMA_AS_ENUMERATION = 6,
|
||||
SCHEMA_AS_NUMERIC_STRING = 7,
|
||||
SCHEMA_AS_PRINTABLE_STRING = 8,
|
||||
SCHEMA_AS_CASE_IGNORE_STRING = 9,
|
||||
SCHEMA_AS_IA5_STRING = 10,
|
||||
SCHEMA_AS_UTC_TIME = 11,
|
||||
SCHEMA_AS_GENERALIZED_TIME = 12,
|
||||
SCHEMA_AS_CASE_SENSITIVE_STRING = 13,
|
||||
SCHEMA_AS_DIRECTORY_STRING = 14,
|
||||
SCHEMA_AS_LARGE_INTEGER = 15,
|
||||
SCHEMA_AS_OBJECT_SECURITY_DESCRIPTOR = 16,
|
||||
SCHEMA_AS_DN = 17,
|
||||
SCHEMA_AS_DN_BINARY = 18,
|
||||
SCHEMA_AS_OR_NAME = 19,
|
||||
SCHEMA_AS_REPLICA_LINK = 20,
|
||||
SCHEMA_AS_PRESENTATION_ADDRESS = 21,
|
||||
SCHEMA_AS_ACCESS_POINT = 22,
|
||||
SCHEMA_AS_DN_STRING = 23
|
||||
};
|
||||
|
||||
int map_schema_syntax(uint32_t om_syntax,
|
||||
const char *attr_syntax,
|
||||
const struct ldb_val *om_class,
|
||||
enum schema_internal_syntax *syntax);
|
||||
|
||||
int schema_validate(struct ldb_context *ldb,
|
||||
struct ldb_message_element *el,
|
||||
enum schema_internal_syntax type,
|
||||
bool single, int min, int max);
|
||||
|
@ -79,13 +79,13 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem
|
||||
ret = ldb_msg_add_string(msg, attr->lDAPDisplayName, "CASE_INSENSITIVE");
|
||||
}
|
||||
if (ret != LDB_SUCCESS) {
|
||||
return ret;
|
||||
break;
|
||||
}
|
||||
|
||||
if (attr->searchFlags & SEARCH_FLAG_ATTINDEX) {
|
||||
ret = ldb_msg_add_string(msg_idx, "@IDXATTR", attr->lDAPDisplayName);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
return ret;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,11 +105,11 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem
|
||||
}
|
||||
|
||||
if (ret != LDB_SUCCESS) {
|
||||
return ret;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!write_attributes) {
|
||||
if (!write_attributes || ret != LDB_SUCCESS) {
|
||||
talloc_free(mem_ctx);
|
||||
return ret;
|
||||
}
|
||||
@ -120,19 +120,13 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem
|
||||
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
|
||||
ret = ldb_add(ldb, msg);
|
||||
} else if (ret != LDB_SUCCESS) {
|
||||
talloc_free(mem_ctx);
|
||||
return ret;
|
||||
} else if (res->count != 1) {
|
||||
ret = ldb_add(ldb, msg);
|
||||
} else {
|
||||
|
||||
if (res->count != 1) {
|
||||
talloc_free(mem_ctx);
|
||||
return LDB_ERR_NO_SUCH_OBJECT;
|
||||
}
|
||||
|
||||
ret = LDB_SUCCESS;
|
||||
/* Annoyingly added to our search results */
|
||||
ldb_msg_remove_attr(res->msgs[0], "distinguishedName");
|
||||
|
||||
|
||||
mod_msg = ldb_msg_diff(ldb, res->msgs[0], msg);
|
||||
if (mod_msg->num_elements > 0) {
|
||||
ret = ldb_modify(ldb, mod_msg);
|
||||
@ -141,10 +135,11 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem
|
||||
|
||||
if (ret == LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS) {
|
||||
/* We might be on a read-only DB */
|
||||
ret = LDB_SUCCESS;
|
||||
}
|
||||
if (ret != LDB_SUCCESS) {
|
||||
talloc_free(mem_ctx);
|
||||
return ret;
|
||||
} else if (ret != LDB_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Now write out the indexs, as found in the schema (if they have changed) */
|
||||
@ -153,14 +148,10 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem
|
||||
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
|
||||
ret = ldb_add(ldb, msg_idx);
|
||||
} else if (ret != LDB_SUCCESS) {
|
||||
talloc_free(mem_ctx);
|
||||
return ret;
|
||||
} else if (res->count != 1) {
|
||||
ret = ldb_add(ldb, msg_idx);
|
||||
} else {
|
||||
if (res_idx->count != 1) {
|
||||
talloc_free(mem_ctx);
|
||||
return LDB_ERR_NO_SUCH_OBJECT;
|
||||
}
|
||||
|
||||
ret = LDB_SUCCESS;
|
||||
/* Annoyingly added to our search results */
|
||||
ldb_msg_remove_attr(res_idx->msgs[0], "distinguishedName");
|
||||
|
||||
@ -171,7 +162,6 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem
|
||||
}
|
||||
if (ret == LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS) {
|
||||
/* We might be on a read-only DB */
|
||||
talloc_free(mem_ctx);
|
||||
ret = LDB_SUCCESS;
|
||||
}
|
||||
talloc_free(mem_ctx);
|
||||
|
@ -27,14 +27,14 @@ class NoContextTests(unittest.TestCase):
|
||||
|
||||
class SimpleLdb(unittest.TestCase):
|
||||
def test_connect(self):
|
||||
ldb.Ldb("foo.tdb")
|
||||
ldb.Ldb("foo.ldb")
|
||||
|
||||
def test_connect_none(self):
|
||||
ldb.Ldb()
|
||||
|
||||
def test_connect_later(self):
|
||||
x = ldb.Ldb()
|
||||
x.connect("foo.tdb")
|
||||
x.connect("foo.ldb")
|
||||
|
||||
def test_repr(self):
|
||||
x = ldb.Ldb()
|
||||
@ -49,19 +49,19 @@ class SimpleLdb(unittest.TestCase):
|
||||
x.set_modules_dir("/tmp")
|
||||
|
||||
def test_search(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
self.assertEquals(len(l.search()), 1)
|
||||
|
||||
def test_search_controls(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
self.assertEquals(len(l.search(controls=["paged_results:1:5"])), 1)
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
self.assertEquals(len(l.search(controls=["paged_results:0:5"])), 1)
|
||||
|
||||
def test_search_attrs(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
self.assertEquals(len(l.search(ldb.Dn(l, ""), ldb.SCOPE_SUBTREE, "(dc=*)", ["dc"])), 0)
|
||||
|
||||
def test_search_string_dn(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
self.assertEquals(len(l.search("", ldb.SCOPE_SUBTREE, "(dc=*)", ["dc"])), 0)
|
||||
|
||||
def test_search_attr_string(self):
|
||||
@ -69,29 +69,29 @@ class SimpleLdb(unittest.TestCase):
|
||||
self.assertRaises(TypeError, l.search, attrs="dc")
|
||||
|
||||
def test_opaque(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
l.set_opaque("my_opaque", l)
|
||||
self.assertTrue(l.get_opaque("my_opaque") is not None)
|
||||
self.assertEquals(None, l.get_opaque("unknown"))
|
||||
|
||||
def test_parse_control_strings(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
self.assertRaises(ldb.LdbError, l.parse_control_strings, ["foo", "bar"])
|
||||
self.assertTrue(l.parse_control_strings(["paged_results:1:5"]) is not None)
|
||||
self.assertTrue(l.parse_control_strings(["paged_results:0:5"]) is not None)
|
||||
|
||||
def test_search_scope_base(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
self.assertEquals(len(l.search(ldb.Dn(l, "dc=foo"),
|
||||
ldb.SCOPE_ONELEVEL)), 0)
|
||||
|
||||
def test_delete(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
self.assertRaises(ldb.LdbError, lambda: l.delete(ldb.Dn(l, "dc=foo")))
|
||||
|
||||
def test_contains(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
self.assertFalse(ldb.Dn(l, "dc=foo") in l)
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
m = ldb.Message()
|
||||
m.dn = ldb.Dn(l, "dc=foo")
|
||||
m["b"] = ["a"]
|
||||
@ -102,23 +102,23 @@ class SimpleLdb(unittest.TestCase):
|
||||
l.delete(m.dn)
|
||||
|
||||
def test_get_config_basedn(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
self.assertEquals(None, l.get_config_basedn())
|
||||
|
||||
def test_get_root_basedn(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
self.assertEquals(None, l.get_root_basedn())
|
||||
|
||||
def test_get_schema_basedn(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
self.assertEquals(None, l.get_schema_basedn())
|
||||
|
||||
def test_get_default_basedn(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
self.assertEquals(None, l.get_default_basedn())
|
||||
|
||||
def test_add(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
m = ldb.Message()
|
||||
m.dn = ldb.Dn(l, "dc=foo")
|
||||
m["bla"] = "bla"
|
||||
@ -130,7 +130,7 @@ class SimpleLdb(unittest.TestCase):
|
||||
l.delete(ldb.Dn(l, "dc=foo"))
|
||||
|
||||
def test_add_dict(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
m = {"dn": ldb.Dn(l, "dc=foo"),
|
||||
"bla": "bla"}
|
||||
self.assertEquals(len(l.search()), 1)
|
||||
@ -141,7 +141,7 @@ class SimpleLdb(unittest.TestCase):
|
||||
l.delete(ldb.Dn(l, "dc=foo"))
|
||||
|
||||
def test_add_dict_string_dn(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
m = {"dn": "dc=foo", "bla": "bla"}
|
||||
self.assertEquals(len(l.search()), 1)
|
||||
l.add(m)
|
||||
@ -151,7 +151,7 @@ class SimpleLdb(unittest.TestCase):
|
||||
l.delete(ldb.Dn(l, "dc=foo"))
|
||||
|
||||
def test_rename(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
m = ldb.Message()
|
||||
m.dn = ldb.Dn(l, "dc=foo")
|
||||
m["bla"] = "bla"
|
||||
@ -164,7 +164,7 @@ class SimpleLdb(unittest.TestCase):
|
||||
l.delete(ldb.Dn(l, "dc=bar"))
|
||||
|
||||
def test_rename_string_dns(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
m = ldb.Message()
|
||||
m.dn = ldb.Dn(l, "dc=foo")
|
||||
m["bla"] = "bla"
|
||||
@ -177,7 +177,7 @@ class SimpleLdb(unittest.TestCase):
|
||||
l.delete(ldb.Dn(l, "dc=bar"))
|
||||
|
||||
def test_modify_delete(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
m = ldb.Message()
|
||||
m.dn = ldb.Dn(l, "dc=modifydelete")
|
||||
m["bla"] = ["1234"]
|
||||
@ -195,7 +195,7 @@ class SimpleLdb(unittest.TestCase):
|
||||
l.delete(ldb.Dn(l, "dc=modifydelete"))
|
||||
|
||||
def test_modify_add(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
m = ldb.Message()
|
||||
m.dn = ldb.Dn(l, "dc=add")
|
||||
m["bla"] = ["1234"]
|
||||
@ -212,7 +212,7 @@ class SimpleLdb(unittest.TestCase):
|
||||
l.delete(ldb.Dn(l, "dc=add"))
|
||||
|
||||
def test_modify_modify(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
m = ldb.Message()
|
||||
m.dn = ldb.Dn(l, "dc=modify2")
|
||||
m["bla"] = ["1234", "456"]
|
||||
@ -229,7 +229,7 @@ class SimpleLdb(unittest.TestCase):
|
||||
l.delete(ldb.Dn(l, "dc=modify2"))
|
||||
|
||||
def test_transaction_commit(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
l.transaction_start()
|
||||
m = ldb.Message(ldb.Dn(l, "dc=foo"))
|
||||
m["foo"] = ["bar"]
|
||||
@ -238,7 +238,7 @@ class SimpleLdb(unittest.TestCase):
|
||||
l.delete(m.dn)
|
||||
|
||||
def test_transaction_cancel(self):
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
l.transaction_start()
|
||||
m = ldb.Message(ldb.Dn(l, "dc=foo"))
|
||||
m["foo"] = ["bar"]
|
||||
@ -249,13 +249,13 @@ class SimpleLdb(unittest.TestCase):
|
||||
def test_set_debug(self):
|
||||
def my_report_fn(level, text):
|
||||
pass
|
||||
l = ldb.Ldb("foo.tdb")
|
||||
l = ldb.Ldb("foo.ldb")
|
||||
l.set_debug(my_report_fn)
|
||||
|
||||
|
||||
class DnTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.ldb = ldb.Ldb("foo.tdb")
|
||||
self.ldb = ldb.Ldb("foo.ldb")
|
||||
|
||||
def test_eq_str(self):
|
||||
x = ldb.Dn(self.ldb, "dc=foo,bar=bloe")
|
||||
@ -402,7 +402,7 @@ class LdbMsgTests(unittest.TestCase):
|
||||
self.assertEquals(["dn", "foo", "bar"], self.msg.keys())
|
||||
|
||||
def test_dn(self):
|
||||
self.msg.dn = ldb.Dn(ldb.Ldb("foo.tdb"), "@BASEINFO")
|
||||
self.msg.dn = ldb.Dn(ldb.Ldb("foo.ldb"), "@BASEINFO")
|
||||
self.assertEquals("@BASEINFO", self.msg.dn.__str__())
|
||||
|
||||
def test_get_dn(self):
|
||||
|
@ -103,7 +103,7 @@ fi
|
||||
count=`$VALGRIND ldbsearch '(cn<=t)' cn | grep '^dn' | wc -l`
|
||||
if [ $count != 13 ]; then
|
||||
echo returned $count records - expected 13
|
||||
echo "this fails on opsnLdap ..."
|
||||
echo "this fails on openLdap ..."
|
||||
fi
|
||||
|
||||
checkcount() {
|
||||
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 64 B After Width: | Height: | Size: 64 B |
Before Width: | Height: | Size: 49 B After Width: | Height: | Size: 49 B |
Before Width: | Height: | Size: 456 B After Width: | Height: | Size: 456 B |
Before Width: | Height: | Size: 80 B After Width: | Height: | Size: 80 B |
Before Width: | Height: | Size: 44 B After Width: | Height: | Size: 44 B |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 63 B After Width: | Height: | Size: 63 B |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.0 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |