Windows操作系统 - 如何修改本地凭据缓存。 [英] Windows OS - how to modify the local credential cache.

查看:629
本文介绍了Windows操作系统 - 如何修改本地凭据缓存。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

修改本地缓存凭据的标准/推荐方法是什么?与此交易相关的所有流程是什么?


请分享此示例代码。


谢谢,


Rahul




  

解决方案




您可以简单地使用.NET框架的CredentialCache类来管理缓存凭据。



基本方法是添加和删除,您可能已经猜到了 - 添加和删除NetworkCredential 来自缓存的实例。下面是C#中的基本代码示例,使用不同语言的相同代码示例也可以在
MSDN中找到:

 CredentialCache myCache = new CredentialCache( ); 

myCache.Add(new Uri(" http://www.contoso.com/")," Basic",new NetworkCredential(UserName,SecurelyStoredPassword));
myCache.Add(new Uri(" http://www.contoso.com/")," Digest",new NetworkCredential(UserName,SecurelyStoredPassword,Domain));

wReq.Credentials = myCache;

https://msdn.microsoft.com/en-us/library/system.net.credentialcache%28v=vs.110 %29.aspx?f = 255& MSPPError = -2147217396


您感兴趣的属性是DefaultCredentials。 DefaultCredentials根据当前安全上下文检索应用程序的系统凭据。如果当前安全上下文是客户端应用程序,则用户名,
密码和当前登录用户的域将成为DefaultCredentials属性的一部分。









What is the standard/recommended way to modify the local cache credential ? what all process associated with this transaction?

Please share the sample code for this.

Thanks,

Rahul

  

解决方案


You can simply use the CredentialCache Class of the .NET framework to manage your cache credential.

The fundamental methods are Add and Remove, which you might have guessed - adds and removes the NetworkCredential  instances from the cache. Below is a basic code example in C# and the same code example using a different language can also be found in MSDN:

CredentialCache myCache = new CredentialCache();

myCache.Add(new Uri("http://www.contoso.com/"),"Basic",new NetworkCredential(UserName,SecurelyStoredPassword));
myCache.Add(new Uri("http://www.contoso.com/"),"Digest", new NetworkCredential(UserName,SecurelyStoredPassword,Domain));

wReq.Credentials = myCache;

https://msdn.microsoft.com/en-us/library/system.net.credentialcache%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

The property that you would be interested in is DefaultCredentials. DefaultCredentials retrieves the system credentials of the application depending on the current security context. If the current security context is a client application, the user name, password, and domain of the user who is currently logged in will be part of the DefaultCredentials property.




这篇关于Windows操作系统 - 如何修改本地凭据缓存。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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