2

I have a windows service that runs a WCF Net Tcp binding service. All binding and endpoint information is set programmatically.

_host.AddServiceEndpoint(typeof(IService), new NetTcpBinding(), serviceName);

In sharepoint I am accessing this service using a channel factory:

var channelFactory = new ChannelFactory<IService>(
  new NetTcpBinding(),
  new EndpointAddress(new Uri(connectionUrl))
);
 return channelFactory.CreateChannel();

This code ran fine using SharePoint 2007. Now that we are upgrading our SharePoint site to 2010 the new forms based claims identity is not sending client credentials. I get this error.

System.IdentityModel.Tokens.SecurityTokenValidationException, System.IdentityModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
The service does not allow you to log on anonymously.

Does anyone know how I can get the Channel Factory to send the application pool's credentials? Right now I have solved my issue by using RunWithElevatedPrivileges but I'm not really keen on doing that unless I do not have any other choice.

1 Answer 1

2

We solved it using this approach:

using(WindowsIdentity.Impersonate(IntPtr.Zero))
{
  var result = channel.ServiceMethod();
}

This in my opinion is better then needlessly elevating SharePoint credentials using RunWithElevatedPrivileges.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.