Obtain Network Credentials from Current User in Windows Authentication Application

后端 未结 2 1305
终归单人心
终归单人心 2021-02-05 12:32

I was wondering whether it was possible to obtain the current user object and get their credentials so that I can pass them along to a NetworkCredential object whic

相关标签:
2条回答
  • 2021-02-05 13:28

    I don't fully understand your question, but is your call coming from ASP.NET that you require the credentials? You could attempt:

    Uri uri = new Uri("http://tempuri.org/");
    ICredentials credentials = CredentialCache.DefaultCredentials;
    NetworkCredential credential = credentials.GetCredential(uri, "Basic");
    

    Assuming your user has already authenticated via a Membership Provider.

    0 讨论(0)
  • 2021-02-05 13:31

    CredentialCache.DefaultNetworkCredentials?

    The credentials returned by DefaultNetworkCredentials represents the authentication credentials for the current security context in which the application is running. For a client-side application, these are usually the Windows credentials (user name, password, and domain) of the user running the application.

    0 讨论(0)
提交回复
热议问题