简体   繁体   English

没有UAC / admin权限的主机WCF应用程序

[英]Host WCF application without UAC/admin privilege

I have written a application which is hosting a WCF Service. 我写了一个托管WCF服务的应用程序。 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. (如果可能,仅更改配置。)此外,我还需要在Visual Studio中添加服务引用以编写客户端程序。 If possible, please keep the application can be added service references in Visual Studio 2010. 如果可能,请保留应用程序可以在Visual Studio 2010中添加服务引用。

If you want to keep it on an HTTP binding so a nonadmin can run it, you'll need to add permissions using the command 如果要将其保留在HTTP绑定上,以便非管理员可以运行它,则需要使用该命令添加权限

netsh http add urlacl (see help for the rest of the params)

This will allow the user you specify to carve off a chunk of the URL-space for the machine. 这将允许您指定的用户为该机器分割出一大块URL空间。 If you don't want to do this, you'll need to change to a different binding (netTcp, for instance) that doesn't require special privileges to listen. 如果您不想这样做,则需要更改为不需要特殊权限才能侦听的其他绑定(例如netTcp)。

This solution worked for me (using HTTP binding), open your service on this URL: 此解决方案适用于我(使用HTTP绑定),在此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. 必须承认我在google-ing之后在这个网站http://www.paraesthesia.com/archive/2010/06/11/developing-as-a-non-admin-testing-wcf-services.aspx/上找到了它一段时间......所以归功于那个人。

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. 基于对我的其他答案的评论,您将无法使用内置的HTTP绑定执行此操作 - 它们都基于HTTP.sys,这需要授予非管理员用户注册URL的权限。 If your deployment scenario allows, consider switching to netTcpBinding instead- no permission issues there. 如果您的部署方案允许,请考虑切换到netTcpBinding - 没有权限问题。 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. 否则,您使用内置绑定是SOL - 您需要构建一个不基于HTTP.sys的原始HTTP传输。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM