WERROR dsdb_attribute_from_ldb(struct ldb_context *ldb, struct dsdb_schema *schema, struct ldb_message *msg) { WERROR status; struct dsdb_attribute *attr = talloc_zero(schema, struct dsdb_attribute); if (!attr) { return WERR_NOMEM; } GET_STRING_LDB(msg, "cn", attr, attr, cn, false); GET_STRING_LDB(msg, "lDAPDisplayName", attr, attr, lDAPDisplayName, true); GET_STRING_LDB(msg, "attributeID", attr, attr, attributeID_oid, true); if (!schema->prefixmap || schema->prefixmap->length == 0) { /* set an invalid value */ attr->attributeID_id = DRSUAPI_ATTID_INVALID; } else { status = dsdb_schema_pfm_make_attid(schema->prefixmap, attr->attributeID_oid, &attr->attributeID_id); if (!W_ERROR_IS_OK(status)) { DEBUG(0,("%s: '%s': unable to map attributeID %s: %s\n", __location__, attr->lDAPDisplayName, attr->attributeID_oid, win_errstr(status))); return status; } } /* fetch msDS-IntId to be used in resolving ATTRTYP values */ GET_UINT32_LDB(msg, "msDS-IntId", attr, msDS_IntId); GET_GUID_LDB(msg, "schemaIDGUID", attr, schemaIDGUID); GET_UINT32_LDB(msg, "mAPIID", attr, mAPIID); GET_GUID_LDB(msg, "attributeSecurityGUID", attr, attributeSecurityGUID); GET_GUID_LDB(msg, "objectGUID", attr, objectGUID); GET_UINT32_LDB(msg, "searchFlags", attr, searchFlags); GET_UINT32_LDB(msg, "systemFlags", attr, systemFlags); GET_BOOL_LDB(msg, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, false); GET_UINT32_LDB(msg, "linkID", attr, linkID); GET_STRING_LDB(msg, "attributeSyntax", attr, attr, attributeSyntax_oid, true); if (!schema->prefixmap || schema->prefixmap->length == 0) { /* set an invalid value */ attr->attributeSyntax_id = DRSUAPI_ATTID_INVALID; } else { status = dsdb_schema_pfm_attid_from_oid(schema->prefixmap, attr->attributeSyntax_oid, &attr->attributeSyntax_id); if (!W_ERROR_IS_OK(status)) { DEBUG(0,("%s: '%s': unable to map attributeSyntax_ %s: %s\n", __location__, attr->lDAPDisplayName, attr->attributeSyntax_oid, win_errstr(status))); return status; } } GET_UINT32_LDB(msg, "oMSyntax", attr, oMSyntax); GET_BLOB_LDB(msg, "oMObjectClass", attr, attr, oMObjectClass); GET_BOOL_LDB(msg, "isSingleValued", attr, isSingleValued, true); GET_UINT32_PTR_LDB(msg, "rangeLower", attr, attr, rangeLower); GET_UINT32_PTR_LDB(msg, "rangeUpper", attr, attr, rangeUpper); GET_BOOL_LDB(msg, "extendedCharsAllowed", attr, extendedCharsAllowed, false); GET_UINT32_LDB(msg, "schemaFlagsEx", attr, schemaFlagsEx); GET_BLOB_LDB(msg, "msDs-Schema-Extensions", attr, attr, msDs_Schema_Extensions); GET_BOOL_LDB(msg, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, false); GET_STRING_LDB(msg, "adminDisplayName", attr, attr, adminDisplayName, false); GET_STRING_LDB(msg, "adminDescription", attr, attr, adminDescription, false); GET_STRING_LDB(msg, "classDisplayName", attr, attr, classDisplayName, false); GET_BOOL_LDB(msg, "isEphemeral", attr, isEphemeral, false); GET_BOOL_LDB(msg, "isDefunct", attr, isDefunct, false); GET_BOOL_LDB(msg, "systemOnly", attr, systemOnly, false); attr->syntax = dsdb_syntax_for_attribute(attr); if (!attr->syntax) { DEBUG(0,(__location__ ": Unknown schema syntax for %s\n", attr->lDAPDisplayName)); return WERR_DS_ATT_SCHEMA_REQ_SYNTAX; } if (dsdb_schema_setup_ldb_schema_attribute(ldb, attr) != LDB_SUCCESS) { DEBUG(0,(__location__ ": Unknown schema syntax for %s - ldb_syntax: %s, ldap_oid: %s\n", attr->lDAPDisplayName, attr->syntax->ldb_syntax, attr->syntax->ldap_oid)); return WERR_DS_ATT_SCHEMA_REQ_SYNTAX; } DLIST_ADD(schema->attributes, attr); return WERR_OK; }
WERROR dsdb_attribute_from_ldb(const struct dsdb_schema *schema, struct ldb_message *msg, struct dsdb_attribute *attr) { WERROR status; if (attr == NULL) { DEBUG(0, ("%s: attr is null, it's expected not to be so\n", __location__)); return WERR_INVALID_PARAM; } GET_STRING_LDB(msg, "cn", attr, attr, cn, false); GET_STRING_LDB(msg, "lDAPDisplayName", attr, attr, lDAPDisplayName, true); GET_STRING_LDB(msg, "attributeID", attr, attr, attributeID_oid, true); if (!schema->prefixmap || schema->prefixmap->length == 0) { /* set an invalid value */ attr->attributeID_id = DRSUAPI_ATTID_INVALID; } else { status = dsdb_schema_pfm_make_attid(schema->prefixmap, attr->attributeID_oid, &attr->attributeID_id); if (!W_ERROR_IS_OK(status)) { DEBUG(0,("%s: '%s': unable to map attributeID %s: %s\n", __location__, attr->lDAPDisplayName, attr->attributeID_oid, win_errstr(status))); return status; } } /* fetch msDS-IntId to be used in resolving ATTRTYP values */ GET_UINT32_LDB(msg, "msDS-IntId", attr, msDS_IntId); GET_GUID_LDB(msg, "schemaIDGUID", attr, schemaIDGUID); GET_UINT32_LDB(msg, "mAPIID", attr, mAPIID); GET_GUID_LDB(msg, "attributeSecurityGUID", attr, attributeSecurityGUID); GET_GUID_LDB(msg, "objectGUID", attr, objectGUID); GET_UINT32_LDB(msg, "searchFlags", attr, searchFlags); GET_UINT32_LDB(msg, "systemFlags", attr, systemFlags); GET_BOOL_LDB(msg, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, false); GET_UINT32_LDB(msg, "linkID", attr, linkID); GET_STRING_LDB(msg, "attributeSyntax", attr, attr, attributeSyntax_oid, true); if (!schema->prefixmap || schema->prefixmap->length == 0) { /* set an invalid value */ attr->attributeSyntax_id = DRSUAPI_ATTID_INVALID; } else { status = dsdb_schema_pfm_attid_from_oid(schema->prefixmap, attr->attributeSyntax_oid, &attr->attributeSyntax_id); if (!W_ERROR_IS_OK(status)) { DEBUG(0,("%s: '%s': unable to map attributeSyntax_ %s: %s\n", __location__, attr->lDAPDisplayName, attr->attributeSyntax_oid, win_errstr(status))); return status; } } GET_UINT32_LDB(msg, "oMSyntax", attr, oMSyntax); GET_BLOB_LDB(msg, "oMObjectClass", attr, attr, oMObjectClass); GET_BOOL_LDB(msg, "isSingleValued", attr, isSingleValued, true); GET_UINT32_PTR_LDB(msg, "rangeLower", attr, attr, rangeLower); GET_UINT32_PTR_LDB(msg, "rangeUpper", attr, attr, rangeUpper); GET_BOOL_LDB(msg, "extendedCharsAllowed", attr, extendedCharsAllowed, false); GET_UINT32_LDB(msg, "schemaFlagsEx", attr, schemaFlagsEx); GET_BLOB_LDB(msg, "msDs-Schema-Extensions", attr, attr, msDs_Schema_Extensions); GET_BOOL_LDB(msg, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, false); GET_STRING_LDB(msg, "adminDisplayName", attr, attr, adminDisplayName, false); GET_STRING_LDB(msg, "adminDescription", attr, attr, adminDescription, false); GET_STRING_LDB(msg, "classDisplayName", attr, attr, classDisplayName, false); GET_BOOL_LDB(msg, "isEphemeral", attr, isEphemeral, false); GET_BOOL_LDB(msg, "isDefunct", attr, isDefunct, false); GET_BOOL_LDB(msg, "systemOnly", attr, systemOnly, false); return WERR_OK; }