WCF中添加使用Netsh港口因为没有管理员权限域管理员 [英] Add ports with netsh in WCF as domain admin without admin privileges
问题描述
我有一个WPF应用程序(自行管理)与WCF服务和我有典型的错误您的进程不具有访问权限这个命名空间。
上的用户不具有管理员权限,以便使用是名为.manifest不是一个解决方案。
的端口是动态的,应用计算自由港每次运行,因此应用程序必须插入以netsh多次监听端口
我使用的ProcessStartInfo域管理员,但启动过程用户需要管理员权限。
运行应用程序,以管理员身份既不是一个解决方案,所以我需要一个正常的用户可以运行应用程序,该程序以netsh以域管理员添加端口。
I have a service with WCF in a WPF application (self-hosted) and I have the typical error "Your process does not have access rights to this namespace". The users can’t have admin privileges so using a .manifest is not a solution. The ports are dynamic, the application calculate a free port every time is running, so the application must insert the listen port by netsh several times I use a ProcessStartInfo with domain administrator, but to start the process the user needs admin privileges. Run the application as administrator neither is a solution, so I need that a normal user can run the application and the program add the port by netsh as domain administrator.
我的过程是这样的:
ProcessStartInfo psi = new ProcessStartInfo("netsh", parameter);
SecureString ss = new SecureString();
for (int i = 0; i < adminPass.Length; i++)
ss.AppendChar(adminPass[i]);
psi.Password = ss;
psi.UserName = Admin;
psi.Domain = Domain;
psi.Verb = "runas";
psi.RedirectStandardOutput = false;
psi.CreateNoWindow = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
Process.Start(psi);
非常感谢
Thanks a lot
推荐答案
看看这个堆栈溢出的问题,一个可能的解决您的问题。在答案中概述的方法是出来打出来的管理,需要的代码放到一个Windows服务这下调用时,适当的(分开)账户进行了提升权限的操作。
Take a look at the accepted answer for this Stack Overflow question for a possible solution to your problem. The approach outlined in the answer is to break out the admin-requiring code out into a Windows service which performs the elevated privilege operations under an appropriate (separate) account when invoked.
这篇关于WCF中添加使用Netsh港口因为没有管理员权限域管理员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!