Only check for valid realm and domain if not doing a cleanup
Consolidate duplicate code checking for domain and realm