#include "librpc/gen_ndr/ndr_misc.h"
#include "librpc/ndr/libndr.h"
#include "dsdb/samdb/samdb.h"
+#include "../../../lib/ldb/include/ldb_handlers.h"
struct entryuuid_private {
struct ldb_context *ldb;
return out;
}
+/* Ensure we always convert sids into string, so the backend doesn't have to know about both forms */
+static struct ldb_val sid_always_string(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
+{
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
+ struct ldb_val out = data_blob(NULL, 0);
+
+ if (ldif_comparision_objectSid_isString(val)) {
+ if (ldb_handler_copy(ldb, ctx, val, &out) != LDB_SUCCESS) {
+ return data_blob(NULL, 0);
+ }
+
+ } else {
+ if (ldif_write_objectSid(ldb, ctx, val, &out) != LDB_SUCCESS) {
+ return data_blob(NULL, 0);
+ }
+ }
+ return out;
+}
+
/* Ensure we always convert objectCategory into a DN */
static struct ldb_val objectCategory_always_dn(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
{
static struct ldb_val normalise_to_signed32(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
{
struct ldb_val out;
- int32_t i = (int32_t) strtol((char *)val->data, NULL, 0);
+ /* We've to use "strtoll" here to have the intended overflows.
+ * Otherwise we may get "LONG_MAX" and the conversion is wrong. */
+ int32_t i = (int32_t) strtoll((char *)val->data, NULL, 0);
out = data_blob_string_const(talloc_asprintf(ctx, "%d", i));
return out;
}
/* objectGUID */
{
.local_name = "objectGUID",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "entryUUID",
/* invocationId */
{
.local_name = "invocationId",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "invocationId",
/* objectSid */
{
.local_name = "objectSid",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "objectSid",
},
{
.local_name = "name",
- .type = MAP_RENAME,
+ .type = LDB_MAP_RENAME,
.u = {
.rename = {
.remote_name = "samba4RDN"
},
{
.local_name = "whenCreated",
- .type = MAP_RENAME,
+ .type = LDB_MAP_RENAME,
.u = {
.rename = {
.remote_name = "createTimestamp"
},
{
.local_name = "whenChanged",
- .type = MAP_RENAME,
+ .type = LDB_MAP_RENAME,
.u = {
.rename = {
.remote_name = "modifyTimestamp"
},
{
.local_name = "objectClasses",
- .type = MAP_RENAME,
+ .type = LDB_MAP_RENAME,
.u = {
.rename = {
.remote_name = "samba4ObjectClasses"
},
{
.local_name = "dITContentRules",
- .type = MAP_RENAME,
+ .type = LDB_MAP_RENAME,
.u = {
.rename = {
.remote_name = "samba4DITContentRules"
},
{
.local_name = "attributeTypes",
- .type = MAP_RENAME,
+ .type = LDB_MAP_RENAME,
.u = {
.rename = {
.remote_name = "samba4AttributeTypes"
},
{
.local_name = "objectCategory",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "objectCategory",
},
{
.local_name = "distinguishedName",
- .type = MAP_RENAME,
+ .type = LDB_MAP_RENAME,
.u = {
.rename = {
.remote_name = "entryDN"
}
}
},
+ {
+ .local_name = "primaryGroupID",
+ .type = LDB_MAP_CONVERT,
+ .u = {
+ .convert = {
+ .remote_name = "primaryGroupID",
+ .convert_local = normalise_to_signed32,
+ .convert_remote = val_copy,
+ }
+ }
+ },
{
.local_name = "groupType",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "groupType",
.convert_local = normalise_to_signed32,
.convert_remote = val_copy,
- },
+ }
}
},
{
.local_name = "userAccountControl",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "userAccountControl",
.convert_local = normalise_to_signed32,
.convert_remote = val_copy,
- },
+ }
}
},
{
.local_name = "sAMAccountType",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "sAMAccountType",
.convert_local = normalise_to_signed32,
.convert_remote = val_copy,
- },
+ }
+ }
+ },
+ {
+ .local_name = "systemFlags",
+ .type = LDB_MAP_CONVERT,
+ .u = {
+ .convert = {
+ .remote_name = "systemFlags",
+ .convert_local = normalise_to_signed32,
+ .convert_remote = val_copy,
+ }
}
},
{
.local_name = "usnChanged",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "entryCSN",
},
{
.local_name = "usnCreated",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "createTimestamp",
},
{
.local_name = "*",
- .type = MAP_KEEP,
+ .type = LDB_MAP_KEEP,
},
{
.local_name = NULL,
/* objectGUID */
{
.local_name = "objectGUID",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "nsuniqueid",
.convert_local = guid_ns_string,
.convert_remote = encode_ns_guid,
- },
- },
+ }
+ }
},
/* objectSid */
{
.local_name = "objectSid",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
- .remote_name = "objectSid",
- .convert_local = sid_always_binary,
- .convert_remote = val_copy,
- },
- },
+ .remote_name = "sambaSID",
+ .convert_local = sid_always_string,
+ .convert_remote = sid_always_binary,
+ }
+ }
},
{
.local_name = "whenCreated",
- .type = MAP_RENAME,
+ .type = LDB_MAP_RENAME,
.u = {
.rename = {
.remote_name = "createTimestamp"
},
{
.local_name = "whenChanged",
- .type = MAP_RENAME,
+ .type = LDB_MAP_RENAME,
.u = {
.rename = {
.remote_name = "modifyTimestamp"
},
{
.local_name = "objectCategory",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "objectCategory",
.convert_local = objectCategory_always_dn,
.convert_remote = val_copy,
- },
- },
+ }
+ }
},
{
.local_name = "distinguishedName",
- .type = MAP_RENAME,
+ .type = LDB_MAP_RENAME,
.u = {
.rename = {
.remote_name = "entryDN"
}
}
},
+ {
+ .local_name = "primaryGroupID",
+ .type = LDB_MAP_CONVERT,
+ .u = {
+ .convert = {
+ .remote_name = "primaryGroupID",
+ .convert_local = normalise_to_signed32,
+ .convert_remote = val_copy,
+ }
+ }
+ },
{
.local_name = "groupType",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
- .remote_name = "groupType",
+ .remote_name = "sambaGroupType",
.convert_local = normalise_to_signed32,
.convert_remote = val_copy,
- },
+ }
}
},
{
.local_name = "userAccountControl",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "userAccountControl",
.convert_local = normalise_to_signed32,
.convert_remote = val_copy,
- },
+ }
}
},
{
.local_name = "sAMAccountType",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "sAMAccountType",
.convert_local = normalise_to_signed32,
.convert_remote = val_copy,
- },
+ }
+ }
+ },
+ {
+ .local_name = "systemFlags",
+ .type = LDB_MAP_CONVERT,
+ .u = {
+ .convert = {
+ .remote_name = "systemFlags",
+ .convert_local = normalise_to_signed32,
+ .convert_remote = val_copy,
+ }
}
},
{
.local_name = "usnChanged",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "modifyTimestamp",
.convert_local = usn_to_timestamp,
.convert_remote = timestamp_to_usn,
- },
- },
+ }
+ }
},
{
.local_name = "usnCreated",
- .type = MAP_CONVERT,
+ .type = LDB_MAP_CONVERT,
.u = {
.convert = {
.remote_name = "createTimestamp",
.convert_local = usn_to_timestamp,
.convert_remote = timestamp_to_usn,
- },
- },
+ }
+ }
+ },
+ {
+ .local_name = "pwdLastSet",
+ .type = LDB_MAP_RENAME,
+ .u = {
+ .rename = {
+ .remote_name = "sambaPwdLastSet"
+ }
+ }
+ },
+ {
+ .local_name = "lastLogon",
+ .type = LDB_MAP_RENAME,
+ .u = {
+ .rename = {
+ .remote_name = "sambaLogonTime"
+ }
+ }
+ },
+ {
+ .local_name = "lastLogoff",
+ .type = LDB_MAP_RENAME,
+ .u = {
+ .rename = {
+ .remote_name = "sambaLogoffTime"
+ }
+ }
+ },
+ {
+ .local_name = "badPwdCount",
+ .type = LDB_MAP_RENAME,
+ .u = {
+ .rename = {
+ .remote_name = "sambaBadPasswordCount"
+ }
+ }
+ },
+ {
+ .local_name = "logonHours",
+ .type = LDB_MAP_RENAME,
+ .u = {
+ .rename = {
+ .remote_name = "sambaLogonHours"
+ }
+ }
+ },
+ {
+ .local_name = "homeDrive",
+ .type = LDB_MAP_RENAME,
+ .u = {
+ .rename = {
+ .remote_name = "sambaHomeDrive"
+ }
+ }
+ },
+ {
+ .local_name = "scriptPath",
+ .type = LDB_MAP_RENAME,
+ .u = {
+ .rename = {
+ .remote_name = "sambaLogonScript"
+ }
+ }
+ },
+ {
+ .local_name = "profilePath",
+ .type = LDB_MAP_RENAME,
+ .u = {
+ .rename = {
+ .remote_name = "sambaProfilePath"
+ }
+ }
+ },
+ {
+ .local_name = "userWorkstations",
+ .type = LDB_MAP_RENAME,
+ .u = {
+ .rename = {
+ .remote_name = "sambaUserWorkstations"
+ }
+ }
+ },
+ {
+ .local_name = "homeDirectory",
+ .type = LDB_MAP_RENAME,
+ .u = {
+ .rename = {
+ .remote_name = "sambaHomePath"
+ }
+ }
+ },
+ {
+ .local_name = "nextRid",
+ .type = LDB_MAP_RENAME,
+ .u = {
+ .rename = {
+ .remote_name = "sambaNextRid"
+ }
+ }
+ },
+ {
+ .local_name = "privilegeDisplayName",
+ .type = LDB_MAP_RENAME,
+ .u = {
+ .rename = {
+ .remote_name = "sambaPrivName"
+ }
+ }
},
{
.local_name = "*",
- .type = MAP_KEEP,
+ .type = LDB_MAP_KEEP,
},
{
.local_name = NULL,
}
};
+/* This objectClass conflicts with builtin classes on FDS */
+const struct ldb_map_objectclass nsuniqueid_objectclasses[] =
+{
+ {
+ .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 */
static const char * const nsuniqueid_wildcard_attributes[] = {
static int nsuniqueid_init(struct ldb_module *module)
{
int ret;
- ret = ldb_map_init(module, nsuniqueid_attributes, NULL, nsuniqueid_wildcard_attributes, "extensibleObject", NULL);
+ ret = ldb_map_init(module, nsuniqueid_attributes, nsuniqueid_objectclasses, nsuniqueid_wildcard_attributes, "extensibleObject", NULL);
if (ret != LDB_SUCCESS)
return ret;