One of the most commonly used SharePoint web services through InfoPath is the UserProfileService. This service can render information about the current user accessing the form. (click here if you need to find out more about how to use UserProfileService)
I was developing an InfoPath solution that required the logged-in-user’s Manager and Department information. Naturally, the UserProfileService is a great candidate to achieve this requirement. As a first step, I created the data connection and configured the form to display user’s first name. I verified by previewing the form in InfoPath Designer and saw that my first name was displayed properly. Everything was looking kosher, so I proceeded to publish the form onto SharePoint as a web-based-form. I then opened the form in SharePoint, and instead of seeing my user info, I saw the user info for a SharePoint admin.
This dazed and confused look went on for a couple of weeks as I searched and searched the Interweb for answers. As luck would have it, I had the chance to sit in on Clayton Cobb‘s InfoPath session during SharePoint Saturday The Conference. I approached Clayton with this problem and he instantly knew the remedy.
Apparently in a claims-based-authentication farm, SharePoint Form Services mistakenly displays the service account that manages the application pool’s worker process. This means two things: (1) I’m not completely crazy (2) I need to find a workaround from Clayton. Thankfully there is one.
Here’s the workaround, if your UserProfileService is displaying an admin user account:
- Disable auto-retrieval of the UserProfileService Data Connection
- Modify the Data Connection
- Get to the last step of the wizard and deselect “Automatically retrieve data when form is opened”
- Assign your Field by selecting the User Profile data connection > queryFields > AccountName
- Assign the value with the following:
- Click button
- Insert function of concat
- Replace the inside of the concat function with
- Then insert function of username
- Your formula should like the following below
- Click OK twice to save your form load rule
Now you should be able to see the correct user profile information.
Moral of this experience. Don’t bother troubleshooting it yourself, just talk to an MVP.