System.DirectoryServices COM Exception 0x80072020

G

Guest

All,

I've built an Employee Directory with ASP.NET app that queries Active
Directory for users and builds links with the results. What I'm seeing is
really intermittent failures to bind to the directory. I'll log into the app
twice with the same account and sometimes it works, while with others I get
the following:

System.Runtime.InteropServices.COMException (0x80072020): An operations
error occurred at System.DirectoryServices.DirectoryEntry.Bind(Boolean
throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at
System.DirectoryServices.DirectoryEntry.get_AdsObject() at
System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne)
at System.DirectoryServices.DirectorySearcher.FindAll() at
DirSearch.test.TestLogin() in C:\Inetpub\wwwroot\DirSearch\test.aspx.vb:line
55


Included below is a procedure I launch on Page.Load to try and isolate the
issue:

Sub TestLogin()
Dim strLDAPConn As String
Dim UserName As String
UserName = txtUserName.Text
strLDAPConn = "LDAP://DC=EDOCORP,DC=COM"
Dim DirEntry As New DirectoryEntry(strLDAPConn)
Dim DirSearch As New DirectorySearcher(DirEntry)
Dim SrchResColl As SearchResultCollection
Dim SrchRes As SearchResult
Dim deSrchRes As DirectoryEntry
DirSearch.Filter = "(&(objectClass=user)(samaccountname=*" &
UserName & "*)(objectCategory=Person))"
DirSearch.Sort.PropertyName = "SN"
DirSearch.Sort.Direction = SortDirection.Ascending

Try
SrchResColl = DirSearch.FindAll()
Catch ex As Exception
lblError.Text = ex.ToString
End Try

End Sub

I'm really confused as to why this is happening. what's more, I'll use the
same account, it'll work for a while (a few sessions), stop working, and then
subsequent sessions stop working. Am I missing a layer here? Any advice or
direction would be greatly appreciated.

Regards,

Chris Frohlich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top