I have a Sharepoint 2013 webpart that has a impersonation issue. Webpart solution is created in VS 2012 as a Visual Web Part control. Webpart contains DevExpress controls.

While in development environment everything looks good, the problem is at the production environment. First, it showed "WebPart is not registered as safe" and after editing Safe="true" property, I also had to manually register DevExpress http handler. Webpart is communicating with webservice for data retrieval and that is the point when the problem with impersonation arises.

The code that I am using for impersonation is as follows:

  // Begin impersonation with elevated privileges
       // Get Windows Token for current claim
        WindowsIdentity windowsIdentity = null;
             windowsIdentity = SPSecurityContext.GetWindowsIdentity();
              if (windowsIdentity != null)
                     //Display windows identity properties
                     using (WindowsImpersonationContext ctx = windowsIdentity.Impersonate())
                  //call webservice
             catch (Exception ex)
        //Display exception

Account: It looks like account that is used to call webservice has all permissions.

This is the list that might be relevant: Central Administration settings: 1. Zone: Default 2. Enable Windows Authentication is checked 3. Integrated Windows Authentication is checked 4. Integrated Windows Authentication: NTLM

Security for webpart pages section: 1. Allow users to create connections between webparts (checked) 2. Allow users to access the Online web part gallery

Scriptable webparts section: 1. Prevent contributors from adding or editing scriptable webparts

App pool is running in Integrated mode with the service accounts that is added to local security policy with permissions to: - Impersonate a client after authentication - Log on as a batch job - Log on a service -Act as a aprt of operating system. -Account has delegation settings as in this link

c2wts is running with default settings.

Exception message:

"An error ocurred loading a configuration file: Either a required impersonation level was not provided or the provided impersonation level is invalid. (C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config)"

Exception Source: "System.COnfiguration"

When debugging, windows identity shows "AuthenticationType:Kerberos".

What else to check? is there something I am missing in configuration?

This webpart worked perfectly fine at Sharepoint 2010. I know there were changes in SP 2013 and if anyone has any ideas what else to check I would be very grateful.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.