Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NET-由于NativeObject绑定,对Active Directory的身份验证失败_Asp.net_Web Applications_Webforms_Active Directory_Credentials - Fatal编程技术网

ASP.NET-由于NativeObject绑定,对Active Directory的身份验证失败

ASP.NET-由于NativeObject绑定,对Active Directory的身份验证失败,asp.net,web-applications,webforms,active-directory,credentials,Asp.net,Web Applications,Webforms,Active Directory,Credentials,我正在从事一个学术项目,我们必须对来自web应用程序的Active Directory域服务帐户进行身份验证。 我遵循了此msdn,并按照指定更改了Login\u Click()函数中的ldap路径。 一切都很顺利,但当我尝试登录web应用程序时,我发现: 验证错误。验证用户身份时出错。登录失败: 未知的用户名或错误的密码。。。在 System.DirectoryServices.DirectoryEntry.get_NativeObject() 以下是错误屏幕截图: 关于信息,我这样填写了a

我正在从事一个学术项目,我们必须对来自web应用程序的Active Directory域服务帐户进行身份验证。 我遵循了此msdn,并按照指定更改了
Login\u Click()
函数中的ldap路径。 一切都很顺利,但当我尝试登录web应用程序时,我发现:

验证错误。验证用户身份时出错。登录失败: 未知的用户名或错误的密码。。。在 System.DirectoryServices.DirectoryEntry.get_NativeObject()

以下是错误屏幕截图:

关于信息,我这样填写了
adPath
(在
Login\u Click()
方法中):

我们也尝试过:

string adPath = "LDAP://DC.datacenter.mex.am.company.net/DC=datacenter,DC=mex,DC=am,DC=company,DC=net/"
我们尝试登录时使用的凭据是完全有效的,因为我们测试了它们访问Active Directory帐户的权限。。。但是相同的凭据在asp.net web应用程序中不起作用

我在网上到处搜索,但什么也没找到


有人知道吗???

您可以通过PrincipalContext进行身份验证

using (var context = new PrincipalContext(ContextType.Domain,
                    yourdomain,
                    UsernameforAD,
                    ADUserPassword)
                {
                    bool isAuthenticated= context.ValidateCredentials(username,password);
                }

谢谢你的回答!!不幸的是,它仍然不起作用。。。现在我遇到了这个错误:无法联系服务器。。。在System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType ContextType、字符串名称、字符串用户名、字符串密码)中,您是否正确地给出了参数?Usernameford和ASUserPassword参数不是当前用户的凭据,它们是ActiveDirectory用户的凭据。是的,我想我这样做了。但是你能告诉我广告用户的凭据是什么样子的吗?它不是特殊格式的,它是普通的用户名和密码,例如“user3444”“123456”,那么它肯定不起作用。。。我尝试了Active Directory的几个有效凭据,但什么都没有。。。ActiveDirectoryMembershipProvider是否可以作为解决方案??我看过一个教程,但它是针对.NET2.0的,所以我不知道它是否仍然可用。。。
using (var context = new PrincipalContext(ContextType.Domain,
                    yourdomain,
                    UsernameforAD,
                    ADUserPassword)
                {
                    bool isAuthenticated= context.ValidateCredentials(username,password);
                }