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.
The Scenario:
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.
The Problem:
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 Solution:
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.
References:
Hi Susan, thank you very much for this very helpful post. 🙂
Just a follow-up question, if for example we want to get the user’s Manager, will the function return the manager’s account name in the form of claims (0#.w|contoso\amber.lee) or the standard form (contoso\amber.lee)? Right now, we are getting contoso\amber.lee. Is this the default behavior? Or should we be expecting it in claims notation? Thank you!!
I am no expert on this, but I believe that getting the Manager, you’re getting it from the User Profile Web Service, which is getting it from the User’s SharePoint Profile. My assumption is that either the UPS or the Web Service is handling the account and stripping out the claims tokens. I have experienced the same behavior you have.
I tried this procedure and its throwing an error when I set the AccountName to current user and run the query, please help me
Could you please specify exactly what account name you’re setting by printing it out somewhere on your form (you don’t have to tell me the account name, just verify that it has correctly stripped the Claims token characters off). Also, what is the error message you’re getting?
I mapped an full privileged account in the secure store, then its working but I always get the same user info for any account I try with. Then is the part of changing the account name to current username, yes the claim tokens are being stripped off I check it. The error is “Error accessing the web service” error 5566
Do you have access to the server on which SharePoint is hosted? The “ULS Logs” will probably have more detail for you. I did a little checking and it seems that error 5566 is often a problem with no access to the web service (permissions). You say you mapped a full privileged account in the secure store, can you double-check to make sure that account has at least Read access in the EXACT web site where the user profile service data connection is being made, i.e. the GetUserProfileByName url? If you can get the ULS logs that will help you in determining where the problem lies.
I don’t much information in the ULS logs either. It says WCFLogging:Begin UserProfileGetProperties and end UserProfileGetProperties. Thats what I see in the ULS Logs.
For me I get It working untill the rules, when I add the AccountName = substring-after(userName(), “0#.w|”) and query the data source that is where its throwing the error.
Really nice (and thorough) post but I have a minor suggestion . Instead of setting the formula to “substring-after(userName(), “0#.w|”)” . I would suggest you just use “substring-after(userName(), “|”)” because the claims token can vary.
thanks man, your comment saved me.
I have followed the directions exactly and we are still receiving a 401 Authentication error when trying to hit the Web Service:
The following query failed: GetUserProfileByName (User: 0#.w|domain\current_user, Form Name: ServiceRequest_r1-7-1_20140428, IP: , Connection Target: http://site/IS Data Connection Library/GetUserProfilebyName.udcx, Request: http://site/SitePages/Worker.aspx, Form ID: urn:schemas-microsoft-com:office:infopath:ServiceRequest-r1-7-1-20140428:-dataFormSolution Type: DataAdapterException, Exception Message: The remote server returned an error: (401) Unauthorized. The remote server returned an error: (401) Unauthorized.)
The udcx file is configured for the new Secure Store:
It seems like the Data Connection is still trying to connect to the Web Service using the current logged in user rather than the user specified in the SSO “UPASS”.
Any suggestions for where else I may look?
Thank you,
Eric Magnuson
I am getting 401 error as well and disabling loopback check fixes my problem. this is on SP2013 on windows 2013. http://support.microsoft.com/kb/896861
OMG, you fixed the exact issue I was having. Thank you so much for solving this massive headache for me. Fixed the 401 unauthorized messages for me. Thanks a ton for this. In case that link stops working, here is the work around info from the KB link:
here are two methods to work around this issue, use one of the following methods, as appropriate for your situation.
Method 1: Specify host names (Preferred method if NTLM authentication is desired)
To specify the host names that are mapped to the loopback address and can connect to Web sites on your computer, follow these steps:
Set the
DisableStrictNameChecking
registry entry to 1. For more information about how to do this, click the following article number to view the article in the Microsoft Knowledge Base:
281308 Connecting to SMB share on a Windows 2000-based computer or a Windows Server 2003-based computer may not work with an alias name
Click Start, click Run, type regedit, and then click OK.
In Registry Editor, locate and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
Right-click MSV1_0, point to New, and then click Multi-String Value.
Type BackConnectionHostNames, and then press ENTER.
Right-click BackConnectionHostNames, and then click Modify.
In the Value data box, type the host name or the host names for the sites that are on the local computer, and then click OK.
Quit Registry Editor, and then restart the IISAdmin service.
Method 2: Disable the loopback check (less-recommended method)
The second method is to disable the loopback check by setting the DisableLoopbackCheck registry key.
To set the DisableLoopbackCheck registry key, follow these steps:
Set the
DisableStrictNameChecking
registry entry to 1. For more information about how to do this, click the following article number to view the article in the Microsoft Knowledge Base:
281308 Connecting to SMB share on a Windows 2000-based computer or a Windows Server 2003-based computer may not work with an alias name
Click Start, click Run, type regedit, and then click OK.
In Registry Editor, locate and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
Right-click Lsa, point to New, and then click DWORD Value.
Type DisableLoopbackCheck, and then press ENTER.
Right-click DisableLoopbackCheck, and then click Modify.
In the Value data box, type 1, and then click OK.
Quit Registry Editor, and then restart your computer.
Reblogged this on crazyforsharepoint and commented:
Unable to hit User Profile Service in InfoPath Form in SharePoint 2013 Claims Based Web Application
Reblogged this on SharePoint and everything else … and commented:
Brilliant! Short, sweet but did the job perfectly. Thank you!
Sue, I’m still having 5566 error issues. I read that you have to create a classic mode web app in sp2013, then connect the cuff through there. Is t his true?
Cuff, meant UDC
Pingback: Security Trimming SharePoint 2010 InfoPath Form Fields | SharePoint Diva
Fantastic post – thanks for sharing and saving some of my sanity!
Pingback: InfoPath vs SharePoint 2013 Web Services | rule30
I get the information of the webapp application pool identity instead of the user opening the form. Has anyone else run into this issue?
did you ever managed to get the actual username? I have the exact Problem, and I think I have configured everything correctly.
Ditto. Getting the application pool identity
Hi Joe! After a *very* long hiatus, I am trying to slowly come back to blogging and writing. I noticed your recent comment here, and I am (believe it or not) actually working with this issue currently with a client.
So the issues in a nutshell are:
1) Need to authenticate to the web service in a special manner, using a privileged account specifically set up for this – in your case, you may be using the App Pool service account, in my case, we set up a special “InfoPath Reader” service account for this access.
2) When you do set up that authentication, then by default, if you just simply then query the web service, you will receive all of the information about the service account. You will get the display name, email, account ID, etc, for the privileged service account.
3) To retrieve the “actual” user, you have to take a multi-step process [I need to update this blog post with pictures of doing this]:
a) Action: Set a Field’s Value.
i) Field to set: Drill into the GetUserProfileByName secondary data connection, expand queryFields, and pick the field AccountName
ii) Value to set it to: this formula:
substring-after(userName(), “|”)
b) Action: Query for Data
i) Data Connection: the GetUserProfileByName secondary data connection
c) Action: Set a Field’s Value
i) Field to set:
ii) Value to set it to:
Pick your GetUserProfileByName secondary data connection; expand all the way to “Value”; highlight it and click “Filter”; Pick its parent field called “Name”; Type text for equals “PreferredName” (or WorkEmail, etc – any profile field). Basically this here is drilling into the GetUserProfileByName data connection and picking from the name/value pairs for all the info returned by the user profile.
I’d be interested if you got this to work. When I get home I will try to update the post with more pictures and step-by-step of those parts.
Thanks for your interest!!
Sue Hernandez
Thank you so much! I spend hours to search for the problem, but never find the hint to add the “substring-after-rule”. Best regards 🙂
WHat was the account credentials i need to give while setting credentials to application at SSO , I have given the account which we used to create all service applications on the server. I am still getting the error 5566.could anyone help me out as I am struck with this thing since 4 days. thanks all
Hi vink, have you found the solution for your issue? Thanks.
In this way how can I get FirstName, LastName, PreferredName, WorkEmail and the other AD Information.
Hi, has anyone found the solution for the 5566 error? The logs show “Credentials in SSO (Windows=[no], Username=[yes], Password= [yes]) did not match the specified type “NTLM”.
I am a bit stuck on this one. Any advise is welcome! Thanks!
http://macenstein.com/default/application-for-mac-chick-of-the-month/