I am using this example http://support.microsoft.com/kb/326340
After having to tweak some things I got it to work....I think.
The GetGroups function is causing an exception. Here is the code:
Public Function GetGroups() As StringDim search As DirectorySearcher = New DirectorySearcher(_path)
search.Filter =
"(cn=" & _filterAttribute & ")"search.PropertiesToLoad.Add("memberOf")
Dim groupNames As StringBuilder = New StringBuilder()
TryDim result As SearchResult = search.FindOne() **************THIS IS WHERE THE ERROR OCCURS
Dim propertyCount As Integer = result.Properties("memberOf").Count
Dim dn As StringDim equalsIndex, commaIndex
Dim propertyCounter As IntegerFor propertyCounter = 0 To propertyCount - 1
dn =
CType(result.Properties("memberOf")(propertyCounter), String)equalsIndex = dn.IndexOf("=", 1)
commaIndex = dn.IndexOf(
",", 1)
If (equalsIndex = -1) Then
Return Nothing
End If
groupNames.Append(dn.Substring((equalsIndex + 1), (commaIndex - equalsIndex) - 1))
groupNames.Append("|")
NextCatch ex As Exception
Throw New Exception("Error obtaining group names. " & ex.Message)
End TryReturn groupNames.ToString()
End Function
In this line Dim search As DirectorySearcher = New DirectorySearcher(_path) the path is formed like this LDAP://CN=Barton\,Tyler,OU=MedicBuilding,DC=Medics,DC=LCL
Notice the "\"after the last name. Is this suppose to be there? I cannot help but think that this is the reason for the error.
Help would be apperciated.
Thanks,
Ty