Search code examples
c#.netwcfnettcpbinding

WCF error with net.tcp "The service endpoint failed to listen on the URI because access was denied


I'm getting the following error when hosting WCF Net.Tcp service on windows 8.1 machine where I'm in the administrators group: The service endpoint failed to listen on the URI 'net.tcp://localhost:9001/dataservice' because access was denied. Verify that the current user is granted access in the appropriate allowAccounts section of SMSvcHost.exe.config.

I even added the user to the config as suggested:

<?xml version="1.0" encoding="utf-8"?>
<!-- The configuration file for SMSvcHost.exe -->
<configuration>
    <runtime>
        <gcConcurrent enabled="false" />
    </runtime>
    <system.serviceModel>
        <!-- SMSvcHost ETW traces are redirected by default to an etwProviderId different from WCF's default. 
             To trace to the default provider, remove the etwProviderId attribute below. -->
        <diagnostics performanceCounters="Off" etwProviderId="{f18839f5-27ff-4e66-bd2d-639b768cf18b}"/>
    </system.serviceModel>
    <system.serviceModel.activation>
    <net.tcp listenBacklog="10" maxPendingConnections="100" maxPendingAccepts="2" receiveTimeout="00:00:10" teredoEnabled="false">
            <allowAccounts>
                <add securityIdentifier="S-1-5-18"/>

                <add securityIdentifier="S-1-5-19"/>

                <add securityIdentifier="S-1-5-20"/>

                <add securityIdentifier="S-1-5-32-544" />


        <add securityIdentifier="S-1-5-21-2476327175-1934278006-4092406606"/>
            </allowAccounts>
        </net.tcp>
    <net.pipe maxPendingConnections="100" maxPendingAccepts="2" receiveTimeout="00:00:10">
            <allowAccounts>
                <add securityIdentifier="S-1-5-18"/>

                <add securityIdentifier="S-1-5-19"/>

                <add securityIdentifier="S-1-5-20"/>

                <add securityIdentifier="S-1-5-32-544" />


        <add securityIdentifier="S-1-5-21-2476327175-1934278006-4092406606"/>
            </allowAccounts>
        </net.pipe>
        <diagnostics performanceCountersEnabled="true" />
    </system.serviceModel.activation>
</configuration>

But still get the same error, this works fine without any need for config change on a W7 machine, any ideas?


Solution

  • I thought I had added the correct sid in the config but in fact I used the wrong sid. To get hold of the sid I used the cmd psgetsid assuming this would give me the current logged in user which is myself but no, I then used cmd psgetid [username] and this gave me a different sid. Used this and now it works.