There *is* a bug here, as Nick pointed out in the first followup - slap_mods2entry does a redundant check for duplicates. All of the mods that get fed into this function have already been checked by slap_mods_check. So we're doing an n^2 check twice on every add, no wonder LDAPAdds are so slow...