简体   繁体   English

防火墙中的入站规则仅具有管理员权限

[英]Inbound rule in firewall only works with Admin privileges

I am trying to host a webserver with WPF on the local wifi network and expose a webservice that another device (in my case, an Android) can call while connected to the same wifi network. 我正在尝试在本地wifi网络上托管带有WPF的网络服务器,并公开一个网络服务,连接到同一wifi网络时,另一台设备(在我的情况下为Android)可以调用该服务。 I have created an inbound rule on the firewall for the port I am using. 我在防火墙上为正在使用的端口创建了入站规则。 The webservice call only goes through when the windows app is launched using "Run as Administrator" Is there a way I can do the same without Admin privileges? 仅当使用“以管理员身份运行”启动Windows应用程序时,webservice调用才能通过。是否可以在没有管理员特权的情况下执行相同的操作? Here is my code - 这是我的代码-

public class SelfHost
{
    WebServiceHost Host;
    public void HostServer()
    {
        var hostIPadd = Util.GetLocalHostIP(); //This returns something like "http://192.168.1.2" 
        Values.SERVER_PORT_VALUE = "55000";

        var uri = new Uri(hostIPadd + ":" + Values.SERVER_PORT_VALUE);

        Host = new WebServiceHost(new Service{...}, uri);

        //Start host
        ServiceEndpoint ep = Host.AddServiceEndpoint(typeof(IService), new WebHttpBinding(), "");
        Host.Open();
    }
}


public partial class MyWindow : Window
{

    public MyWindow()
    {
        InitializeComponent();
        StartHost();
    }

     private void StartHost()
    {
        var host = new SelfHost();

        var thServer = new System.Threading.Thread(host.HostServer);
        thServer.IsBackground = true;
        thServer.Start();
    }
}

I have created an inbound rule in the firewall with these properties 我已经使用这些属性在防火墙中创建了入站规则
Protocol type - TCP 协议类型-TCP
Local port - Specific Ports - 55000 本地端口-特定端口-55000
Profiles - Public 个人资料-公开
Action - "Allow the connection" 行动-“允许连接”
Programs - "All programs that meet the specified conditions" 程序-“符合指定条件的所有程序”

I don't quite know why the firewall ignores this exception if the app is not running in Admin. 我不太清楚如果应用程序未在Admin中运行,为什么防火墙会忽略此异常。 The WebServiceHost object runs fine even if it is not in Admin mode, no errors. 即使WebServiceHost对象不在Admin模式下,它也可以正常运行,没有错误。 But the webservice call never reaches the server and the request times out. 但是,Web服务调用永远不会到达服务器,并且请求超时。

nothing to do with the firewall, you can't open an http link in a wpf app - for security reasons 与防火墙无关,出于安全原因,您无法在wpf应用中打开http链接

see that 看到

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

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