gpt4 book ai didi

asp.net - 模拟WCF

转载 作者:行者123 更新时间:2023-12-01 18:44:12 25 4
gpt4 key购买 nike

我有一个托管在 IIS 中的 WCF 服务,我需要它来模拟 annon 帐户。

在我的 Webconfig 中

<authentication mode="Windows"/>
<identity impersonate ="true"/>

使用vs2008测试以下内容

        public void ByRuleId(int ruleId)
{
try
{
string user = WindowsIdentity.GetCurrent().Name;
string name = Thread.CurrentPrincipal.Identity.Name;
........

//get the data as a string.
using (FileStream fs = File.Open(location, FileMode.Open))
using (StreamReader reader = new StreamReader(fs))
{
rawData = reader.ReadToEnd();
}

}
catch.....
}

这有效。但是如果我添加模拟属性

  [OperationBehavior(Impersonation=ImpersonationOption.Required)]
public void ByRuleId(int ruleId)

这不适用于错误消息

“未提供所需的模拟级别,或者提供的模拟级别无效。”

稍微研究了一下,我注意到第一种方式是通过 Kerboros 进行身份验证的,而第二种方式在身份验证类型上失败了

我正在使用 WCF 客户端工具来传递我的凭据。这似乎有效。

最佳答案

检查当前线程身份的'TokenImpersonationLevel';您需要它至少是“模拟”才能在运行该服务的计算机上执行操作。

通常,如果您使用代理客户端,则需要设置客户端的“TokenImpersonationLevel”:

http://www.devx.com/codemag/Article/33342/1763/page/4

关于asp.net - 模拟WCF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1432568/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com