所以我一直在想这件事。我有一个自我托管的WCF服务:
var webServiceHost = new WebServiceHost(helloWorld);
webServiceHost.Authorization.ImpersonateCallerForAllOperations = true;
var uri = new Uri(BaseUri + webService.UriDirectory);
var webHttpBinding = new WebHttpBinding(webHttpSecurityMode);
webHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
var sep = webServiceHost.AddServiceEndpoint(IHelloWorld, webHttpBinding, uri);
var webHttpBehavior = new WebHttpBehavior {HelpEnabled = true};
sep.Behaviors.Add(webHttpBehavior);
webServiceHost.Open();我继续并将以下属性应用于我的方法:
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public List<GpoItem> GetAll()
{
using (ServiceSecurityContext.Current.WindowsIdentity.Impersonate())
{
// Execute GPO code here...
return new List<GpoItem>();
}
}为了添加更多的上下文,我基本上有一个web服务,允许一个人登录到一个网页,在域上创建一个GPO。在控制台中运行此操作很好,因为我是作为登录域用户运行它的。将其作为Windows服务运行,将引发“拒绝访问”异常。因此,需要模仿。我在上面输入了以下修改后的代码,得到了“发生了一个操作错误。( HRESULT: 0x80072020中的例外)”。谷歌显示这仍然是一个许可问题。我是作为管理员登录到Web服务测试环境中的,因此我可以完全访问,并且我已经向您展示了我可以作为管理员在控制台中运行它。我觉得我错过了一些设置在什么地方的旗帜。
有什么想法吗?
Update1我尝试将服务从本地系统切换到网络服务,但仍然遇到同样的问题。
Update2当我登录到承载WCF服务的服务器(作为本地系统运行)并直接在该机器上使用浏览器时,一切正常。授权用户身份验证似乎是个问题.这里还不知道。
发布于 2011-12-22 14:37:28
显然,人们只能从WCF属性中获得模拟级别的令牌,这些属性只能用于本地资源访问。相反,我必须使用LogonUser API,以便能够获得一个具有网络资源访问权限的委托级令牌。1
1
https://stackoverflow.com/questions/8593439
复制相似问题