Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8780525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:04:29+00:00 2026-06-13T20:04:29+00:00

I have a WCF Channel Factory that has its endpoint modified for a WCF

  • 0

I have a WCF Channel Factory that has its endpoint modified for a WCF service call. What I want is for the service call to be done on a different context which ordinarily is straight forward. However it is not working for me. I can successfully add the credentials to the endpoint behavior, inspect them, and see them but the call is not made using the ‘NewUser’ credentials.

internal static void UpdateChannelClientBehavior(ChannelFactory factory)
{
   factory.Endpoint.Behaviors.Remove<ClientCredentials>();
   //MyCustomCredentials is a custom class class variable that inherits System.ServiceModel.Description.ClientCredentials
   MyCustomCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
   MyCustomCredentials.Windows.ClientCredential = new NetworkCredential("NewUser", "password", "MyDomain");
   factory.Endpoint.Behaviors.Add(MyCustomCredentials);
   return;
}

So after this code the endpoint indeed has the new Windows Credentials but server side it is still being called under the default context and not with the ‘NewUsers’ credentials. What am I doing incorrectly to make this work?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:04:31+00:00Added an answer on June 13, 2026 at 8:04 pm

    Actually this code does work:

    internal static void UpdateChannelClientBehavior(ChannelFactory factory)
    {
       factory.Endpoint.Behaviors.Remove<ClientCredentials>();
       //MyCustomCredentials is a custom class class variable that inherits System.ServiceModel.Description.ClientCredentials
       MyCustomCredentials.Windows.ClientCredential = new NetworkCredential("NewUser", "password", "MyDomain");
       factory.Endpoint.Behaviors.Add(MyCustomCredentials);
       return;
    }
    

    If you were instantiating an instance of the WCF client proxy directly, another way this could be done is as follows:

    MyWcfService.MyWcfServiceServiceClient client = new MyWcfService.MyWcfServiceServiceClient();
    client.ClientCredentials.Windows.ClientCredential = new NetworkCredential("NewUser", "password", "MyDomain");
    

    I was iterating through many attempts of making code changes and has messed up something downstream that was affecting this code. You can indeed change the context of the call using the code above to impersonate a different user making the WCF call. This comes in very handy if needing to temporarily elevate a call to a WCF service.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF service that I need to call in a ASP.NET web
Hi, I have a WCF service hosted in IIS that has the following binding
We have a Windows Service that makes a WCF service call. Normally, it works
I've have a WCF service which has multiple clients that it connects to. What
I have WCF endpoint exposed as defined bellow, <service name=MyApp.Server.Endpoint.Orange behaviorConfiguration=MyTio.Server.Endpoint.OrangeBehavior> <endpoint address= binding=basicHttpBinding
I have a WCF service that accesses a SQL database to fetch data .
I have a WCF web service. I want to send email from this service.
I have a RESTful service that I am developing in WCF . I am
I have a WCF service that needs to know the Principal of the calling
I have a WCF service that I consume in my code and generated as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.