Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 25, 2011 04:21 PM by jordanbmail
Aug 23, 2011 10:19 PM|LINK
I have recently learned how to retreive information from AD with VB in an ASP.NET application so that i can do some group comparison and i am receiving the
System.OutOfMemoryException in the below code. I have spent 3 days or so looking for solutions and everything i have tried doesn’t seem to work. My
machine is not out of actual memory so i am at a loss. Can someone point me in the right direction please? Thank you in advance for your assistance.
Dim Domain As New DirectoryEntry("GC://dc=XXX,dc=XXX,dc=XXX")
Dim DSearcher As New DirectorySearcher(Domain)
Dim pSearcher As New DirectorySearcher(Domain)
pSearcher.Filter = ("(mail=" & txtUser.Text & "@domain.com)")
Dim pResults As SearchResult
pResults = pSearcher.FindOne()
Dim propcount = pResults.Properties("memberOf").Count
Dim dn As String
Dim equalsIndex As Integer
Dim commaIndex As Integer
Dim propcounter As Integer = 0
Dim groupnames As New StringBuilder
While propcounter < propcount
dn = pResults.Properties("memberOf")(propcounter)
equalsIndex = dn.IndexOf("=", 1)
commaIndex = dn.IndexOf(",", 1)
If equalsIndex = -1 Then
groupnames.Append((dn.Substring((equalsIndex + 1).ToString, (commaIndex - equalsIndex) - 1)))
Catch ex As Exception
MsgBox("Error Obtaining Group Names. " & ex.Message)
Label1.Text = groupnames.ToString
Aug 25, 2011 03:35 AM|LINK
As your are using while to go through the search result , but I cannot find a increasing of propcounter, it may cause the group names increases till it exhaust all memory.
I hope this can be helpful for you.
Aug 25, 2011 04:21 PM|LINK
Nice! Thanks! That fixed it. Just needed a fresh pair of eyes. Thanks again!!!!!!