How to determine if searchresult is person or group RRS feed

  • Question

  • User2085410294 posted


    i am querying the AD for all members of a group.

    As a result i get users AND groups. My question: How can i find out, what the single result is (person or group)?

    This is my code, i get a Resultpropertycollection and when i loop through the collection, i want to know for each item if it is a person or group.

                For Each sr As SearchResult In ds.FindAll
                    Dim valueCollection As ResultPropertyValueCollection = sr.Properties("member")
                    Dim propertyValue As Object
                    For Each propertyValue In valueCollection
                        Console.WriteLine("{0}", propertyValue.ToString())
                    Next propertyValue

    Thursday, September 13, 2012 3:05 PM

All replies

  • User633205417 posted

    Can you tell us more about your structure of Domain Controller and also the code for LDAP connection string.

    Wednesday, September 26, 2012 9:33 AM
  • User2085410294 posted


    i think i found the solution. I would like to share it here.

    A returned object has a property called SchemaClassName. By checking this property i am able to distinguish between groups and persons/users.

    Hope this helps.

    Thursday, September 27, 2012 3:15 PM