7

ServiceHost.Open() is throwing this error:

HTTP could not register URL http://+:8001/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).

So I used netsh to add the url. But event though it is added, i'm still getting the error. This is the command I use:

netsh http add urlacl url=http://+:8001/ user=djerryy

djerryy is my computername. When I run netsh http show urlacl i see it was added.

What am I doing wrong?

Thanks in advance.

Enrico Campidoglio
  • 56,676
  • 12
  • 126
  • 154
Terry
  • 5,132
  • 4
  • 33
  • 66

3 Answers3

22

It looks like you are missing the name of the user account who is running the service. Here's a couple of options:

  • Local user account:
netsh http add urlacl url=http://+:8001/ user=ComputerName\Username
  • Domain user account:
netsh http add urlacl url=http://+:8001/ user=DomainName\Username
  • Built-in NetworkService account:
netsh http add urlacl url=http://+:8001/ user="NT AUTHORITY\NETWORK SERVICE"
Enrico Campidoglio
  • 56,676
  • 12
  • 126
  • 154
  • i'm not in a domain. and i tried DJERRYY\Djerry, which still gave me the same error – Terry May 28 '10 at 09:14
  • Where are you hosting your service? Do you start it from Visual Studio? What is the service endpoint? – Enrico Campidoglio May 28 '10 at 09:47
  • No, the service was installed with a setup project. It runs form windows services. This is the address i'm using as Uri : "net.tcp://localhost:8000", but i also tries adding 8000... – Terry May 28 '10 at 09:52
  • That URL does not use HTTP as transport protocol. It uses TCP, so you shouldn't get that error. Shouldn't it be "http://localhost:8001" instead? Also, under which user account is the Windows Service running? – Enrico Campidoglio May 28 '10 at 10:04
  • you've lost me now: this (net.tcp://localhost:8000) isn't used in commands if i understand you correctly, it is the setup of my server (this link shows my setup : http://stackoverflow.com/questions/2847097/how-to-restart-a-wcf-server-from-within-a-client) the service is running as a network service, and i'm logged in as "djerry", which should be administrator. – Terry May 28 '10 at 10:14
  • 1
    You need to grant access to the HTTP URL to the NetworkService account. I updated my answer with the correct command. – Enrico Campidoglio May 28 '10 at 10:47
  • at last, servicehost opened. Now to get my client connected again... :) – Terry May 28 '10 at 11:49
5

I must stress:

netsh http add urlacl url=http://+:8001/ user="NT AUTHORITY\NETWORK SERVICE"

will work only on a system with the English locale!

A better way is to remove that one space and make it:

netsh http add urlacl url=http://+:8001/ user="NT AUTHORITY\NETWORKSERVICE"

Now the command will work on any locale. I spent a good 0,5h battling this today... all because of a single char. ;)

MBender
  • 5,395
  • 1
  • 42
  • 69
0

To add even more to this answer: You MUST specify a port number! Spend quite a while trying to authorize a service to bind to a normal HTTP address, it only started working when I explicitly specified:

netsh http add urlacl 
    url=http://some.example.com:80/extension/ 
    user="NT AUTHORITY\NETWORKSERVICE"
w5l
  • 5,341
  • 1
  • 25
  • 43