Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtain Network Credentials from Current User in Windows Authentication Application

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 which I am using to connect to my AX .NET Business Connector. As, at the moment I'm having to specify it connect as a specific user which I set when I instantiate a NetworkCredential object:

private NetworkCredential nc = new NetworkCredential("myUser", "myPassword", "myDomain");

I was hoping to do something like: private NetworkCredential nc = (NetworkCredential)HttpContext.User; but obviously that won't work...

That way, it's easier to keep track of which user has created a sales order for example, as at the moment everything gets created by the user I have specified..

like image 288
CallumVass Avatar asked Jul 10 '12 13:07

CallumVass


People also ask

How do I find my network sharing credentials?

Go to Control Panel > User accounts. From there, navigate to Credential Manager > Windows Credentials. You will see a field Add Windows Credentials, tap on it. In this menu, you can add the computer's name you want to access, username and password.

What is user credentials for network authentication?

When a domain account is used, network authentication occurs transparently and in the background via Kerberos or TLS/SSL. Users who use a local computer account must give user credentials such as a username and password while trying to gain access to a network resource.

What is the correct method to pass authentication credentials from client?

A client that wants to authenticate itself with the server can then do so by including an Authorization request header with the credentials. Usually a client will present a password prompt to the user and will then issue the request including the correct Authorization header.


2 Answers

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.

like image 119
Damien_The_Unbeliever Avatar answered Sep 25 '22 12:09

Damien_The_Unbeliever


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.

like image 25
Jaime Torres Avatar answered Sep 24 '22 12:09

Jaime Torres