Blue Prism Product

last person joined: an hour ago 

Chat about Blue Prism products

Using For Each to assign collection to collection data item

  • 1.  Using For Each to assign collection to collection data item

    Posted 07-09-2020 08:04

    Working in Blue Prisms environment and currently building out an LDAP VBO utility. I have the below code, it will return the list of users in an AD Group i.e. samAccountName, givenname & surname.

    My namespace imports used are:

    System.Drawing, System.Data

    My issue is with trying to loop through the resultset and store each row of data returned in my final collection data item, colResults.

    I know I'm working with a collection and I'm aware that what I'm doing in my For Each loop is not correct, i.e. compile error:

    "String cannot be converted to System.Data.Datatable"

    But I'm unable to resolve.

    I've attempted to rewrite and use an index but syntactically I can't use .Count with my Properties.SearchResultCollection.

    Dim de As New DirectoryServices.DirectoryEntry("LDAP://" + Path)
    Dim ds As New DirectoryServices.DirectorySearcher(de)
    Dim srCol As DirectoryServices.SearchResultCollection
    Dim sr As DirectoryServices.SearchResult
    'Try and assume success
    Success = True
        ds.Filter = "(&(objectCategory=user)(memberOf=" + GroupDN + "))"
        srCol = ds.FindAll()
        For Each sr In srCol
            If Not sr.GetDirectoryEntry.Properties("name").Value Is Nothing Then
                colResults = (sr.GetDirectoryEntry.Properties("givenname").Value.ToString())
                colResults = (sr.GetDirectoryEntry.Properties("sn").Value.ToString())
                colResults = (sr.GetDirectoryEntry.Properties("samAccountName").Value.ToString)
            End If
    Catch e As System.Exception
        Success = False
    End Try
    Disclaimer: This content was auto-posted from Stackoverflow. The original Stackoverflow question is here Stackoverflow Post, posted by GpioNelson.