Set username credential for a new channel without creating a new factory

Posted by Ramon on Stack Overflow See other posts from Stack Overflow or by Ramon
Published on 2010-04-13T16:41:48Z Indexed on 2010/04/13 16:43 UTC
Read the original article Hit count: 570

Filed under:
|
|

I have a backend service and front-end services. They communicate via the trusted subsystem pattern. I want to transfer a username from the frontend to the backend and do this via username credentials as found here:

http://msdn.microsoft.com/en-us/library/ms730288.aspx

This does not work in our scenerio where the front-end builds a backend service channel factory via:

channelFactory = new ChannelFactory<IBackEndService>(.....);

Creating a new channel is done via die channel factory. I can only set the credentials one time after that I get an exception that the username object is read-only.

channelFactory.Credentials.Username.Username = "myCoolFrontendUser";
var channel = channelFactory.CreateChannel();

Is there a way to create the channel factory only one time as this is expensive to create and then specify username credential when creating a channel?

© Stack Overflow or respective owner

Related posts about wcf

Related posts about wcf-security