I've created a Windows Service (server) and a WPF (client) that uses WCFs wsdualhttpbinding callback functionality. Everything between the two pieces of software works correctly but the problem I'm having is that the client needs to run elevated to administrator privileges to work (which is understandable because it has to open ports in order to communicate with the server)
Is there any way to configure the client to work without elevation? Or perhaps create a one-time permanent connection so that the client doesn't need to be elevated at all times?
I'm running out of ideas and google search terms..
UPDATE
I've found a solution. Please correct me if there is another best practice I could follow!
I've added an 'Enable' and 'Disable' buttons to the client application that runs netsh to open (or close) and reserve a port.
Enable
Process process = new Process();
process.StartInfo = new ProcessStartInfo("netsh", @"http add urlacl url=http://+:" + PortNumber + @"/ user=DOMAIN\username");
process.StartInfo.Verb = "runas";
process.Start();
process.WaitForExit();
Disable
Process process = new Process();
process.StartInfo = new ProcessStartInfo("netsh", "http delete urlacl url=http://+:" + PortNumber + "/");
process.StartInfo.Verb = "runas";
process.Start();
process.WaitForExit();
I've found a solution. Please correct me if there is another best practice I could follow!
I've added an 'Enable' and 'Disable' buttons to the client application that runs netsh to open (or close) and reserve a port.
Enable
Process process = new Process();
process.StartInfo = new ProcessStartInfo("netsh", @"http add urlacl url=http://+:" + PortNumber + @"/ user=DOMAIN\username");
process.StartInfo.Verb = "runas";
process.Start();
process.WaitForExit();
Disable
Process process = new Process();
process.StartInfo = new ProcessStartInfo("netsh", "http delete urlacl url=http://+:" + PortNumber + "/");
process.StartInfo.Verb = "runas";
process.Start();
process.WaitForExit();