Exemplo n.º 1
0
        public static NetShResult AddUrlAcl(string url, string user)
        {
            var arguments = GetAddParameters(url, user);

            try
            {
                string output;

                if (UacHelper.RunElevated(NetshCommand, arguments, out output))
                {
                    return(new NetShResult(NetShResultCode.Success, output, arguments));
                }


                if (FailedBecauseUrlReservationAlreadyExists(output))
                {
                    return(new NetShResult(NetShResultCode.UrlReservationAlreadyExists, output, arguments));
                }

                return(new NetShResult(NetShResultCode.Error, output, arguments));
            }
            catch (Exception ex)
            {
                return(new NetShResult(NetShResultCode.Error, ex.Message, arguments));
            };
        }
Exemplo n.º 2
0
        public static NetShResult DeleteUrlAcl(string url)
        {
            var arguments = GetDeleteParameters(url);

            try
            {
                string output;

                if (UacHelper.RunElevated(NetshCommand, arguments, out output))
                {
                    return(new NetShResult(NetShResultCode.Success, output, arguments));
                }

                if (FailedBecauseUrlReservationDidNotExist(output))
                {
                    return(new NetShResult(NetShResultCode.UrlReservationDoesNotExist, output, arguments));
                }


                return(new NetShResult(NetShResultCode.Error, output, arguments));
            }
            catch (Exception ex)
            {
                return(new NetShResult(NetShResultCode.Error, ex.Message, arguments));
            }
        }
Exemplo n.º 3
0
        public static NetShResult OpenFirewallPorts(string portList, string username, string firewallRuleName)
        {
            var arguments = GetFirewallParameters(portList, firewallRuleName);

            try
            {
                if (UacHelper.RunElevated(NetshCommand, arguments, out string output))
                {
                    return(new NetShResult(NetShResultCode.Success, output, arguments));
                }

                return(new NetShResult(NetShResultCode.Error, output, arguments));
            }
            catch (Exception ex)
            {
                return(new NetShResult(NetShResultCode.Error, ex.Message, arguments));
            };
        }