Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We have a document library that contains a list of proposals (InfoPath Forms). Users log in through SharePoint using Claims (Forms Auth, via an Extranet) who are from various organizations. The InfoPath form contains a field for what organization the proposal belongs to (a select list) that the user then selects when filling the form.

We have written a custom claims provider that augments each user's login with an organization claim.

When the user opens a proposal from SharePoint in the InfoPath form filler, we'd like to:

  • Pre-populate the organization select list with the organization matching the user's claim
  • Restrict the saving of the form (inserting and updating) if the user's claim value for organization does not match the selected organization on the form

I'm wondering how to get the claims information in InfoPath. Or, for ideas on how to do this server-side using a custom workflow/event receiver/web service (or something else).

share|improve this question
add comment

1 Answer 1

I'm not sure if this will provide the claims you are looking for, but hopefully will get you pointed in the right direction. In the code behind of the InfoPath form you can grab the current user, and from there determine the claims information. Try something like this in the On_load event

            SPClaimsAuthMembershipProvider claimsProvider = new SPClaimsAuthMembershipProvider();

            SPUser user = SPContext.Current.Web.CurrentUser;
            MembershipUser mu = claimsProvider.GetUser(user.ID, true);
share|improve this answer
    
I tried this in the FormEvents_Loading event... All of the SPxxxx types are not found. This might work in a web part but InfoPath is running on a client machine (not the server). If this was server-side, I'd use Page.User as IClaimsPrincipal, but that doesn't seem to be an option here. –  umbyersw Apr 5 '12 at 1:26
1  
Did you try adding using Microsoft.SharePoint at the top of the code file? You will also need to add using System.Web.Security; using System.Configuration.Provider; as well as add the Service.Configuration to your References. You can also try HttpContext.Current.User –  Meyer Denney Apr 5 '12 at 4:44
    
After the references were resolved (thanks), this error appears in a pop-up from InfoPath: System.Security.SecurityException Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. –  umbyersw Apr 5 '12 at 15:50
    
Try adding a SPSecurity.RunWithElevatedPermission(delegate() {code goes here}); around the code where you are accessing permissions. If that doesn't work then you may need to remove that reference. The code behind for InfoPath uses Visual Studio Tools for Applications which doesn't not have full support of the .Net framework. There has been times where I have tried to add various assemblies that wouldn't work for me. Hopefully that is an assembly you can get away without needing. –  Meyer Denney Apr 5 '12 at 17:24
    
Same exception :( In fact even just that, the SPSecurity.RunWithElevatedPrivileges(delegate() {}); with nothing inside it, still throws the security exception. I changed the form to full trust, and now I'm getting this error... Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 80040154. –  umbyersw Apr 6 '12 at 0:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.