Reputation: 334
I want to get network domain credentials of the user by my code.
string user = Environment.UserName;
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
I can get NAME with above samples, but I need password too. Is It possible to get password?
My purpose: I want to use the user's domain login credentials in my code, so the user do not have to login again to my windows app..., but i have to use login credentials for SoapHeader authentication...
Regards...
Upvotes: 0
Views: 1346
Reputation: 1911
See this thread.
That's, what you have already:
You can get the current identity of the user under which the current thread is running (not necessarily the logged in user) using WindowsIdentity.GetCurrent(). Alternatively you can get the logged in user name via the Environment.UserName property. It is not guaranteed to be the user running the current process however.
Is it possible to retrieve the password? No, the password isn't stored in Windows:
There is no Windows API to get a user's password as passwords aren't stored in Windows. Instead Windows stores a one-way hashed version.
Hope it helps!
EDIT: Documentation: Here are the associated docs to GetCurrent() and the returning value WindowsIdentity.
Upvotes: 1