Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.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 c#Active Directory登录_C#_Asp.net_Authentication - Fatal编程技术网

Asp.net c#Active Directory登录

Asp.net c#Active Directory登录,c#,asp.net,authentication,C#,Asp.net,Authentication,我有一个使用.net 4.0和Active DirectoryUserPrincipal登录的web应用程序 它几乎适用于所有人,除了这个用户。每当他尝试时,总是会出错: System.ArgumentOutOfRangeException:索引超出范围。必须为非负数且小于集合的大小。参数名称:索引 在System.Collections.ArrayList.get_项(Int32索引) 位于System.DirectoryServices.ResultPropertyValueCollecti

我有一个使用.net 4.0和Active Directory
UserPrincipal
登录的web应用程序

它几乎适用于所有人,除了这个用户。每当他尝试时,总是会出错:

System.ArgumentOutOfRangeException:索引超出范围。必须为非负数且小于集合的大小。参数名称:索引
在System.Collections.ArrayList.get_项(Int32索引)
位于System.DirectoryServices.ResultPropertyValueCollection.get\u项(Int32索引)

可能有什么问题?代码或他的帐户

请帮忙


谢谢大家!

能否提供完整的异常堆栈跟踪?这意味着您试图访问的返回用户帐户的属性不存在。例如,如果您试图访问他们的电子邮件地址或显示名称。您的一行代码读起来有点像失败了。请您提供打电话的位置的完整代码好吗?这是一段非常简单的代码:
Dim adPath As String=“my active directory path”尝试Dim entry As DirectoryEntry=New DirectoryEntry(adPath,myUserName,mypassword,AuthenticationTypes.Secure)Dim directorySearch As DirectorySearcher=New DirectorySearcher(entry)directorySearch.Filter=“(&(objectClass=user)(userPrincipalName=“&myUserName&”)Dim results As SearchResult=directorySearch.FindOne()如果没有,则结果为空,然后“找到结束,如果结束,请尝试”