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

  • SEARCH
  • Home
  • 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 6969313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:33:54+00:00 2026-05-27T16:33:54+00:00

So I have been banging my head on this one. I have a self

  • 0

So I have been banging my head on this one. I have a self hosted WCF service:

var webServiceHost = new WebServiceHost(helloWorld);
webServiceHost.Authorization.ImpersonateCallerForAllOperations = true;

var uri = new Uri(BaseUri + webService.UriDirectory);
var webHttpBinding = new WebHttpBinding(webHttpSecurityMode);
webHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;

var sep = webServiceHost.AddServiceEndpoint(IHelloWorld, webHttpBinding, uri);
var webHttpBehavior = new WebHttpBehavior {HelpEnabled = true};
sep.Behaviors.Add(webHttpBehavior);

webServiceHost.Open();

I’ve gone ahead and applied the following attributes to my method:

[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public List<GpoItem> GetAll()
{
    using (ServiceSecurityContext.Current.WindowsIdentity.Impersonate())
    {
        // Execute GPO code here...
        return new List<GpoItem>();
    }
}

To add a bit more context, I basically have a webservice that allows a person to log into a web page, create a GPO on the domain. Running this in a console works fine as I’m running it as the logged in domain user. Running it as a Windows service, throws me an “Access Denied” exception. Thus the need for impersonation. I put in the following altered code above and I get ‘An operations error occurred. (Exception from HRESULT: 0x80072020)’. Googling that shows me its a permission issue still. I’m logging into the Web service test environment as an administrator so I have full access, and I’ve shown I can run it in a console just fine as an administrator. I feel like I’m missing some flag setting some where.

Any ideas?

[Update1] I’ve tried switching the service from running as local system to network service, but I still get the same issue.

[Update2] When I logon on to the server hosting my WCF service (being ran as local system), and use the browser directly on that machine, everything works fine. It seems to be an issue with delegating the users authentication… still unknown here.

  • 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-05-27T16:33:55+00:00Added an answer on May 27, 2026 at 4:33 pm

    Apparently one can only get an Impersonation-level token from WCF attributes which can only be used for local resource access. Instead I had to use LogonUser API so that I could get a Delegate-level token which has network resource access. [1]

    [1] http://msdn.microsoft.com/en-us/library/ff649252.aspx

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

Sidebar

Related Questions

I have been banging my head on this one for too long. I have
I have been banging my head on a wall with this one. I need
I have been banging my head on this one for hours and I am
I have been banging my head on this one all day. The C++ project
Ok, I have been banging my head on this one for a while, figure
I've been banging my head against the wall on this one. I have a
I have been banging my head over this one for quite a while now
Okay, I've been banging my head against the wall with this one. I have
I have been banging my head against this one for a while now and
I have been banging my head against the wall with this odd behaviour on

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.