Windows Authentication in .NET application on domain
I'm looking to create a fairly straight forward application that runs on every machine in a domain, when the user logs into the machine with their user/password it automatically logs them in over client/server a开发者_如何转开发nd authenticates them with this server.
So really my question is what's the approach (is there a name for this specifically?) to doing this? I'm not exactly sure how Windows Authentication works in this instance, but I can imagine it sending a user and password hash to my little server and verifying it there.
Googling around I can mostly seem to only find doing it with ASP.NET applications and user authentication, but I'm looking to do this with an actual program running within Windows.
I haven't started on the application yet, and just want to make sure everything is covered as much as possible before development starts. Essentially it's an instant messaging application that authenticates automatically when you login to the machine.
I think you are looking for CredentialCache.DefaultCredentials http://msdn.microsoft.com/en-us/library/system.net.credentialcache.defaultcredentials.aspx
When you pass the credentials to this "server" you can use these. Of course you realize you have left this very open ended. You didnt tell us anything about this client/server application and what it uses to authenticate now.
UPDATE: Some code that will get the current user info.
WindowsIdentity identity = WindowsIdentity.GetCurrent();
textBox1.Text = identity.Name;
精彩评论