| | |
| | | Attribute modifiedAttribute = mod.getAttribute(); |
| | | if (modifiedAttribute != null && !modifiedAttribute.isEmpty()) |
| | | { |
| | | // Only enforce referential integrity on attributes that this plugin is configured to manage. |
| | | final AttributeType modifiedAttrType = modifiedAttribute.getAttributeType(); |
| | | boolean isManagedAttributeType = false; |
| | | if (modifiedAttrType != null && attributeTypes != null) |
| | | { |
| | | for (AttributeType configuredType : attributeTypes) |
| | | { |
| | | if (modifiedAttrType.equals(configuredType) |
| | | || modifiedAttrType.isSubTypeOf(configuredType)) |
| | | { |
| | | isManagedAttributeType = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!isManagedAttributeType) |
| | | { |
| | | // Skip integrity checks for attributes not configured for this plugin. |
| | | continue; |
| | | } |
| | | PluginResult.PreOperation result = |
| | | isIntegrityMaintained(modifiedAttribute, entryDN, entryBaseDN); |
| | | if (result.getResultCode() != ResultCode.SUCCESS) |
| | |
| | | "uniquemember", "uid=user.100,ou=people,ou=dept,dc=example,dc=com"); |
| | | assertEquals(modOperation.getResultCode(), ResultCode.CONSTRAINT_VIOLATION); |
| | | } |
| | | |
| | | @Test |
| | | public void testEnforceIntegrityModifyGroupAddMissingUniqueMemberWithPriorDelete() throws Exception |
| | | { |
| | | // Configure the plugin in the same way as for the single-ADD test. |
| | | replaceAttrEntry(configDN, "ds-cfg-enabled", "false"); |
| | | replaceAttrEntry(configDN, dsConfigPluginType, |
| | | "postoperationdelete", |
| | | "postoperationmodifydn", |
| | | "subordinatemodifydn", |
| | | "subordinatedelete", |
| | | "preoperationadd", |
| | | "preoperationmodify"); |
| | | addAttrEntry(configDN, dsConfigBaseDN, "dc=example,dc=com"); |
| | | replaceAttrEntry(configDN, dsConfigEnforceIntegrity, "true"); |
| | | replaceAttrEntry(configDN, dsConfigAttrType, "uniquemember"); |
| | | addAttrEntry(configDN, dsConfigAttrFiltMapping, |
| | | "uniquemember:(objectclass=person)"); |
| | | replaceAttrEntry(configDN, "ds-cfg-enabled", "true"); |
| | | |
| | | // Build a modify request with a non-ADD/REPLACE modification first, |
| | | // followed by an ADD of a uniquemember referencing a missing DN. |
| | | final ModifyRequest modifyRequest = newModifyRequest(DN.valueOf(ugroup)); |
| | | modifyRequest.addModification(DELETE, "description"); |
| | | modifyRequest.addModification(ADD, "uniquemember", |
| | | "uid=user.100,ou=people,ou=dept,dc=example,dc=com"); |
| | | |
| | | final InternalClientConnection connection = getRootConnection(); |
| | | final ModifyOperation multiModOperation = connection.processModify(modifyRequest); |
| | | assertEquals(multiModOperation.getResultCode(), ResultCode.CONSTRAINT_VIOLATION); |
| | | } |
| | | } |