Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Host WCF application without UAC/admin privilege

Tags:

c#

wcf

I have written a application which is hosting a WCF Service. And I try to run the application with this config.

<?xml version="1.0"?>
<configuration>
    <system.serviceModel>
        <services>
            <service name="MyApp.Service" behaviorConfiguration="ServiceBehavior">
                <host>
                    <baseAddresses>
                        <add baseAddress="http://localhost:8000/service"/>
                    </baseAddresses>
                </host>
                <endpoint address="" binding="wsHttpBinding" contract="MyApp.IService"/>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior">
                    <serviceMetadata httpGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="False"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

But it cause the application need to run as administrator.
Is it possible to run this application without admin privilege? (If possible, change the config only.) In addition, I also need to add service references in Visual Studio to write a client program. If possible, please keep the application can be added service references in Visual Studio 2010.

like image 389
user554712 Avatar asked Apr 25 '11 02:04

user554712


2 Answers

Based on the comment to my other answer, you won't be able to do this with the built-in HTTP bindings- they're all based on HTTP.sys, which requires rights to be granted to non-admin users to register URLs. If your deployment scenario allows, consider switching to netTcpBinding instead- no permission issues there. Otherwise, you're SOL with the built-in bindings- you'd need to build a raw HTTP transport that's not based on HTTP.sys.

like image 173
nitzmahone Avatar answered Nov 06 '22 20:11

nitzmahone


This solution worked for me (using HTTP binding), open your service on this URL:

http://localhost:80/Temporary_Listen_Addresses/

Must admit that i found it on this site http://www.paraesthesia.com/archive/2010/06/11/developing-as-a-non-admin-testing-wcf-services.aspx/ after google-ing for some time...So credits to that guy.

like image 41
RuudSieb Avatar answered Nov 06 '22 20:11

RuudSieb