SharePoint 2013, InfoPath and Claims – GetUserProfileByName
October 11, 2013
Posted by on
You would not believe the hoops you have to go through to get data auto-populated in an InfoPath Form if you’re using Claims-based authentication, which I believe is the default in SharePoint 2013.
You have an on-premise SharePoint 2013 Server installation with InfoPath Forms Services (so you have enterprise) and you want to create an InfoPath form that auto-populates a logged in user’s ID, email, and phone number. You are using Claims-based authentication in the web application in question.
In this scenario, I’m using InfoPath Designer 2010 – I haven’t upgraded to 2013 yet, but I don’t think it makes a difference.
When you use Claims-based authentication, your user name is prefaced by “0#.w|”. So for example, if your user name is SuesDomain\jdoe then your Claims-based user token will be, without the quotes: “0#.w|SuesDomain\jdoe”
InfoPath can’t handle that, or more specifically, the UserProfile.asmx method GetUserProfileByName method can’t handle that. InfoPath tries to pass in your Claims-based user token instead of your domain\User Name.
You get 2 problems – you have an authentication problem where the currently logged in user is not allowed to hit the web service, so you get an Access Denied 401 authentication error. The second problem is getting the right user from the web service.
The steps you have to take are listed here. See the reference posts for more details and pictures.
All of the above was just to get you to Authenticate properly with the Web Service. If you were to stop now, and try to get the information from the web service you would get the information for the user Domain\SP2013_IPRdr. Not the logged in user. Now you have to take the following steps to get the real logged in user:
- Go into InfoPath and go to create a Form Load rule
- For the first rule, call it “Set User Profile” or something similar
- For the second rule, call it something like “Set Fields”
- This is where you fill in your fields from the data source. To find a good example of how to do this, see the first reference in the section at the bottom of this post.
Bottom line: Pain in the rear.