When you create an InfoPath form, which you for example are going to use in a SharePoint site, you want to automatically fill in the name of the user. This is not very in infoPath:
1. Create an InfoPath form and drag a textbox control on the design surface
2. Go to the properties of the textbox, by double or right clicking on it. Once you have the properties dialog box open,you can opt to fill in a default value. We going to use a function to fill in the value.
Click on the button next to the default value textbox and insert a new function.
3. Now search for the userName function, it's the last one if you search in the All category:
Close the properties and open your form, you will see that the name is automatically filled in now.