使用WCF和DefaultCredentials时如何处理密码更改?

时间:2022-04-30 03:45:10

I have a client that uses a WCF proxy to call a service. Credentials and other functionality work fine normally, but if the user changes their domain password and I restart the app, then I am unable to call the service due to this error:

我有一个使用WCF代理来调用服务的客户端。凭据和其他功能正常工作,但如果用户更改其域密码并重新启动应用程序,则由于此错误,我无法调用该服务:

System.ServiceModel.Security.SecurityNegotiaionException -> The server has rejected the client credentials.

System.ServiceModel.Security.SecurityNegotiaionException - >服务器已拒绝客户端凭据。

System.Security.Authentication.InvalidCredentialException -> The server has rejected the client credentials.

System.Security.Authentication.InvalidCredentialException - >服务器已拒绝客户端凭据。

System.componentmodel.Win32Exception -> The logon attempt failed.

System.componentmodel.Win32Exception - >登录尝试失败。

Obviously I know that the user's credentials have changed but how can I refresh the CredentialCache to reflect the new credentials so that the WCF call will succeed?

显然,我知道用户的凭据已更改,但如何刷新CredentialCache以反映新凭据,以便WCF调用成功?

1 个解决方案

#1


6  

The service checks the token in the client context against the AD. The wcf client uses the existing windows token it receives when the user logged into his windows account. If you change the password, the windows session still runs with the old credentials. You have to log in and out of your windows session in order to update the cached credentials.

该服务根据AD检查客户端上下文中的令牌。 wcf客户端使用当用户登录其Windows帐户时收到的现有Windows令牌。如果更改密码,则Windows会话仍使用旧凭据运行。您必须登录和退出Windows会话才能更新缓存的凭据。

#1


6  

The service checks the token in the client context against the AD. The wcf client uses the existing windows token it receives when the user logged into his windows account. If you change the password, the windows session still runs with the old credentials. You have to log in and out of your windows session in order to update the cached credentials.

该服务根据AD检查客户端上下文中的令牌。 wcf客户端使用当用户登录其Windows帐户时收到的现有Windows令牌。如果更改密码,则Windows会话仍使用旧凭据运行。您必须登录和退出Windows会话才能更新缓存的凭据。