Fix some query issues for admin security for multitenant