Hello!
I need to get a list of all members of a specific group (whether or not the currently logged-in user is a member of that group) in a VB.NET codebehind page.
I am able to get all the information on the currently logged-in user (full name, phone number, e-mail address, etc.), but I cannot get my head around the filters needed to get membership in a group.
Here is what I have so far:
Public Function GetSalesGroup()
Dim search As DirectorySearch er = New DirectorySearch er(_path)
search.Filter = "(cn=Sales) "
search.Properti esToLoad.Add("g roup")
Dim groupNames As StringBuilder = New StringBuilder
Try
Dim result As SearchResult = search.FindOne( )
Dim propertyCount As Integer = result.Properti es("memberOf"). Count
Dim dn As String
Dim equalsIndex, commaIndex
Dim propertyCounter As Integer
For propertyCounter = 0 To propertyCount - 1
dn = CType(result.Pr operties("membe rOf")(propertyC ounter), String)
equalsIndex = dn.IndexOf("=", 1)
commaIndex = dn.IndexOf(",", 1)
If (equalsIndex = -1) Then
Return Nothing
End If
groupNames.Appe nd(dn.Substring ((equalsIndex + 1), (commaIndex - equalsIndex) - 1))
groupNames.Appe nd("|")
Next
Catch ex As Exception
Throw New Exception("Erro r obtaining Sales group membership. " & ex.Message & "<br>")
End Try
Return groupNames.ToSt ring()
End Function
The results of this are supposed to be thrown to a session variable upon return.
Help!
Thanks!
SteveO
--
Message posted via http://www.dotnetmonster.com