views:

2285

answers:

7

I am looking for a way 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 in.

Anyone knows how to do this?

+1  A: 

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.

Vaibhav
+1  A: 

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.

Joseph Daigle
+1  A: 

in web.config:

  <system.web>
     <authentication mode="Windows" />
        <identity impersonate="true"/>
  </system>
lordscarlet
A: 

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.)

jdmichal
+2  A: 

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).

Robert C. Barth
A: 

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.

GvS
A: 

I am developing a Web page in JSP. Could I use this in my code? Where? I have a file .website-config file, which contains the following code :

Will it ( ) work if I add the above code in this?