Carsten
Carsten

Reputation: 11

.Net Core Authentication with local active directory

I'm completly new to .Net Core 1.0.1 and currently I'm freaking out about the authentication process with a local AD. I'm trying to implement a new webpage as an intranet application but I can't use windows authentication, because there is a requirement to login on this page from every computer in the company without changing the logged on windows user. So I've implemented a login field with username and password. But I can't figure out how I can use authentication to a local AD inside my company. No Azure AD is available. Novell.LDAP does not work with my dependencies. Hopefully you can help me. Thanks!

Upvotes: 0

Views: 2288

Answers (1)

Tolga Evcimen
Tolga Evcimen

Reputation: 7352

You can use PrincipalContext class by including System.DirectoryServices and System.DirectoryServices.AccountManagement libraries. Then call ValidateCredentials upon that context as follows:

var context = new PrincipalContext(ContextType.Domain, dc.HostName, dc.UserName, dc.Password);

bool authenticated = context.ValidateCredentials(username, password);

The PrincipalContext constructor and ValidateCredentials method have many overloads. And chosing which one to call them is merely up to your system. Hence checking this document would help you along the way.

Upvotes: 1

Related Questions