Hi there...
I am querying a multi-valued UnicodeString in AD and only appear to be able to retrieve the first entry...
Can anyone spot why?
I am querying a multi-valued UnicodeString in AD and only appear to be able to retrieve the first entry...
Can anyone spot why?
Code:
Public Function ListMultiValues(ByVal RootOU, ByVal Filter, ByVal AttributesToLoad)
'This function will query for the value/s contained within the attribute of the
'parsed DistinguishedName and return the values as a collection of items.
Dim dEntry As New DirectoryEntry
Dim dSearch As New DirectorySearcher
Dim cEntries As SearchResultCollection
Dim oValue As SearchResult
Dim aAttributes() As String
Dim i As Integer
Try 'to connect to the parsed DN or throw an error
If Not dEntry.Exists(RootOU) Then Throw (New Exception(RootOU & DOES_NOT_EXIST))
Catch ex As Exception
'Return CType(ex.Message, SearchResultCollection)
Exit Function
End Try
dEntry.Path = RootOU
dSearch.SearchRoot = dEntry
'apply the filter if one is provided
If Not Filter Is Nothing Then
dSearch.Filter = "(&(objectclass=" & Filter & "))"
End If
dSearch.SearchScope = SearchScope.Subtree
dSearch.PropertiesToLoad.Add(AttributesToLoad)
cEntries = dSearch.FindAll
Return cEntries