use replication username attribute

This is #141 rebased on top of the latest master.