Ticket 49071 - Import with duplicate DNs throws unexpected errors
Bug Description: When an import fails there are unable to flush error
Fix Description: When an import fails close the database files before
Also fixed a small issue in DSUtil where we did not properly
check if an entry was valid.
Reviewed by: mreynolds(one line commit rule)
(cherry picked from commit 64b1ebffe5af118965bcdf3a84d62c0fc3efd196)