What permissions are needed to use System.Net.HttpListener without adding a namespace reservation?

725 views Asked by At

I know that if the user is a member of the BUILTIN\administrators group on a computer that you do not need to add a namespace reservation to listen on any port or URI with System.Net.HttpListener (i.e. HTTP.sys).

However is it possible to give a user or group the required permissions without adding that user to the BUILTIN\administrators group?

In my case I'm building an application with a requirement to dynamically start/stop many HttpListener instances on many different and configurable port numbers. Unfortunately I cannot add a wildcard port number. I'm hoping to avoid adding a huge range of ports.

This article suggests that the ACL logic is tied to the group and not some underlying permission.

1

There are 1 answers

0
Patrick Hofman On

If possible you could opt to use localhost as prefix. Then you don't need administrative rights.

The down side of this approach is that the server can't be accessed from outside the machine, which might be a use case for you.

Also, instead of using prefixes to distinguish users, you might need to use folders or port numbers to do so.

The following snippet works without admin rights:

using (var hl = new HttpListener())
{
    hl.Prefixes.Add("http://localhost:8008/myserver/");
    hl.Start();
}