Reputation:
I want to log on to a server inside my program using Windows authentication of the current user logged in. I thought that perhaps I could use
System.Security.Principal.WindowsIdentity.GetCurrent().Name
but while that does give a name, I do not see how I can find out the password of the user to enter it.
Upvotes: 0
Views: 4670
Reputation: 52518
If both the client and the server are in the same domain, you don't have to specify the username and password.
If you are using HttpRequest, you should set the LogonUserIdentity.
If you are calling a SOAP service, you should set the Credentials property.
Upvotes: 0
Reputation: 23315
There's absolutely no way to get the Windows user's password since Windows doesn't even store it (all it stores is an irreversible hash).
Upvotes: 2
Reputation: 11162
If you are going to use the Windows User Authentication, you should probably use some part of it that is more secure than the simple username/password combination. (And there is probably no way to access the password, as that would mean that every .NET application could access your full account information.)
For instance, WindowsIdentity.User is stated to be unique for a user across all Windows NT implementations. (I believe this means that in any Windows NT implementation, this will be unique for each user on a given system... But I'm not sure.)
Upvotes: 0
Reputation: 1193
in web.config:
<system.web>
<authentication mode="Windows" />
<identity impersonate="true"/>
</system>
Upvotes: 1
Reputation: 48448
You won't be able to use their password to a basic login unless the user provides it to your application. You'll have to do some sort impersonation or delegate authority based on the locally logged in user.
Upvotes: 1
Reputation: 11436
You cannot get the password. You need to use Impersonation to pass on the identity to the server that you are trying to connect to.
Upvotes: 1