Here is a blog to get the current user information without having to write a code and it works like a charm. Keeping a link here to for reference:
InfoPath - blog from Itay Shakury
InfoPath - Get user information without writing code (extended) - Clayton Cobb