For historic reasons, the Username() function returns the local username. When published to the browser, this no longer makes sense since the logged in user is the server account. Please use UserProfileService to get the user name. Or, you can install a third-party Active Directory Web Service, such as Qdabra's ADWS which has more functionality and is easier to use.