Login problems on custom domains and root site

I’ve got Multi Domains and Domain Mapping set up on wpmu with BuddyPress:

Site 1: root site on maindomain.com (network root)

Site 2: buddypress on bp.maindomain.com (buddypress)

Site 3: test on test.maindomain.com (subsite)

Site 4: test2 on test.alternatedomain.com (multi-domains)

Site 5: custom on customdomain.com (domain mapped)

As my main super admin account, I can log into the dashboard of the network, root site, buddypress site, subsites on main domain, subsites on alternate domains.

But I can’t log in to the dashboard of sites on custom domains (mapped using domain mapping) and I can’t log in to the front end of the custom domains or of the root site on maindomain.com – I just see the logged out toolbar, and it won’t accept my login.

How can this be?