Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kerberos authentication in windows service

Tags:

c#

kerberos

I am new on kerberos authentication and don't know anything about it. I have the server name, username and password ready for it.

I need to authenticate users from stand alone windows application. Can somebody please help?

I did not find much help on googling.

Appreciate any thought.

like image 977
Paresh Varde Avatar asked Nov 18 '15 13:11

Paresh Varde


People also ask

How do I enable Kerberos authentication in Windows?

Click the Start button, right-click Computer, and then click Properties. Click Advanced System Settings. In the System Properties dialog box, click the Advanced tab and then click Environment Variables. In the Environment Variables dialog box, check if the KRB5CCNAME variable appears in the System variables list.

Does Windows authentication use Kerberos?

Kerberos support is built in to all major computer operating systems, including Microsoft Windows, Apple macOS, FreeBSD and Linux. Since Windows 2000, Microsoft has used the Kerberos protocol as the default authentication method in Windows, and it is an integral part of the Windows Active Directory (AD) service.

How does Kerberos work in Windows?

The Kerberos protocol defines how clients interact with a network authentication service. Clients obtain tickets from the Kerberos Key Distribution Center (KDC), and they present these tickets to servers when connections are established. Kerberos tickets represent the client's network credentials.

How does Kerberos provide authentication service?

Kerberos is a computer network security protocol that authenticates service requests between two or more trusted hosts across an untrusted network, like the internet. It uses secret-key cryptography and a trusted third party for authenticating client-server applications and verifying users' identities.


1 Answers

In Kerberos you authenticate not with pair username/password, but by attaching Kerberos token, which you can grab from CredentialsCache.

WebRequest WReq = WebRequest.Create (MyURI);
WReq.Credentials = CredentialCache.DefaultCredentials;

see: https://msdn.microsoft.com/en-us/library/yk7437c8%28v=vs.110%29.aspx

The second line will give you NTLM or Kerberos credentials. You'll get Kerberos credentials when:

  • your application is started by a domain user account
  • SPN or UPN for the server in present in Kerberos KeyDistributionCentre
  • Server is configured to receive Kerberos tokens, at least: you must provide it a password.

When you execute 'CredentialCache.DefaultCredentials', your application uses underlying mechanisms to generate SPNEGO token for you. Inside it, will be Keberos or NTLM ticket. Here's how it works:

  • description of environment: https://msdn.microsoft.com/en-us/library/aa480562.aspx
  • what goes on a client computer (SSPI implementation is used to generate tickets) https://msdn.microsoft.com/en-us/library/aa480609.aspx
like image 66
greenmarker Avatar answered Sep 18 '22 23:09

greenmarker