[英]Validate AD User Credential from External PC via Web Application
Is there a way to validate the user credential that the user key in from two textbox (username, password) against the Active Directory User Lisst of the network of the web server? 有没有一种方法可以针对Web服务器网络的Active Directory用户权限,从两个文本框(用户名,密码)验证用户凭据的用户凭据?
For example I have a user account, User1 and the password is U1. 例如,我有一个用户帐户User1,密码为U1。 The User1 is included in the domain for example DomainServer so it would be DomainServer\\User1.
User1包含在域中,例如DomainServer,因此它将是DomainServer \\ User1。
Now I need to create a web application that will allow me to login using my user credential. 现在,我需要创建一个Web应用程序,该应用程序将允许我使用用户凭据进行登录。 I need to validate if the username I key in exist in the network of the web server and if the password is correct.
我需要验证输入的用户名是否存在于Web服务器的网络中以及密码是否正确。 Assuming that i accesses that web application via External Machine (machine not included in the web server network) for example a machine from Internet Cafe.
假设我通过外部计算机(Web服务器网络中未包含的计算机)(例如,来自Internet Cafe的计算机)访问该Web应用程序。 Lets assume that the web application was hosted and the URL is www.company.com\\ValidateCrendential
假设托管了Web应用程序,URL为www.company.com \\ ValidateCrendential
Thanks in advance guys! 在此先感谢大家!
If you web server is in domain then you can use LDAP to validate the user credentials. 如果您的Web服务器在域中,则可以使用LDAP验证用户凭据。
public bool Authenticate(string userName,string password, string domain)
{
bool authentic = false;
try
{
DirectoryEntry entry = new DirectoryEntry("LDAP://" + domain,userName, password);
object nativeObject = entry.NativeObject;
authentic = true;
}
catch (DirectoryServicesCOMException) { }
return authentic;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.