简体   繁体   English

具有本地活动目录的.Net Core身份验证

[英].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. 我对.Net Core 1.0.1完全陌生,目前我对本地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. 我正在尝试将新的网页实现为Intranet应用程序,但是我不能使用Windows身份验证,因为需要从公司的每台计算机上登录此页面,而不更改登录的Windows用户。 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. 但是我无法弄清楚如何对公司内部的本地AD使用身份验证。 No Azure AD is available. 没有可用的Azure AD。 Novell.LDAP does not work with my dependencies. Novell.LDAP无法与我的依赖项一起使用。 Hopefully you can help me. 希望你能帮助我。 Thanks! 谢谢!

You can use PrincipalContext class by including System.DirectoryServices and System.DirectoryServices.AccountManagement libraries. 您可以通过包含System.DirectoryServicesSystem.DirectoryServices.AccountManagement库来使用PrincipalContext类。 Then call ValidateCredentials upon that context as follows: 然后在该上下文上调用ValidateCredentials ,如下所示:

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. PrincipalContext构造函数和ValidateCredentials方法具有许多重载。 And chosing which one to call them is merely up to your system. 选择哪个人只是您的系统。 Hence checking this document would help you along the way. 因此,检查此文档将对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM