为什么PrincipalContext.ValidateCredentials针对旧凭据进行验证? [英] Why is PrincipalContext.ValidateCredentials validating against old credentials?

查看:99
本文介绍了为什么PrincipalContext.ValidateCredentials针对旧凭据进行验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个WCF服务,可根据计算机上的本地Windows帐户验证用户的凭据,但是,无论何时创建新用户或更改密码,用户都无法登录,直到我重新启动整个计算机。

We have a WCF service that validates the user's credentials against the local windows accounts on the machine, however whenever a new user is created or a password is changed, users cannot login until I restart the entire machine.

我该怎么做才能告诉它对照当前用户设置检查凭据,而不使用旧的用户设置?

What can I do to tell it to check the credentials against the current user settings, and to not use old ones?

using (var pContext = new PrincipalContext(ContextType.Machine))
{ 
    if (pContext.ValidateCredentials(username, password))
    {
        using (var context = new LHREntities(Connections.GetConnectionString()))
        {
            // Do work
        }
    }
}

我正在使用.Net framework 4.0和Windows Server2003。如果我在计算机上运行Visual Studio中的所有内容,则一切正常,并且可以使用凭据已根据当前设置正确检查,但是一旦将其部署到生产计算机上的IIS,它就会出现

I am using .Net framework 4.0 and Windows Server 2003. If I run everything in Visual Studio on my machine, everything works fine and credentials are correctly checked against the current settings, however once I deploy this to IIS on our production machine, it appears to validate against cached credentials.

推荐答案

我不知道到底是什么问题,但是我确实找到了解决该问题的解决方案。

I do not know what the problem is exactly, but I did find the solution that fixes the issue.

同时运行WCF服务和Silverlight应用程序的AppPool使用 NETWORK SERVICE 作为登录名身份。我将其切换为管理登录名,现在它可以根据当前用户帐户正确验证登录名,新用户帐户和密码更改将立即生效。

The AppPool that was running both the WCF service and the Silverlight application was using NETWORK SERVICE as the login identity. I switched that to an administrative login, and it is now correctly validating the login against the current user accounts, and new users accounts and password changes take effect immediately.

如果有人可以解释为什么这是他们自己的答案,我很乐意接受。

If someone can explain why this is in their own answer, I'd be happy to accept it.

这篇关于为什么PrincipalContext.ValidateCredentials针对旧凭据进行验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆