开发者

Changing client credentials after WCF channel creation

开发者 https://www.devze.com 2023-01-26 02:03 出处:网络
The system we\'ve built allow开发者_如何学Gos for a user to change their password after a WCF channel has been created - is there a way to change the credentials being sent through to the server witho

The system we've built allow开发者_如何学Gos for a user to change their password after a WCF channel has been created - is there a way to change the credentials being sent through to the server without having to recreate the channel?

Thank you in advance.


If the channel has already been used, then the credentials are made read only and cannot be changed (an exception is thrown if the credentials are modified).

If the channel has not been used (and the state of the associated channel factory is Created or Opening) then you can update the credentials in the following way:

public void UpdateCredentials<T>(ClientBase<T> client, string username, string password)
{
  client.ClientCredentials.UserName.UserName = username;
  client.ClientCredentials.UserName.Password = password;
}

However, from your question, I would guess that the channel has already been used. In which case you must re-create the channel I'm afraid.

0

精彩评论

暂无评论...
验证码 换一张
取 消