2

I'm getting the error "system.net.httplistenerexception: access is denied" when running the following c# code on command line under Non-Admin account "Domain\test", but it works when running under admin elevated account "Domain\test"(e.g. Run as Administrator on Windows Command line):

WebApp.Start(new StartOptions("http:\localhost") { Port = 5000 });

I've been trying with different options as suggested at Running self-hosted OWIN Web API under non-admin account, but non of them works for me.

Can you please help?

Eddy Peng
  • 21
  • 2

1 Answers1

0

By default, non-admin accounts cannot create a URL reservation. To allow a user to bind to a given URL, you'll need to add the URL reservation on behalf of the non-administrative user.

For example, to allow CORP\NonAdmin to bind to any address on port 8080 (but only if it's followed by /MyUri), you could run the following in an elevated context:

netsh http add urlacl url=http://+:8080/MyUri user=CORP\NonAdmin

If you wanted to see which reservations already exist, you could run the following:

netsh http show urlacl

Edit:

I see that you're still have problems. Please provide the output of the following command:

netsh http show urlacl

The output should include an entry similar to the following:

Reserved URL            : http://+:5000/
    User: Domain\test
        Listen: Yes
        Delegate: No
        SDDL: D:(A;;GX;;;S-1-5-##-##########-#########-##########-#######)

Edit:

I see you've posted the output of the netsh command.

The SDDL for the first entry doesn't look right to me. Also, because there are two overlapping URL Reservations with different SDDL values, Windows may be getting the two confused.

You may want to remove both URL Reservations and replace them with a single entry. For example:

To remove the overlapping entries:

netsh http delete urlacl url=http://+:5000/
netsh http delete urlacl url=http://localhost:5000/

Now add a single entry:

netsh http add urlacl url=http://+:5000/ user=Domain\test

Close all windows (maybe reboot) and try to run the console (self-hosted web) app again.

If that doesn't work, let me know and I'll try to help.

Edit:

The goal would be to create a single URL reservation that looks like this:

Reserved URL            : http://+:5000/
    User: Domain\test
        Listen: Yes
        Delegate: No
        SDDL: D:(A;;GX;;;S-1-5-21-839522115-1972579041-2146381891-8170)
RobV8R
  • 1,036
  • 8
  • 16