WCF 自托管服务、安装程序类和 netsh
我有一个自托管的 WCF 服务应用程序,我想通过 msi 安装程序包进行部署。端点使用 http 端口 8888。为了在安装后在 Windows 2008 下启动项目,我必须以管理员身份运行该程序,或者必须使用 netsh 编辑 http 设置:
"netsh http add urlacl url=http://+:8888/ user=\Everyone"
我想从我的安装程序类编辑 http 设置。因此,我从 Install() 方法中调用以下方法:
public void ModifyHttpSettings()
{
string parameter = @"http add urlacl url=http://+:8888/ user=\Everyone";
System.Diagnostics.ProcessStartInfo psi =
new System.Diagnostics.ProcessStartInfo("netsh", parameter);
psi.Verb = "runas";
psi.RedirectStandardOutput = false;
psi.CreateNoWindow = true;
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
System.Diagnostics.Process.Start(psi);
}
此方法适用于英文版本的 Windows,但不适用于本地化版本(每个人组在本地化版本中具有不同的名称)。我还尝试使用 Environment.UserName 至少允许当前登录用户进行访问。但这也不起作用,因为安装程序类是由在用户 SYSTEM 下运行的 msi 服务运行的。因此 Enviroment.UserName 返回 SYSTEM 这不是我想要的。
有没有办法从 msi 安装程序类向所有(或至少当前登录的)用户授予对我的自托管 WCF 服务的访问权限?
I have a selfhosted WCF service application which I want to deploy by a msi installer package. The endpoint uses http port 8888. In order to startup the project under windows 2008 after installation I have to either run the program as administrator or have to edit the http settings with netsh:
"netsh http add urlacl url=http://+:8888/ user=\Everyone"
I want to edit the http settings from my installer class. Therefore I call the following method from the Install() method:
public void ModifyHttpSettings()
{
string parameter = @"http add urlacl url=http://+:8888/ user=\Everyone";
System.Diagnostics.ProcessStartInfo psi =
new System.Diagnostics.ProcessStartInfo("netsh", parameter);
psi.Verb = "runas";
psi.RedirectStandardOutput = false;
psi.CreateNoWindow = true;
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
System.Diagnostics.Process.Start(psi);
}
This method will work for english versions of windows, but not for localized versions (The group Everyone has different names in localized versions). I have also tried to use Environment.UserName to allow access at least for the current logged on user. But this does also not work, because the installer class is run by the msi service which runs under the user SYSTEM. Hence Enviroment.UserName returns SYSTEM and that is not what I want.
Is there a way to grant access to all (or at least for the current logged on) user to my selfhosted WCF service from a msi installer class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的解决方案:
SID“S-1-1-0”是众所周知的SID,代表“Everyone”帐户。 SID 对于所有 Windows 本地化版本都是相同的。 SecurityIdentifier 类的 Translate 方法返回Everyone 帐户的本地化名称。
My aproach to a solution:
The SID "S-1-1-0" is a wellknown SID and stands for the "Everyone" account. The SID is the same for all localizations of windows. The method Translate of SecurityIdentifier class returns the localized name of the Everyone account.